net.craftforge.essential.supply.jaxb
Class JaxbConsumer

java.lang.Object
  extended by net.craftforge.essential.supply.Consumer
      extended by net.craftforge.essential.supply.jaxb.JaxbConsumer

public class JaxbConsumer
extends Consumer

Serializes objects.

Since:
26.02.2011
Author:
Christian Bick

Field Summary
 
Fields inherited from class net.craftforge.essential.supply.Consumer
config
 
Constructor Summary
JaxbConsumer(Configuration config)
           
 
Method Summary
 Object json(Class<?> type, InputStream input, String charset)
          Deserializes the input stream in JSON format to an object of the specified type.
 Object xml(Class<?> type, InputStream input, String charset)
          Deserializes the input stream in XML format to an object of the specified type.
 
Methods inherited from class net.craftforge.essential.supply.Consumer
consume, consume, plain
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JaxbConsumer

public JaxbConsumer(Configuration config)
Method Detail

xml

public Object xml(Class<?> type,
                  InputStream input,
                  String charset)
           throws JAXBException,
                  IOException
Deserializes the input stream in XML format to an object of the specified type.

Parameters:
type - The type
input - The input stream
charset - The charset encoding
Returns:
The object
Throws:
JAXBException - Failed to convert the input to an object
UnsupportedEncodingException - Failed to process the charset
IOException

json

public Object json(Class<?> type,
                   InputStream input,
                   String charset)
            throws IOException
Deserializes the input stream in JSON format to an object of the specified type.

Parameters:
type - The type
input - The input stream
charset - The charset encoding
Returns:
The object
Throws:
IOException - Failed to convert the input to an object


Copyright © 2011. All Rights Reserved.