If you're just unmarshalling you should be able to use a regular mapping
even for system classes. Marshalling instances back out as the root
object wouldn't work, though.
One easy way around this is to just use a trivial extension of the
ArrayList class:
public class MyArrayList extends ArrayList {}
Then you can create the <mapping> for MyArrayList, and the original code:
Object obj = uctx.unmarshalDocument
(new FileInputStream("orders.xml"), null);
ArrayList ords = (ArrayList) obj;
will work directly (of course, the object returned will actually be an
instance of MyArrayList - but it'll be usable as ArrayList).
- Dennis
Mocky Habeeb wrote:
I don't think you can bind the root element of your document to a base
java type, for one thing it would mean bytecode enhancing a class that
is sitting in rt.jar, which even if it were possible it would probably
be a bad idea. But it's easy enough to use a wrapper type of your own
making to hold the ArrayList. Then you would be doing this:
ArrayList ords = ((OrdersWrapper)obj).getOrders();
Mocky
-----Original Message-----
*From:* [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] *On Behalf Of
*Stephan Rossouw
*Sent:* Wednesday, October 05, 2005 8:18 AM
*To:* [email protected]
*Subject:* [jibx-users] Getting an ArrayList back
I have a order.xml file full of orders:
<?xml version="1.0" encoding="UTF-8"?>
<orders>
<order>
<order_number>v001</order_number>
<id>1</id>
<order_date>2000-03-21T01:33:00</order_date>
</order>
<order>
<order_number>v001</order_number>
<id>1</id>
<order_date>2000-03-21T01:33:00</order_date>
</order>
</orders>
And I want to bind it so that in the end I have a ArrayList of all
the orders.
This is what I want to do:
Object obj = uctx.unmarshalDocument
(new FileInputStream("orders.xml"), null);
ArrayList ords = (ArrayList) obj;
*>** **Stephan Rossouw** * *EasyPay – Developer*
*|** *Tel (direct): +27 (21) 680 0106* |** *Tel (reception): +27
(21) 680 0100* |** *Fax: +27 (21) 686 1400* |** *Cell: 0833217906*
| [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> *|** *www.easypay.co.za
<http://www.easypay.co.za/>
EasyPay (Pty) Ltd, Ground Floor, EasyPay House, 14 Belmont Road,
Belmont Office Park, Rondebosch, Cape Town, South Africa, 7700
PO Box 58, Rondebosch, Cape Town, South Africa, 7701
**
*|** *Disclaimer* **|*
NOTICE: this electronic mail and any attachments ("message")
contain privileged information intended only for the addressee(s)
use. If you are not the/an intended recipient, you may not
disclose, review, disseminate, retransmit, copy, use or take
action in reliance upon or otherwise deal with or publish this
message, which is subject to copyright ("Use"). You may not use
this message for anything other than the purpose for which it is
intended. If you have received this message in error, you are
required to notify the writer and delete it. EasyPay accepts no
liability whatsoever as a result of any losses arising from
persons placing reliance on any information contained in this
message or and Use thereof. The views expressed in this message
are those of the individual transmitting it, unless they are
expressly stated to be those of EasyPay. It is the recipient’s
obligation to scan this message and ensure that it contains no
viruses or other malicious programs and the recipient is warned
that, notwithstanding reasonable checks performed by EasyPay,
viruses and harmful programs may be contained in this message and
EasyPay accepts no liability whatsoever for any loss, damage, or
liability of any nature, whether direct or indirect, resulting
from the recipient accessing or Using this message or any files
attached to it.
-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users