you can write simple serializers for the state type
and specify the serializer in the jibx binding file.
then your method will be called to translate the
state attribute value to restore your enum and
vice versa. the jibx documentation shows you
how to do this. i hope this helps.
/ eitan
On Apr 13, 2005, at 7:03 AM, Paul Tomsic wrote:
re: @symbols
right, i was thinking and typing attribute. ;-)
thanks for clarification on the mapping, but there's
one other issue at work here - the State class that I
have is an ENUM class, so it's already got the values
that may be entered via the XML.
So the State class would be used like (in java code):
String state = "PA";
if(STATE.PENNSYLVANIA == state) {
// proceed
so, in the model from jibx, it appears that I've
simply got to "hope" that the attribute entered from
the XML is already contained in my ENUM class. Of
course, state's just an example, but I've also got the
same w/ COUNTRY and a number of other classes.
Is it possible to pre-process or look-up the enum
while the jibx is working at runtime?
--- Dennis Sosnoski <[EMAIL PROTECTED]> wrote:
If I understand Paul's original statement correctly
I think what he'd
want would be (combining everything into one
mapping):
<mapping name="Person" value-style="attribute"
class="yourpackagename.Person">
<value name="name" field="_name"/>
<structure name="Address" field="_address"> <!--
wrap values from
_address object in "address" element -->
<value name="city" field="_city"/>
<structure field="_state"> <!-- include
values from _state object
directly in current "address" element -->
<value name="state" field="_code"/>
</structure>
</structure>
</mapping>
The difference is that in the mapping Eitan gave
you'd have a separate
"state" element containing the state code.
I assume you don't really want those '@' characters
on the attribute
names, Paul, since they're not legal in XML.
- Dennis
Eitan Suez wrote:
you have two choices:
1. you can define the mapping for all structures
in a single
mapping, nesting in the definitions for
address and state,
or
2. you can define three mappings, one for each
type, and
reference them.
example for #1: (just for address and state)
<binding>
<mapping name="address"
class="yourpackagename.Address">
<structure name="state" field="_state">
<value name="code" field="_code" />
</structure>
</mapping>
</binding>
example for #2:
<binding>
<mapping name="address"
class="yourpackagename.Address">
<structure field="_state" />
</mapping>
<mapping name="state"
class="yourpackagename.State">
<value name="code" field="_code" />
</mapping>
</binding>
/ eitan
On Apr 11, 2005, at 5:57 PM, Paul Tomsic wrote:
I'm trying to set a class from an attribute, but
it's
actually two steps down...
Here's my xml:
<Person name="Paul">
<Address @city="Philadelphia" @state="PA"/>
....
So my Person class contains an Address class,
which
contains a State class. How would I set up the
Address class and the State class that is a field
on
the Address?
Here's my classes:
public class Person {
private Address _address;
....
public class Address {
private State _state;
public class State {
private String _code;
What would my mapping look like to set the State
from
that attribute?
Thanks
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT
Products from real users.
Discover which products truly live up to the hype.
Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT
Products from real users.
Discover which products truly live up to the hype.
Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real
users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users