[prev in list] [next in list] [prev in thread] [next in thread]
List: jibx-users
Subject: [jibx-users] Collection of Primitive Types with size, load,
From: "Thomas Weise" <tweise () gmx ! de>
Date: 2011-03-20 11:18:29
Message-ID: 003101cbe6f0$8e031fa0$aa095ee0$ () de
[Download RAW message or body]
Dear JiBX community.
I want to specify a JiBX binding for a class which is used
to represent lists of integer (int) values, i.e., lists of
primitive types. This class provides a size, a getter (loader),
and a adder method.
I am using the latest version of JiBX. I have searched my
problem in the mailing list archive but was unable to find
a solution for it there.
Simplified, my class could look like:
public class MyObject {
...
public int size() {...}
public int get(int index) {...}
public void add(int val) {...}
}
The data is neither stored in an array nor in some sort
of Collection class from the java.util package.
I tried some binding similar to:
<mapping type-name="a:myObject" abstract="true" ordered="true"
class="org.something.myObject">
<collection name="myInts" ordered="true" size-method="size"
load-method="get" add-method="add" />
</mapping>
This leads to the error in the Schema generator
org.jibx.schema.generator.SchemaGen, which also occurs with
'item-type="java.lang.Integer"':
Error: add-method add not found in class ...
Error: load-method get not found in class ...
To the collection specification, I can add a 'item-type="int"'.
Then, I get in the Schema generator org.jibx.schema.generator.SchemaGen:
Warning: Handling not implemented for unspecified mapping; on collection element at ..
Warning: No type defined for element 'myInts' at (source unknown)
Then, the binding compiler tells me:
Error running binding compiler
*** Error during code generation for file ...
this may be due to an error in your binding or classpath, or to an error in the JiBX code ***
java.lang.RuntimeException: Can not cast java.lang.Object to int
I would be very thankful for any suggestion on how this problem
can be solved. OK, I could add a "get" and "add" method which
accepts/provides boxed integers (in java.lang.Integer), but this
would be rather ugly. The add method does some additional computations,
so I really want to use it, so a solution like "use an int[] array"
would also not really be nice.
Is there any way to let JiBX use the collection access methods
for primitive types?
Many thanks,
Thomas.
------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic