Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-10-2008, 08:53 PM
Member
 
Join Date: Jul 2008
Posts: 1
prateek is on a distinguished road
JAXB Unmarshalling
Hi,this is regarding JAXB API doing Unmarshalling for the Person.java class
.but what i need is the Unmarshalling method for the generalized class.
here folder is the generated folder containing Person and ObjectFactory class after compiling with the xjc compiler.
i have tried the same but with no answer

This answer is specific to Person.java class what i want is answer with no Person word i.e generalize method.


import java.io.*;
import java.io.File;
import java.util.Date;
import java.io.*;
import folder.*;

import folder.Person;
import folder.ObjectFactory;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.Marshaller;

public class Unmarshaltrr
{

public Unmarshaltrr()
{

}

public void UnMarshal_fn(ByteArrayOutputStream buf_in)

{ try

{

JAXBContext jc = JAXBContext.newInstance ("folder");

Unmarshaller u = jc.createUnmarshaller ();
ObjectInputStream in=new ObjectInputStream(new ByteArrayInputStream(buf_in.toByteArray()));


JAXBElement element = (JAXBElement) u.unmarshal (in);


Person item=(Person)element.getValue();//Person not Required
System.out.println (item.getName()); //these are the values in Person
System.out.println (item.getDateOfBirth());
System.out.println (item.getType());

}
catch (JAXBException e)
{

e.printStackTrace ();


}


catch(IOException e)
{
e.getMessage();
}


} // UnMarshal_fn

}

I tried to do with Reflection Property.Passed the Person object from the Main method
unmarshal_fn( ,Person a);\\function calling

Unmarshalling method:-
unmarshal_fn( , Object obj)
{
Class c=obj.getClass();
.
.
.

c item =(c)element.getValue();
System.out.println(item.getName());// this is a wrong statement-this is the problem how should i make the object of the Person class here????
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
JAXB unmarshall not responding (help needed) Buglish XML 0 06-04-2008 01:26 AM
How to clone a JAXB object ? simon Advanced Java 1 07-15-2007 01:56 AM


All times are GMT +3. The time now is 05:28 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org