Package org.apache.juneau.marshaller
Class StreamMarshaller
java.lang.Object
org.apache.juneau.marshaller.Marshaller
org.apache.juneau.marshaller.StreamMarshaller
- Direct Known Subclasses:
MsgPack
-
Constructor Summary
ConstructorsConstructorDescriptionConstructor. -
Method Summary
Modifier and TypeMethodDescriptionfinal <T> TSame asMarshaller.read(Object,Class)but reads from a byte array and thus doesn't throw anIOException .final <T> TSame asMarshaller.read(Object,Type,Type...)but reads from a byte array and thus doesn't throw anIOException .final byte[]Serializes a POJO directly to a.byte []Methods inherited from class org.apache.juneau.marshaller.Marshaller
getParser, getSerializer, read, read, write
-
Constructor Details
-
StreamMarshaller
Constructor.- Parameters:
s- The serializer to use for serializing output.
Must not benull .p- The parser to use for parsing input.
Must not benull .
-
-
Method Details
-
read
Same asMarshaller.read(Object,Class)but reads from a byte array and thus doesn't throw anIOException .This is the preferred parse method for simple types since you don't need to cast the results.
Examples:
Marshaller
marshaller = Json.DEFAULT ;// Parse into a string. Stringstring =marshaller .read(json , String.class );// Parse into a bean. MyBeanbean =marshaller .read(json , MyBean.class );// Parse into a bean array. MyBean[]beanArray =marshaller .read(json , MyBean[].class );// Parse into a linked-list of objects. Listlist =marshaller .read(json , LinkedList.class );// Parse into a map of object keys/values. Mapmap =marshaller .read(json , TreeMap.class );- Type Parameters:
T- The class type of the object being created.- Parameters:
input- The input.type- The object type to create.- Returns:
- The parsed object.
- Throws:
ParseException- Malformed input encountered.
-
read
Same asMarshaller.read(Object,Type,Type...)but reads from a byte array and thus doesn't throw anIOException .- Type Parameters:
T- The class type of the object to create.- Parameters:
input- The input.type- The object type to create.
Can be any of the following:ClassMeta,Class,ParameterizedType,GenericArrayTypeargs- The type arguments of the class if it's a collection or map.
Can be any of the following:ClassMeta,Class,ParameterizedType,GenericArrayType
Ignored if the main type is not a map or collection.- Returns:
- The parsed object.
- Throws:
ParseException- Malformed input encountered.- See Also:
-
write
Serializes a POJO directly to a.byte []- Parameters:
o- The object to serialize.- Returns:
- The serialized object.
- Throws:
SerializeException- If a problem occurred trying to convert the output.
-