Invoking of set/get methods in JIBX

Discussion in 'Java' started by Ajay Singh Tomar, Jan 22, 2004.

  1. Hello,

    I couldn't locate how to invoke get and set methods from the Java code with
    Binding Definition for JIBX as given below.

    <binding>

    <mapping name="customer" class="Customer">

    <structure name="person" field="person">

    <value name="cust-num" get-method="getNumber" set-method="setNumber" />

    <value name="first-name" field="firstName" />

    <value name="last-name" field="lastName" />

    </structure>

    <value name="street" field="street" />

    <value name="city" field="city" />

    <value name="state" field="state" />

    <value name="zip" field="zip" />

    <value name="phone" field="phone" />

    </mapping>

    </binding>

    This is the Java file for calling the methods. Please tell me what needs to
    be modified here.

    import java.io.FileInputStream;

    import java.io.FileOutputStream;

    import org.jibx.runtime.BindingDirectory;

    import org.jibx.runtime.IBindingFactory;

    import org.jibx.runtime.IMarshallingContext;

    import org.jibx.runtime.IUnmarshallingContext;

    public class Customer

    {

    public Customer()

    {

    try

    {

    IBindingFactory bfact = BindingDirectory.getFactory(Customer.class);

    IUnmarshallingContext uctx = bfact.createUnmarshallingContext();

    Object obj = uctx.unmarshalDocument(new FileInputStream("input.xml"), null);


    Customer cst = new Customer ();

    cst.setNumber(4);


    IMarshallingContext mctx = bfact.createMarshallingContext();

    mctx.setIndent(4);

    mctx.marshalDocument(obj, "UTF-8", null,new FileOutputStream("output.xml"));


    }

    catch(Exception e)

    {

    System.out.println(e.toString());

    }

    }

    public static void main(String[] args)

    {

    Customer test1 = new Customer ();

    }


    }

    Please help.

    Regards,

    Ajay
    Ajay Singh Tomar, Jan 22, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    3
    Views:
    7,459
    lordabhi
    Aug 24, 2009
  2. Matthias Langbein

    JibX with an existing DOM-Tree

    Matthias Langbein, May 8, 2006, in forum: XML
    Replies:
    0
    Views:
    549
    Matthias Langbein
    May 8, 2006
  3. coltrane

    Looking for Jibx examples

    coltrane, Sep 20, 2006, in forum: Java
    Replies:
    4
    Views:
    7,334
    coltrane
    Sep 21, 2006
  4. Jimmy
    Replies:
    0
    Views:
    455
    Jimmy
    Mar 13, 2007
  5. Replies:
    0
    Views:
    412
Loading...

Share This Page