Search in sources :

Example 1 with IUnmarshallingContext

use of org.jibx.runtime.IUnmarshallingContext 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 2 with IUnmarshallingContext

use of org.jibx.runtime.IUnmarshallingContext 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 3 with IUnmarshallingContext

use of org.jibx.runtime.IUnmarshallingContext 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)

Example 4 with IUnmarshallingContext

use of org.jibx.runtime.IUnmarshallingContext in project camel by apache.

the class JibxDataFormat method unmarshal.

public Object unmarshal(Exchange exchange, InputStream stream) throws Exception {
    Class<?> unmarshallType = exchange.getIn().getHeader(UNMARSHALL_CLASS, Class.class);
    if (unmarshallType == null) {
        unmarshallType = getUnmarshallClass();
    }
    ObjectHelper.notNull(unmarshallType, "unmarshallClass or CamelJibxUnmarshallClass header");
    IBindingFactory bindingFactory = createBindingFactory(unmarshallType, bindingName);
    IUnmarshallingContext unmarshallingContext = bindingFactory.createUnmarshallingContext();
    return unmarshallingContext.unmarshalDocument(stream, null);
}
Also used : IUnmarshallingContext(org.jibx.runtime.IUnmarshallingContext) IBindingFactory(org.jibx.runtime.IBindingFactory)

Aggregations

IBindingFactory (org.jibx.runtime.IBindingFactory)4 IUnmarshallingContext (org.jibx.runtime.IUnmarshallingContext)4 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 InputStream (java.io.InputStream)1