Invoking of set/get methods in JIBX

A

Ajay Singh Tomar

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top