Joda System API

org.joda.property.xml
Class XMLMetaData

java.lang.Object
  |
  +--org.joda.property.xml.XMLMetaData

public final class XMLMetaData
extends java.lang.Object

Class defining the 'rules' for converting data to and from XML. Generally an application will create one instance of this class and reuse it throughout the application. This can be achieved by customising the default obtained from getDefault.

Author:
Stephen Colebourne

Constructor Summary
XMLMetaData()
          Constructor
 
Method Summary
 void addXMLConvertor(XMLConvertor convertor)
          Add an xml convertor used to convert to and from xml at the end of the list of convertors.
 void addXMLFilter(XMLFilter filter)
          Add an xml convertor used to convert to and from xml at the end of the list of convertors.
 boolean getBasicTypeAsAttribute()
          Gets whether basic types should be output as attributes (true) or elements (false).
static XMLMetaData getDefault()
          Constructor
 XMLName getIDAttributeName()
          Gets the id attribute name used for object identification.
 XMLName getIDREFAttributeName()
          Gets the idref attribute name used for object identification.
 XMLName getKeyAttributeName()
          Gets the key attribute name used for Map keys.
 XMLName getNullAttributeName()
          Gets the null attribute name used to indicate a null value.
 boolean getPrettyPrint()
          Gets whether to pretty print or not.
 XMLName getTypeAttributeName()
          Gets the type attribute name used for object type identification.
 boolean getUseCollectionsElement()
          Gets whether collections should have their own element wrapping the contents of the collection (true) or the contents should be directly under the bean's element (false).
 boolean getUseCollectionsElementWhenEmpty()
          Gets whether a collection element should be output (true) if a collection has zero size and no attributes.
 boolean getUseIdrefAttributeOnRecursionOnly()
          Gets whether the idref attribute should be only be used to block recursion (true) or whenever the same bean is encountered (false) Default is to send whenever the bean is encountered twice (false).
 boolean getUseNullAttribute()
          Gets whether nulls should be output (true) or ignored (false).
 boolean getUseTypeAttribute()
          Gets whether the type attribute should be output (true) or not (false).
 boolean getUseTypeAttributeAlways()
          Gets whether the type attribute should be always be output (true) or only when required (false).
 java.util.List getXMLConvertorList()
          Get the list of xml convertors used to convert to and from xml.
 java.util.List getXMLFilterList()
          Get the list of xml convertors used to convert to and from xml.
 void insertXMLConvertor(XMLConvertor convertor)
          Add an xml convertor used to convert to and from xml at the start of the list of convertors.
 void insertXMLFilter(XMLFilter filter)
          Add an xml convertor used to convert to and from xml at the start of the list of convertors.
 void setBasicTypeAsAttribute(boolean basicTypeAsAttribute)
          Sets whether basic types should be output as attributes (true) or elements (false).
 void setIDAttributeName(XMLName idAttributeName)
          Sets the id attribute name used for object identification.
 void setIDREFAttributeName(XMLName idrefAttributeName)
          Sets the idref attribute name used for object identification.
 void setKeyAttributeName(XMLName keyAttributeName)
          Sets the key attribute name used for Map keys.
 void setNullAttributeName(XMLName nullAttributeName)
          Sets the null attribute name used to indicate a null value.
 void setPrettyPrint(boolean prettyPrint)
          Sets whether to pretty print or not.
 void setTypeAttributeName(XMLName typeAttributeName)
          Sets the type attribute name used for object type identification.
 void setUseCollectionsElement(boolean collections)
          Sets whether collections should have their own element wrapping the contents of the collection (true) or the contents should be directly under the bean's element (false).
 void setUseCollectionsElementWhenEmpty(boolean outputEmptyCollections)
          Sets whether a collection element should be output (true) if a collection has zero size and no attributes.
 void setUseIdrefAttributeOnRecursionOnly(boolean outputIDREF)
          Sets whether the idref attribute should be only be used to block recursion (true) or whenever the same bean is encountered (false) Default is to send whenever the bean is encountered twice (false).
 void setUseNullAttribute(boolean outputNulls)
          Sets whether nulls should be output (true) or ignored (false).
 void setUseTypeAttribute(boolean outputType)
          Sets whether the type attribute should be output (true) or not (false).
 void setUseTypeAttributeAlways(boolean outputTypeAlways)
          Sets whether the type attribute should be always be output (true) or only when required (false).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLMetaData

public XMLMetaData()
Constructor

Method Detail

getDefault

public static XMLMetaData getDefault()
Constructor


getKeyAttributeName

public XMLName getKeyAttributeName()
Gets the key attribute name used for Map keys.

Returns:
key name

setKeyAttributeName

public void setKeyAttributeName(XMLName keyAttributeName)
Sets the key attribute name used for Map keys.

Parameters:
keyAttributeName - The key name

getIDAttributeName

public XMLName getIDAttributeName()
Gets the id attribute name used for object identification.

Returns:
id name

setIDAttributeName

public void setIDAttributeName(XMLName idAttributeName)
Sets the id attribute name used for object identification.

Parameters:
idAttributeName - The id name

getIDREFAttributeName

public XMLName getIDREFAttributeName()
Gets the idref attribute name used for object identification.

Returns:
idref name

setIDREFAttributeName

public void setIDREFAttributeName(XMLName idrefAttributeName)
Sets the idref attribute name used for object identification.

Parameters:
idrefAttributeName - The idref name

getTypeAttributeName

