net.craftforge.essential.supply
Class Consumer
java.lang.Object
net.craftforge.essential.supply.Consumer
- Direct Known Subclasses:
- JaxbConsumer
public class Consumer
- extends Object
De-serializes strings to objects.
- Since:
- 02.12.2010
- Author:
- Christian Bick
|
Method Summary |
Object |
consume(Class<?> clazz,
String mediaType,
InputStream inputStream,
String charset)
Consumes the given input stream, deserializing it to an object of the
specified class. |
Object |
consume(Class<?> clazz,
String mediaType,
String input)
Consumes the given input string, deserializing it to an object of the
specified class. |
Object |
plain(Class<?> clazz,
String input)
Consumes the given input string, deserializing it to an object of the
specified class. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
config
protected Configuration config
Consumer
public Consumer(Configuration config)
consume
public Object consume(Class<?> clazz,
String mediaType,
String input)
throws ControllerException
- Consumes the given input string, deserializing it to an object of the
specified class. The consumer method is chosen accordingly to the given
media type. The responsible consumer method must contain this media type
in its @Consumes annotation.
- Parameters:
clazz - The class of the desired result objectmediaType - The media type (e.g. text/xml)input - The input string
- Returns:
- The result object
- Throws:
ControllerException - if the consumption process fails
consume
public Object consume(Class<?> clazz,
String mediaType,
InputStream inputStream,
String charset)
throws ControllerException
- Consumes the given input stream, deserializing it to an object of the
specified class. The given charset is used to decode the stream.
The consumer method is chosen accordingly to the given
media type. The responsible consumer method must contain this media type
in its @Consumes annotation.
- Parameters:
clazz - The class of the desired result objectmediaType - The media type (e.g. text/xml)inputStream - The input streamcharset - The charset
- Returns:
- The result object
- Throws:
ControllerException - if the consumption process fails
plain
public Object plain(Class<?> clazz,
String input)
throws ControllerException,
InstantiationException,
InvocationTargetException,
IllegalAccessException
- Consumes the given input string, deserializing it to an object of the
specified class.
- Parameters:
clazz - The class of the desired result objectinput - The input stream
- Returns:
- The result object
- Throws:
ControllerException - Failed to find a convenient method to initialize object from input
InstantiationException - Failed to instantiate object from constructor
InvocationTargetException - Failed to invoke 'valueOf' method
IllegalAccessException - Failed to invoke constructor or 'valueOf' method
Copyright © 2011. All Rights Reserved.