net.craftforge.essential.supply.jaxb
Class JaxbProducer

java.lang.Object
  extended by net.craftforge.essential.supply.Producer
      extended by net.craftforge.essential.supply.jaxb.JaxbProducer

public class JaxbProducer
extends Producer

Serializes objects using JAXB annotations.

Since:
02.12.2010
Author:
Christian Bick

Field Summary
 
Fields inherited from class net.craftforge.essential.supply.Producer
config
 
Constructor Summary
JaxbProducer(Configuration config)
          Constructs the producer by supplying the controller configuration.
 
Method Summary
 void json(Object result, OutputStream out, String charset)
          Serializes the result object to JSON, using the specified character encoding.
 void xml(Object result, OutputStream out, String charset)
          Serializes the result object to XML, using the specified character encoding.
 
Methods inherited from class net.craftforge.essential.supply.Producer
getBestMatchingMediaType, plain, produce
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JaxbProducer

public JaxbProducer(Configuration config)
Constructs the producer by supplying the controller configuration.

Parameters:
config - The configuration
Method Detail

xml

public void xml(Object result,
                OutputStream out,
                String charset)
         throws JAXBException,
                IOException
Serializes the result object to XML, using the specified character encoding. Uses the output stream for streaming.

Parameters:
result - The result
out - The output stream
charset - The character encoding
Throws:
JAXBException - Failed to serialize object to XML
UnsupportedEncodingException - Unsupported charset encoding
IOException

json

public void json(Object result,
                 OutputStream out,
                 String charset)
          throws ControllerException,
                 IOException
Serializes the result object to JSON, using the specified character encoding. Uses the output stream for streaming.

Parameters:
result - The result
out - The output stream
charset - The character encoding
Throws:
IOException - Failed to serialize object to JSON
ControllerException - Invalid JSON property


Copyright © 2011. All Rights Reserved.