I'm not entirely sure I understand what you're trying to do...
do you just want to cast the Object to a String?
String theValue = (String)getId();
or is something else required?
if you post a brief code sample so that we can see more easily what you're trying to accomplish, then maybe we can help you.
T
I try in both mode:
- if I use Cast ( (String) obj.getId() ) i recieve a java.lang.ClassCast Exception;
- if I use toString() method, the strResult is the index (in memory I presume) of the value, but not the true value.
I use JAXB, but I think this problem is related standard JAVA library.
The code:
-
public void gestisci_slave(SlaveType slave,List module){
ObjectType obj;
String s;
List elemento;
obj=slave.getObject();
s= obj.getId().toString();
System.out.println("ID= "+s);
}
-
where:
- ObjectType and SlaveType are types generated by JAXB;
- slave.getObject() return me an ObjectType type;
- obj.getId() return me an Object type (java.lang.Object);
If I execut code, the s output is:
ID= xml.modify.impl.ClipImpl@82d210
xml.modify.impl.ClipImpl identify a class generated by JAXB, @82d210 is (I presume) memory address.
How can I get the true value?
I try with Reference and RefAddr type, but.....nothing!!!!
Any idea?
PS: in JAXB documentation there is Reference type link, but the html file is empty!!
You can't get the string representation in the format you want. because the SlaveType class doesn't seems to override the toString() method. It is encapsulated in that way. You must encapsulate a method to achive it. Otherwise you will get the output as xml.modify.impl.ClipImpl@xxxxx only.
(Dhananjay Singh)