Search in sources :

Example 1 with IBindingFactory

use of org.jibx.runtime.IBindingFactory in project RESTdoclet by IG-Group.

the class JiBXUtils method marshallController.

/**
    * Static method for marshalling a controller.
    * 
    * @param controller the controller to be marshalled.
    * @param file the file the controller has to be marshalled to.
    * @throws JiBXException if JiBX fails.
    * @throws IOException if an input- or output-exception occurs.
    */
public static void marshallController(final Controller controller, final File file) throws JiBXException, IOException {
    final Writer writer = new FileWriter(file);
    final IBindingFactory factory = BindingDirectory.getFactory(Controller.class);
    final IMarshallingContext context = factory.createMarshallingContext();
    context.setIndent(INDENT);
    context.setOutput(writer);
    context.marshalDocument(controller, ENCODING, null);
}
Also used : IMarshallingContext(org.jibx.runtime.IMarshallingContext) IBindingFactory(org.jibx.runtime.IBindingFactory) FileWriter(java.io.FileWriter) FileWriter(java.io.FileWriter) Writer(java.io.Writer)

Example 2 with IBindingFactory

use of org.jibx.runtime.IBindingFactory in project RESTdoclet by IG-Group.

the class JiBXUtils method marshallService.

/**
    * Static method for marshalling a service.
    * 
    * @param service the service to be marshalled.
    * @param file the file the service has to be marshalled to.
    * @throws JiBXException if JiBX fails.
    * @throws IOException if an input- or output-exception occurs.
    */
public static void marshallService(final Service service, final File file) throws JiBXException, IOException {
    final Writer writer = new FileWriter(file);
    final IBindingFactory factory = BindingDirectory.getFactory(Service.class);
    final IMarshallingContext context = factory.createMarshallingContext();
    context.setIndent(INDENT);
    context.setOutput(writer);
    context.marshalDocument(service, ENCODING, null);
}
Also used : IMarshallingContext(org.jibx.runtime.IMarshallingContext) IBindingFactory(org.jibx.runtime.IBindingFactory) FileWriter(java.io.FileWriter) FileWriter(java.io.FileWriter) Writer(java.io.Writer)

Example 3 with IBindingFactory

use of org.jibx.runtime.IBindingFactory in project RESTdoclet by IG-Group.

the class JiBXUtils method unmarshallController.

/**
    * Static method for unmarshalling a controller.
    * 
    * @param file the file the controller has to be unmarshalled from.
    * @return the unmarshalled controller.
    * @throws JiBXException if JiBX fails.
    * @throws FileNotFoundException if the input file can't be found.
    */
public static Controller unmarshallController(final File file) throws JiBXException, FileNotFoundException {
    final IBindingFactory factory = BindingDirectory.getFactory(Controller.class);
    final IUnmarshallingContext context = factory.createUnmarshallingContext();
    final InputStream stream = new FileInputStream(file);
    return (Controller) context.unmarshalDocument(stream, ENCODING);
}
Also used : IUnmarshallingContext(org.jibx.runtime.IUnmarshallingContext) IBindingFactory(org.jibx.runtime.IBindingFactory) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) Controller(com.iggroup.oss.restdoclet.doclet.type.Controller) FileInputStream(java.io.FileInputStream)

Example 4 with IBindingFactory

use of org.jibx.runtime.IBindingFactory in project RESTdoclet by IG-Group.

the class JiBXUtils method unmarshallServices.

/**
    * Static method for unmarshalling services.
    * 
    * @param input the input-stream services have to be unmarshalled from.
    * @return the unmarshalled services..
    * @throws JiBXException if JiBX fails.
    * @throws FileNotFoundException if the input file can't be found.
    */
public static Services unmarshallServices(final InputStream input) throws JiBXException, FileNotFoundException {
    final IBindingFactory factory = BindingDirectory.getFactory(Services.class);
    final IUnmarshallingContext context = factory.createUnmarshallingContext();
    return (Services) context.unmarshalDocument(input, ENCODING);
}
Also used : IUnmarshallingContext(org.jibx.runtime.IUnmarshallingContext) Services(com.iggroup.oss.restdoclet.doclet.type.Services) IBindingFactory(org.jibx.runtime.IBindingFactory)

Example 5 with IBindingFactory

use of org.jibx.runtime.IBindingFactory in project RESTdoclet by IG-Group.

the class JiBXUtils method unmarshallService.

/**
    * Static method for unmarshalling a service.
    * 
    * @param input the input-stream the service has to be unmarshalled from.
    * @return the unmarshalled service.
    * @throws JiBXException if JiBX fails.
    */
public static Service unmarshallService(final InputStream input) throws JiBXException {
    final IBindingFactory factory = BindingDirectory.getFactory(Service.class);
    final IUnmarshallingContext context = factory.createUnmarshallingContext();
    return (Service) context.unmarshalDocument(input, ENCODING);
}
Also used : IUnmarshallingContext(org.jibx.runtime.IUnmarshallingContext) IBindingFactory(org.jibx.runtime.IBindingFactory) Service(com.iggroup.oss.restdoclet.doclet.type.Service)

Aggregations

IBindingFactory (org.jibx.runtime.IBindingFactory)21 IUnmarshallingContext (org.jibx.runtime.IUnmarshallingContext)13 IMarshallingContext (org.jibx.runtime.IMarshallingContext)9 InputStream (java.io.InputStream)5 FileWriter (java.io.FileWriter)3 Writer (java.io.Writer)3 URL (java.net.URL)3 Configuration (org.exoplatform.container.xml.Configuration)3 Test (org.junit.Test)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 FileOutputStream (java.io.FileOutputStream)2 IOException (java.io.IOException)2 Component (org.exoplatform.container.xml.Component)2 ObjectParameter (org.exoplatform.container.xml.ObjectParameter)2 Controller (com.iggroup.oss.restdoclet.doclet.type.Controller)1 Service (com.iggroup.oss.restdoclet.doclet.type.Service)1 Services (com.iggroup.oss.restdoclet.doclet.type.Services)1 FileInputStream (java.io.FileInputStream)1 StringReader (java.io.StringReader)1 StringWriter (java.io.StringWriter)1