public XMLName getTypeAttributeName()
Gets the type attribute name used for object type identification.

Returns:
type name

setTypeAttributeName

public void setTypeAttributeName(XMLName typeAttributeName)
Sets the type attribute name used for object type identification.

Parameters:
typeAttributeName - The type name

getNullAttributeName

public XMLName getNullAttributeName()
Gets the null attribute name used to indicate a null value.

Returns:
null name

setNullAttributeName

public void setNullAttributeName(XMLName nullAttributeName)
Sets the null attribute name used to indicate a null value.

Parameters:
nullAttributeName - The null name

getBasicTypeAsAttribute

public boolean getBasicTypeAsAttribute()
Gets whether basic types should be output as attributes (true) or elements (false). Default is to send as elements (false).

Returns:
true if outputting basic types as attributes

setBasicTypeAsAttribute

public void setBasicTypeAsAttribute(boolean basicTypeAsAttribute)
Sets whether basic types should be output as attributes (true) or elements (false). Default is to send as elements (false).

Parameters:
basicTypeAsAttribute - true to output basic types as attributes

getUseNullAttribute

public boolean getUseNullAttribute()
Gets whether nulls should be output (true) or ignored (false). If sent, the null attribute will be set to true. Default is to not send (false).

Returns:
Returns a boolean

setUseNullAttribute

public void setUseNullAttribute(boolean outputNulls)
Sets whether nulls should be output (true) or ignored (false). If sent, the null attribute will be set to true. Default is to not send (false).

Parameters:
outputNulls - true to output nulls, false to ignore

getUseTypeAttribute

public boolean getUseTypeAttribute()
Gets whether the type attribute should be output (true) or not (false). Default is to use it (true).

Returns:
Returns a boolean

setUseTypeAttribute

public void setUseTypeAttribute(boolean outputType)
Sets whether the type attribute should be output (true) or not (false). Default is to use it (true).

Parameters:
outputType - true to output type attributes

getUseTypeAttributeAlways

public boolean getUseTypeAttributeAlways()
Gets whether the type attribute should be always be output (true) or only when required (false). Default is to send only when required (false).

Returns:
Returns a boolean

setUseTypeAttributeAlways

public void setUseTypeAttributeAlways(boolean outputTypeAlways)
Sets whether the type attribute should be always be output (true) or only when required (false). Default is to send only when required (false).

Parameters:
outputTypeAlways - true to output type always, false to only send when required

getUseIdrefAttributeOnRecursionOnly

public boolean getUseIdrefAttributeOnRecursionOnly()
Gets whether the idref attribute should be only be used to block recursion (true) or whenever the same bean is encountered (false) Default is to send whenever the bean is encountered twice (false).

Returns:
Returns a boolean

setUseIdrefAttributeOnRecursionOnly

public void setUseIdrefAttributeOnRecursionOnly(boolean outputIDREF)
Sets whether the idref attribute should be only be used to block recursion (true) or whenever the same bean is encountered (false) Default is to send whenever the bean is encountered twice (false).


getUseCollectionsElement

public boolean getUseCollectionsElement()
Gets whether collections should have their own element wrapping the contents of the collection (true) or the contents should be directly under the bean's element (false). The default is false.

Returns:
true if an extra element exists

setUseCollectionsElement

public void setUseCollectionsElement(boolean collections)
Sets whether collections should have their own element wrapping the contents of the collection (true) or the contents should be directly under the bean's element (false). The default is false.


getUseCollectionsElementWhenEmpty

public boolean getUseCollectionsElementWhenEmpty()
Gets whether a collection element should be output (true) if a collection has zero size and no attributes. This is only relevant if UseCollectionElement is true. Default is to not send (false).

Returns:
Returns a boolean

setUseCollectionsElementWhenEmpty

public void setUseCollectionsElementWhenEmpty(boolean outputEmptyCollections)
Sets whether a collection element should be output (true) if a collection has zero size and no attributes. This is only relevant if UseCollectionElement is true. Default is to not send (false).

Parameters:
outputEmptyCollections - true to output empty collections, false to ignore

getPrettyPrint

public boolean getPrettyPrint()
Gets whether to pretty print or not. Default is not.

Returns:
pretty print flag

setPrettyPrint

public void setPrettyPrint(boolean prettyPrint)
Sets whether to pretty print or not. Default is not.

Parameters:
prettyPrint - pretty print flag

addXMLConvertor

public void addXMLConvertor(XMLConvertor convertor)
Add an xml convertor used to convert to and from xml at the end of the list of convertors.

Parameters:
convertor - the convertor

insertXMLConvertor

public void insertXMLConvertor(XMLConvertor convertor)
Add an xml convertor used to convert to and from xml at the start of the list of convertors.

Parameters:
convertor - the convertor

getXMLConvertorList

public java.util.List getXMLConvertorList()
Get the list of xml convertors used to convert to and from xml.

Returns:
the list of convertors

addXMLFilter

public void addXMLFilter(XMLFilter filter)
Add an xml convertor used to convert to and from xml at the end of the list of convertors.


insertXMLFilter

public void insertXMLFilter(XMLFilter filter)
Add an xml convertor used to convert to and from xml at the start of the list of convertors.


getXMLFilterList

public java.util.List getXMLFilterList()
Get the list of xml convertors used to convert to and from xml.

Returns:
the list of convertors

Joda System API

Copyright © 2001-2003 Stephen Colebourne. All Rights Reserved.