org.joda.beans.ser
Class JodaBeanSer

java.lang.Object
  extended by org.joda.beans.ser.JodaBeanSer

public final class JodaBeanSer
extends Object

Provides the ability for a Joda-Bean to be serialized.

Serialization of Joda-Beans uses the information in the beans to optimize the size of the data output.


Field Summary
static JodaBeanSer COMPACT
          Obtains the singleton compact instance.
static JodaBeanSer PRETTY
          Obtains the singleton pretty-printing instance.
 
Method Summary
 Class<?> decodeClass(String className, String basePackage, Map<String,Class<?>> knownTypes)
          Decodes a class.
 String encodeClass(Class<?> cls, String basePackage, Map<Class<?>,String> knownTypes)
          Encodes a basic class.
 org.joda.convert.StringConvert getConverter()
          Gets the string converter.
 String getIndent()
          Gets the pretty print indent.
 SerIteratorFactory getIteratorFactory()
          Gets the iterator factory.
 String getNewLine()
          Gets the new line string.
 SerIteratorFactory isShortTypes()
          Gets whether to use short types.
 JodaBeanSer withConverter(org.joda.convert.StringConvert converter)
          Returns a copy of this serializer with the specified string converter.
 JodaBeanSer withIndent(String indent)
          Returns a copy of this serializer with the specified pretty print indent.
 JodaBeanSer withIteratorFactory(SerIteratorFactory iteratorFactory)
          Returns a copy of this serializer with the specified iterator factory.
 JodaBeanSer withNewLine(String newLine)
          Returns a copy of this serializer with the specified pretty print new line.
 JodaBeanSer withShortTypes(boolean shortTypes)
          Returns a copy of this serializer with the short types flag set.
 JodaBeanXmlReader xmlReader()
          Creates an XML reader.
 JodaBeanXmlWriter xmlWriter()
          Creates an XML writer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMPACT

public static final JodaBeanSer COMPACT
Obtains the singleton compact instance.


PRETTY

public static final JodaBeanSer PRETTY
Obtains the singleton pretty-printing instance.

Method Detail

getIndent

public String getIndent()
Gets the pretty print indent.

Returns:
the indent, not null

withIndent

public JodaBeanSer withIndent(String indent)
Returns a copy of this serializer with the specified pretty print indent.

Parameters:
indent - the indent, not null
Returns:
a copy of this object with the indent changed, not null

getNewLine

public String getNewLine()
Gets the new line string.

Returns:
the newLine, not null

withNewLine

public JodaBeanSer withNewLine(String newLine)
Returns a copy of this serializer with the specified pretty print new line.

Parameters:
newLine - the new line, not null
Returns:
a copy of this object with the new line changed, not null

getConverter

public org.joda.convert.StringConvert getConverter()
Gets the string converter.

The default converter can be modified.

Returns:
the converter, not null

withConverter

public JodaBeanSer withConverter(org.joda.convert.StringConvert converter)
Returns a copy of this serializer with the specified string converter.

The default converter can be modified.

Parameters:
converter - the converter, not null
Returns:
a copy of this object with the converter changed, not null

getIteratorFactory

public SerIteratorFactory getIteratorFactory()
Gets the iterator factory.

Returns:
the iterator factory, not null

withIteratorFactory

public JodaBeanSer withIteratorFactory(SerIteratorFactory iteratorFactory)
Returns a copy of this serializer with the specified iterator factory.

Parameters:
iteratorFactory - the iterator factory, not null
Returns:
a copy of this object with the iterator factory changed, not null

isShortTypes

public SerIteratorFactory isShortTypes()
Gets whether to use short types.

Returns:
the short types flag, not null

withShortTypes

public JodaBeanSer withShortTypes(boolean shortTypes)
Returns a copy of this serializer with the short types flag set.

Parameters:
shortTypes - whether to use short types, not null
Returns:
a copy of this object with the short types flag changed, not null

encodeClass

public String encodeClass(Class<?> cls,
                          String basePackage,
                          Map<Class<?>,String> knownTypes)
Encodes a basic class.

This handles known simple types, like String, Integer or File, and prefixing. It also allows a map of message specific shorter forms.

Parameters:
cls - the class to encode, not null
basePackage - the base package to use with trailing dot, null if none
knownTypes - the known types map, null if not using known type shortening
Returns:
the class object, null if not a basic type

decodeClass

public Class<?> decodeClass(String className,
                            String basePackage,
                            Map<String,Class<?>> knownTypes)
                     throws ClassNotFoundException
Decodes a class.

This uses the context class loader. This handles known simple types, like String, Integer or File, and prefixing. It also allows a map of message specific shorter forms.

Parameters:
className - the class name, not null
basePackage - the base package to use with trailing dot, null if none
knownTypes - the known types map, null if not using known type shortening
Returns:
the class object, not null
Throws:
ClassNotFoundException - if not found

xmlWriter

public JodaBeanXmlWriter xmlWriter()
Creates an XML writer.

Returns:
the XML writer, not null

xmlReader

public JodaBeanXmlReader xmlReader()
Creates an XML reader.

Returns:
the XML reader, not null


Copyright © 2007–2013 Joda.org. All rights reserved.