Javolution 6.0.0 java
javolution.xml.XMLFormat< T >.Default Class Reference
Inheritance diagram for javolution.xml.XMLFormat< T >.Default:
[legend]
Collaboration diagram for javolution.xml.XMLFormat< T >.Default:
[legend]

Public Member Functions

 Default ()
 
boolean isReferenceable ()
 
Object newInstance (Class<?> cls, javolution.xml.XMLFormat.InputElement xml) throws XMLStreamException
 
void read (XMLFormat.InputElement xml, Object obj) throws XMLStreamException
 
void write (Object obj, XMLFormat.OutputElement xml) throws XMLStreamException
 
newInstance (Class<? extends T > cls, InputElement xml) throws XMLStreamException
 
abstract void write (T obj, OutputElement xml) throws XMLStreamException
 
abstract void read (InputElement xml, T obj) throws XMLStreamException
 

Static Private Attributes

static final String NULL
 

Detailed Description

Returns the default XML format for any object having a plain text format; this XML representation consists of the plain text representation of the object as a "value" attribute.

Definition at line 986 of file XMLFormat.java.

Constructor & Destructor Documentation

◆ Default()

javolution.xml.XMLFormat< T >.Default.Default ( )

Default constructor.

Definition at line 991 of file XMLFormat.java.

991 {}

Member Function Documentation

◆ isReferenceable()

boolean javolution.xml.XMLFormat< T >.Default.isReferenceable ( )

Definition at line 994 of file XMLFormat.java.

994  {
995  return false; // Always by value (immutable).
996  }

◆ newInstance() [1/2]

T javolution.xml.XMLFormat< T >.newInstance ( Class<? extends T >  cls,
InputElement  xml 
) throws XMLStreamException
inherited

Allocates a new object of the specified class from the specified XML input element. By default, this method returns an object created using the public no-arg constructor of the specified class. XML formats may override this method in order to use private/multi-arg constructors.

Parameters
clsthe class of the object to return.
xmlthe XML input element.
Returns
the object corresponding to the specified XML element.

Definition at line 152 of file XMLFormat.java.

153  {
154  try {
155  return cls.newInstance();
156  } catch (InstantiationException e) {
157  throw new XMLStreamException(e);
158  } catch (IllegalAccessException e) {
159  throw new XMLStreamException(e);
160  }
161  }

◆ newInstance() [2/2]

Object javolution.xml.XMLFormat< T >.Default.newInstance ( Class<?>  cls,
javolution.xml.XMLFormat.InputElement  xml 
) throws XMLStreamException

Definition at line 999 of file XMLFormat.java.

1001  {
1002  TextFormat<?> format = TextContext.getFormat(cls);
1003  if (format == null)
1004  throw new XMLStreamException(
1005  "No TextFormat defined to parse instances of " + cls);
1006  CharArray value = xml.getAttribute("value");
1007  if (value == null)
1008  throw new XMLStreamException(
1009  "Missing value attribute (to be able to parse the instance of "
1010  + cls + ")");
1011  return format.parse(value);
1012  }

References javolution.text.TextContext.getFormat(), and javolution.text.TextFormat< T >.parse().

Here is the call graph for this function:

◆ read() [1/2]

abstract void javolution.xml.XMLFormat< T >.read ( InputElement  xml,
obj 
) throws XMLStreamException
abstractinherited

Parses an XML input element into the specified object.

Parameters
xmlthe XML element to parse.
objthe object created through newInstance and to setup from the specified XML element.

◆ read() [2/2]

void javolution.xml.XMLFormat< T >.Default.read ( XMLFormat.InputElement  xml,
Object  obj 
) throws XMLStreamException

Definition at line 1014 of file XMLFormat.java.

1015  {
1016  // Do nothing.
1017  }

◆ write() [1/2]

void javolution.xml.XMLFormat< T >.Default.write ( Object  obj,
XMLFormat.OutputElement  xml 
) throws XMLStreamException

Definition at line 1020 of file XMLFormat.java.

1021  {
1022  TextBuilder tmp = new TextBuilder();
1023  TextFormat<?> tf = TextContext.getFormat(obj.getClass());
1024  ((TextFormat<Object>) tf).format(obj, tmp);
1025  xml.setAttribute("value", tmp);
1026  }

References javolution.text.TextContext.getFormat().

Here is the call graph for this function:

◆ write() [2/2]

abstract void javolution.xml.XMLFormat< T >.write ( obj,
OutputElement  xml 
) throws XMLStreamException
abstractinherited

Formats an object into the specified XML output element.

Parameters
objthe object to format.
xmlthe XMLElement destination.

Member Data Documentation

◆ NULL

final String javolution.xml.XMLFormat< T >.NULL
staticprivateinherited

Holds null representation.

Definition at line 121 of file XMLFormat.java.


The documentation for this class was generated from the following file:
javolution.text.TextFormat.parse
abstract T parse(CharSequence csq, Cursor cursor)
javolution.text.TextFormat.format
abstract Appendable format(T obj, Appendable dest)
javolution.text.TextFormat<?>