Sorry, I do not understand.
>>> obj.getClass() returns with a Class object not with a SwissProt object;
>>> I have seen somewhere obj.cast(ToMyObject), but the 'Object' class
does not have any cast() method. ???
I think independently of the reflection I have to convert/cast a general
(Object type) object into the object I would like to use (SwissProt).
=============
OK. My problem is solved: I do not have to cast the Object type obj into
my object, as I am going to hande the obj all the time by reflection.
However I am going to use also a third party package that does not need
to know about the fields of the objects, but it may need a specific type
of objects (not Object type, but SwissProt type (or some user defined))...
=============
Independently of the aboves I would like to know if there is an existing
casting possibility or not (at this moment just scientific type curiosity)
I am sorry that this is some general java question, but I run into this
becuse of jibx and all the members of this list seems to be nice and
professional :-)
Tamas
Davies, Joshua wrote:
Well, the following bit of code:
Object obj = uctx.unmarshalElement();
System.out.println( obj.getClass( ).getName( ) );
Will print out:
"SwissProt"
In the example you gave below; in other words,
java.lang.Object.getClass( ) always returns the actual type of the
object. So, if you're going to be doing reflective programming, you
probably just want to pass "obj.getClass( )" into your reflective
methods and code them generically from there.
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Tamas
Hegedus
Sent: Thursday, August 25, 2005 9:34 AM
To: [email protected]
Subject: [jibx-users] dynamic casting & performance
Hi,
My current problem is loosly connected to jibx but all the routs go to
Sosnoski Inc: I was googling the 'cast...'
I would like to make dynamic casting, but it seems it not commonly used
and people bringing up the topic does not know much about it even about
the casting (?). E.g. I have red that the casting is just saying to the
compiler that you know better than the compiler that this object is that
particular type. But see my example:
// This works fine
Object obj = uctx.unmarshalElement();
SwissProt sp2 = (SwissProt) obj;
for(int i = 0; i < sp2.accessions.length; i++ ) {
System.out.println( sp2.accessions[i]);
};
// This doesn't (I am not surprised)
Object obj = uctx.unmarshalElement();
for(int i = 0; i < obj.accessions.length; i++ ) {
System.out.println( obj.accessions[i]);
};
===========================================
I would like to have the following situation:
> I write a java-package (a very dynamic one);
> The users creates the jibx binding fieles and the corresponding java
class files;
====> I do not know what type of object will be unmarshelled at the time
of the writing of my package;
> The users have to make compile and binding steps (but I do not think
that my problem can be solved at this step);
!!! > unmarshaling into the object that was created by the user; that
needs the dynamic casting; how???
> I plan handle the object with java reflection (and my own classes
reflecting the object).
The other important thing connected to Dannis' earlier work: I would
like to unmarshall large documents with pretty large and complicated
objects with pretty high number of objects; the performance of the
casting could become important bottleneck.
Thanks for the solutions :-), ideas, comments,
Tamas
--
Tamas Hegedus, PhD | phone: (1) 919-966 0329
UNC - Biochem & Biophys | fax: (1) 919-966 5178
5007A Thurston-Bowles Bldg | mailto:[EMAIL PROTECTED]
Chapel Hill, NC, 27599-7248 | http://biohegedus.org
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users