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

Public Member Functions

XMLStreamWriter getStreamWriter ()
 
void add (Object obj) throws XMLStreamException
 
void add (Object obj, String name) throws XMLStreamException
 
void add (Object obj, String localName, String uri) throws XMLStreamException
 
void addText (CharSequence text) throws XMLStreamException
 
void addText (String text) throws XMLStreamException
 
void setAttribute (String name, CharSequence value) throws XMLStreamException
 
void setAttribute (String name, String value) throws XMLStreamException
 
void setAttribute (String name, boolean value) throws XMLStreamException
 
void setAttribute (String name, char value) throws XMLStreamException
 
void setAttribute (String name, byte value) throws XMLStreamException
 
void setAttribute (String name, short value) throws XMLStreamException
 
void setAttribute (String name, int value) throws XMLStreamException
 
void setAttribute (String name, long value) throws XMLStreamException
 
void setAttribute (String name, float value) throws XMLStreamException
 
void setAttribute (String name, double value) throws XMLStreamException
 
void setAttribute (String name, Object value) throws XMLStreamException
 

Package Functions

 OutputElement ()
 
public< T > void add (T obj, String name, Class< T > cls) throws XMLStreamException
 
public< T > void add (T obj, String localName, String uri, Class< T > cls) throws XMLStreamException
 
void setBinding (XMLBinding xmlBinding)
 
void setReferenceResolver (XMLReferenceResolver xmlReferenceResolver)
 
void reset ()
 

Package Attributes

final XMLStreamWriterImpl _writer = new XMLStreamWriterImpl()
 

Private Member Functions

boolean writeReference (Object obj) throws XMLStreamException
 

Private Attributes

XMLBinding _binding
 
XMLReferenceResolver _referenceResolver
 
TextBuilder _tmpTextBuilder = new TextBuilder()
 

Detailed Description

This class represents an output XML element (marshalling).

Definition at line 622 of file XMLFormat.java.

Constructor & Destructor Documentation

◆ OutputElement()

javolution.xml.XMLFormat< T >.OutputElement.OutputElement ( )
package

Default constructor.

Definition at line 642 of file XMLFormat.java.

642  {
643  reset();
644  }

Member Function Documentation

◆ add() [1/5]

void javolution.xml.XMLFormat< T >.OutputElement.add ( Object  obj) throws XMLStreamException

Adds the specified object or null as an anonymous nested element of unknown type.

Parameters
objthe object added as nested element or null.

Definition at line 662 of file XMLFormat.java.

662  {
663  if (obj == null) {
665  return;
666  }
667 
668  // Writes start element.
669  Class<?> cls = obj.getClass();
670  _binding.writeClass(cls, _writer, false);
671 
672  // Checks if reference written.
673  XMLFormat<Object> xmlFormat = (XMLFormat<Object>) _binding
674  .getFormat(cls);
675  if (xmlFormat.isReferenceable() && writeReference(obj))
676  return;
677 
678  xmlFormat.write(obj, this);
680  }

References javolution.xml.XMLFormat< T >.isReferenceable(), javolution.xml.XMLFormat< T >.NULL, javolution.xml.XMLFormat< T >.write(), javolution.xml.XMLBinding.writeClass(), javolution.xml.internal.stream.XMLStreamWriterImpl.writeEmptyElement(), and javolution.xml.internal.stream.XMLStreamWriterImpl.writeEndElement().

Here is the call graph for this function:

◆ add() [2/5]

void javolution.xml.XMLFormat< T >.OutputElement.add ( Object  obj,
String  localName,
String  uri 
) throws XMLStreamException

Adds the specified object as a fully qualified nested element of unknown type (null objects are ignored). The nested XML element contains a class attribute identifying the object type.

Parameters
objthe object added as nested element or null.
localNamethe local name of the nested element.
urithe namespace URI of the nested element.

Definition at line 722 of file XMLFormat.java.

723  {
724  if (obj == null)
725  return;
726 
727  // Writes start element.
728  _writer.writeStartElement(uri, localName);
729 
730  // Writes class attribute.
731  Class<?> cls = obj.getClass();
732  _binding.writeClass(cls, _writer, true);
733 
734  // Checks if reference written.
735  XMLFormat<Object> xmlFormat = (XMLFormat<Object>) _binding
736  .getFormat(cls);
737  if (xmlFormat.isReferenceable() && writeReference(obj))
738  return;
739 
740  xmlFormat.write(obj, this);
742  }

References javolution.xml.XMLFormat< T >.isReferenceable(), javolution.xml.XMLFormat< T >.write(), javolution.xml.XMLBinding.writeClass(), javolution.xml.internal.stream.XMLStreamWriterImpl.writeEndElement(), and javolution.xml.internal.stream.XMLStreamWriterImpl.writeStartElement().

Here is the call graph for this function:

◆ add() [3/5]

void javolution.xml.XMLFormat< T >.OutputElement.add ( Object  obj,
String  name 
) throws XMLStreamException

Adds the specified object as a named nested element of unknown type (null objects are ignored). The nested XML element contains a class attribute identifying the object type.

Parameters
objthe object added as nested element or null.
namethe name of the nested element.

Definition at line 691 of file XMLFormat.java.

691  {
692  if (obj == null)
693  return;
694 
695  // Writes start element.
697 
698  // Writes class attribute.
699  Class<?> cls = obj.getClass();
700  _binding.writeClass(cls, _writer, true);
701 
702  // Checks if reference written.
703  XMLFormat<Object> xmlFormat = (XMLFormat<Object>) _binding
704  .getFormat(cls);
705  if (xmlFormat.isReferenceable() && writeReference(obj))
706  return;
707 
708  xmlFormat.write(obj, this);
710  }

References javolution.xml.XMLFormat< T >.isReferenceable(), javolution.xml.XMLFormat< T >.write(), javolution.xml.XMLBinding.writeClass(), javolution.xml.internal.stream.XMLStreamWriterImpl.writeEndElement(), and javolution.xml.internal.stream.XMLStreamWriterImpl.writeStartElement().

Here is the call graph for this function:

◆ add() [4/5]

public<T> void javolution.xml.XMLFormat< T >.OutputElement.add ( obj,
String  localName,
String  uri,
Class< T >  cls 
) throws XMLStreamException
package

Adds the specified object as a fully qualified nested element of specified actual type (null objects are ignored). The nested XML element does not contain any class attribute.

Parameters
objthe object added as nested element or null.
localNamethe local name of the nested element.
urithe namespace URI of the nested element.
clsthe class identifying the format of the specified object.

Definition at line 780 of file XMLFormat.java.

781  {
782  if (obj == null)
783  return;
784 
785  // Writes start element.
786  _writer.writeStartElement(uri, localName);
787 
788  // Checks if reference written.
789  XMLFormat<T> xmlFormat = (XMLFormat<T>) _binding.getFormat(cls);
790  if (xmlFormat.isReferenceable() && writeReference(obj))
791  return;
792 
793  xmlFormat.write(obj, this);
795  }

References javolution.xml.XMLBinding.getFormat(), javolution.xml.XMLFormat< T >.isReferenceable(), javolution.xml.XMLFormat< T >.write(), javolution.xml.internal.stream.XMLStreamWriterImpl.writeEndElement(), and javolution.xml.internal.stream.XMLStreamWriterImpl.writeStartElement().

Here is the call graph for this function:

◆ add() [5/5]

public<T> void javolution.xml.XMLFormat< T >.OutputElement.add ( obj,
String  name,
Class< T >  cls 
) throws XMLStreamException
package

Adds the specified object as a named nested element of specified
actual type (null objects are ignored). The nested XML element does not contain any class attribute.

Parameters
objthe object added as nested element or null.
namethe name of the nested element.
clsthe class identifying the format of the specified object.

Definition at line 753 of file XMLFormat.java.

754  {
755  if (obj == null)
756  return;
757 
758  // Writes start element.
760 
761  // Checks if reference written.
762  XMLFormat<T> xmlFormat = (XMLFormat<T>) _binding.getFormat(cls);
763  if (xmlFormat.isReferenceable() && writeReference(obj))
764  return;
765 
766  xmlFormat.write(obj, this);
768  }

References javolution.xml.XMLBinding.getFormat(), javolution.xml.XMLFormat< T >.isReferenceable(), javolution.xml.XMLFormat< T >.write(), javolution.xml.internal.stream.XMLStreamWriterImpl.writeEndElement(), and javolution.xml.internal.stream.XMLStreamWriterImpl.writeStartElement().

Here is the call graph for this function:

◆ addText() [1/2]

void javolution.xml.XMLFormat< T >.OutputElement.addText ( CharSequence  text) throws XMLStreamException

Adds the content of a text-only element (equivalent to getStreamWriter().writeCharacters(text)).

Parameters
textthe element text content or an empty sequence if none.

Definition at line 813 of file XMLFormat.java.

813  {
814  _writer.writeCharacters(text);
815  }

References javolution.xml.internal.stream.XMLStreamWriterImpl.writeCharacters().

Here is the call graph for this function:

◆ addText() [2/2]

void javolution.xml.XMLFormat< T >.OutputElement.addText ( String  text) throws XMLStreamException

Equivalent to addText(CharSequence) (for J2ME compatibility).

Parameters
textthe element text content or an empty sequence if none.

Definition at line 823 of file XMLFormat.java.

823  {
824  _writer.writeCharacters(text);
825  }

References javolution.xml.internal.stream.XMLStreamWriterImpl.writeCharacters().

Here is the call graph for this function:

◆ getStreamWriter()

XMLStreamWriter javolution.xml.XMLFormat< T >.OutputElement.getStreamWriter ( )

Returns the StAX-like stream writer (provides complete control over the marshalling process).

Returns
the stream writer.

Definition at line 652 of file XMLFormat.java.

652  {
653  return _writer;
654  }

◆ reset()

void javolution.xml.XMLFormat< T >.OutputElement.reset ( )
package

Definition at line 972 of file XMLFormat.java.

972  {
973  _binding = XMLBinding.DEFAULT;
974  _writer.reset();
977  _referenceResolver = null;
978  }

References javolution.xml.XMLBinding.DEFAULT, javolution.xml.internal.stream.XMLStreamWriterImpl.reset(), javolution.xml.internal.stream.XMLStreamWriterImpl.setAutomaticEmptyElements(), and javolution.xml.internal.stream.XMLStreamWriterImpl.setRepairingNamespaces().

Here is the call graph for this function:

◆ setAttribute() [1/11]

void javolution.xml.XMLFormat< T >.OutputElement.setAttribute ( String  name,
boolean  value 
) throws XMLStreamException

Sets the specified boolean attribute.

Parameters
namethe attribute name.
valuethe boolean value for the specified attribute.

Definition at line 861 of file XMLFormat.java.

862  {
863  setAttribute(name, _tmpTextBuilder.clear().append(value));
864  }

◆ setAttribute() [2/11]

void javolution.xml.XMLFormat< T >.OutputElement.setAttribute ( String  name,
byte  value 
) throws XMLStreamException

Sets the specified byte attribute.

Parameters
namethe attribute name.
valuethe byte value for the specified attribute.

Definition at line 886 of file XMLFormat.java.

887  {
888  setAttribute(name, _tmpTextBuilder.clear().append(value));
889  }

References javolution.text.TextBuilder.append(), and javolution.text.TextBuilder.clear().

Here is the call graph for this function:

◆ setAttribute() [3/11]

void javolution.xml.XMLFormat< T >.OutputElement.setAttribute ( String  name,
char  value 
) throws XMLStreamException

Sets the specified char attribute.

Parameters
namethe attribute name.
valuethe char value for the specified attribute.

Definition at line 874 of file XMLFormat.java.

875  {
876  setAttribute(name,
877  (TextBuilder) _tmpTextBuilder.clear().append(value));
878  }

References javolution.text.TextBuilder.append(), and javolution.text.TextBuilder.clear().

Here is the call graph for this function:

◆ setAttribute() [4/11]

void javolution.xml.XMLFormat< T >.OutputElement.setAttribute ( String  name,
CharSequence  value 
) throws XMLStreamException

Sets the specified CharSequence attribute (null values are ignored).

Parameters
namethe attribute name.
valuethe attribute value or null.

Definition at line 834 of file XMLFormat.java.

835  {
836  if (value == null)
837  return;
838  _writer.writeAttribute(name, value);
839  }

References javolution.xml.internal.stream.XMLStreamWriterImpl.writeAttribute().

Here is the call graph for this function:

◆ setAttribute() [5/11]

void javolution.xml.XMLFormat< T >.OutputElement.setAttribute ( String  name,
double  value 
) throws XMLStreamException

Sets the specified double attribute.

Parameters
namethe attribute name.
valuethe double value for the specified attribute.

Definition at line 941 of file XMLFormat.java.

942  {
943  setAttribute(name, _tmpTextBuilder.clear().append(value));
944  }

References javolution.text.TextBuilder.append(), and javolution.text.TextBuilder.clear().

Here is the call graph for this function:

◆ setAttribute() [6/11]

void javolution.xml.XMLFormat< T >.OutputElement.setAttribute ( String  name,
float  value 
) throws XMLStreamException

Sets the specified float attribute.

Parameters
namethe attribute name.
valuethe float value for the specified attribute.

Definition at line 930 of file XMLFormat.java.

931  {
932  setAttribute(name, _tmpTextBuilder.clear().append(value));
933  }

References javolution.text.TextBuilder.append(), and javolution.text.TextBuilder.clear().

Here is the call graph for this function:

◆ setAttribute() [7/11]

void javolution.xml.XMLFormat< T >.OutputElement.setAttribute ( String  name,
int  value 
) throws XMLStreamException

Sets the specified int attribute.

Parameters
namethe attribute name.
valuethe int value for the specified attribute.

Definition at line 908 of file XMLFormat.java.

909  {
910  setAttribute(name, _tmpTextBuilder.clear().append(value));
911  }

References javolution.text.TextBuilder.append(), and javolution.text.TextBuilder.clear().

Here is the call graph for this function:

◆ setAttribute() [8/11]

void javolution.xml.XMLFormat< T >.OutputElement.setAttribute ( String  name,
long  value 
) throws XMLStreamException

Sets the specified long attribute.

Parameters
namethe attribute name.
valuethe long value for the specified attribute.

Definition at line 919 of file XMLFormat.java.

920  {
921  setAttribute(name, _tmpTextBuilder.clear().append(value));
922  }

References javolution.text.TextBuilder.append(), and javolution.text.TextBuilder.clear().

Here is the call graph for this function:

◆ setAttribute() [9/11]

void javolution.xml.XMLFormat< T >.OutputElement.setAttribute ( String  name,
Object  value 
) throws XMLStreamException

Sets the specified attribute using its associated TextFormat.

Parameters
namethe name of the attribute.
valuethe value for the specified attribute or null in which case the attribute is not set.

Definition at line 954 of file XMLFormat.java.

955  {
956  if (value == null)
957  return;
958  setAttribute(name, _tmpTextBuilder.clear().append(value.toString()));
959  }

References javolution.text.TextBuilder.append(), and javolution.text.TextBuilder.clear().

Here is the call graph for this function:

◆ setAttribute() [10/11]

void javolution.xml.XMLFormat< T >.OutputElement.setAttribute ( String  name,
short  value 
) throws XMLStreamException

Sets the specified short attribute.

Parameters
namethe attribute name.
valuethe short value for the specified attribute.

Definition at line 897 of file XMLFormat.java.

898  {
899  setAttribute(name, _tmpTextBuilder.clear().append(value));
900  }

References javolution.text.TextBuilder.append(), and javolution.text.TextBuilder.clear().

Here is the call graph for this function:

◆ setAttribute() [11/11]

void javolution.xml.XMLFormat< T >.OutputElement.setAttribute ( String  name,
String  value 
) throws XMLStreamException

Sets the specified String attribute (null values are ignored).

Parameters
namethe attribute name.
valuethe attribute value.

Definition at line 848 of file XMLFormat.java.

849  {
850  if (value == null)
851  return;
852  _writer.writeAttribute(name, value);
853  }

References javolution.xml.internal.stream.XMLStreamWriterImpl.writeAttribute().

Here is the call graph for this function:

◆ setBinding()

void javolution.xml.XMLFormat< T >.OutputElement.setBinding ( XMLBinding  xmlBinding)
package

Definition at line 962 of file XMLFormat.java.

962  {
963  _binding = xmlBinding;
964  }

◆ setReferenceResolver()

void javolution.xml.XMLFormat< T >.OutputElement.setReferenceResolver ( XMLReferenceResolver  xmlReferenceResolver)
package

Definition at line 967 of file XMLFormat.java.

967  {
968  _referenceResolver = xmlReferenceResolver;
969  }

◆ writeReference()

boolean javolution.xml.XMLFormat< T >.OutputElement.writeReference ( Object  obj) throws XMLStreamException
private

Definition at line 798 of file XMLFormat.java.

798  {
799  if ((_referenceResolver == null)
800  || !_referenceResolver.writeReference(obj, this))
801  return false;
803  return true; // Reference written.
804  }

References javolution.xml.internal.stream.XMLStreamWriterImpl.writeEndElement(), and javolution.xml.XMLReferenceResolver.writeReference().

Here is the call graph for this function:

Member Data Documentation

◆ _binding

XMLBinding javolution.xml.XMLFormat< T >.OutputElement._binding
private

Holds the XML binding.

Definition at line 632 of file XMLFormat.java.

◆ _referenceResolver

XMLReferenceResolver javolution.xml.XMLFormat< T >.OutputElement._referenceResolver
private

Holds the reference resolver.

Definition at line 637 of file XMLFormat.java.

◆ _tmpTextBuilder

TextBuilder javolution.xml.XMLFormat< T >.OutputElement._tmpTextBuilder = new TextBuilder()
private

Definition at line 866 of file XMLFormat.java.

◆ _writer

final XMLStreamWriterImpl javolution.xml.XMLFormat< T >.OutputElement._writer = new XMLStreamWriterImpl()
package

Holds the stream writer.

Definition at line 627 of file XMLFormat.java.


The documentation for this class was generated from the following file:
javolution.xml.internal.stream.XMLStreamWriterImpl.writeAttribute
void writeAttribute(CharSequence localName, CharSequence value)
Definition: XMLStreamWriterImpl.java:418
javolution.text.TextBuilder.append
final TextBuilder append(char c)
Definition: TextBuilder.java:202
javolution.xml.internal.stream.XMLStreamWriterImpl.writeEndElement
void writeEndElement()
Definition: XMLStreamWriterImpl.java:356
javolution.text.TextBuilder.clear
final TextBuilder clear()
Definition: TextBuilder.java:725
javolution.xml.internal.stream.XMLStreamWriterImpl.setRepairingNamespaces
void setRepairingNamespaces(boolean isRepairingNamespaces)
Definition: XMLStreamWriterImpl.java:220
javolution.xml.internal.stream.XMLStreamWriterImpl.writeStartElement
void writeStartElement(CharSequence localName)
Definition: XMLStreamWriterImpl.java:305
javolution.xml.XMLFormat.OutputElement.reset
void reset()
Definition: XMLFormat.java:972
javolution.xml.XMLFormat.OutputElement._writer
final XMLStreamWriterImpl _writer
Definition: XMLFormat.java:627
javolution.xml.internal.stream.XMLStreamWriterImpl.setAutomaticEmptyElements
void setAutomaticEmptyElements(boolean automaticEmptyElements)
Definition: XMLStreamWriterImpl.java:265
javolution.xml.XMLFormat.OutputElement.writeReference
boolean writeReference(Object obj)
Definition: XMLFormat.java:798
javolution.xml.XMLFormat.OutputElement.setAttribute
void setAttribute(String name, CharSequence value)
Definition: XMLFormat.java:834
javolution.xml.XMLFormat.OutputElement._referenceResolver
XMLReferenceResolver _referenceResolver
Definition: XMLFormat.java:637
javolution.xml.internal.stream.XMLStreamWriterImpl.reset
void reset()
Definition: XMLStreamWriterImpl.java:282
javolution.xml.XMLFormat.OutputElement._binding
XMLBinding _binding
Definition: XMLFormat.java:632
javolution.xml.internal.stream.XMLStreamWriterImpl.writeEmptyElement
void writeEmptyElement(CharSequence localName)
Definition: XMLStreamWriterImpl.java:335
javolution.xml.XMLBinding.getFormat
XMLFormat<?> getFormat(Class<?> forClass)
Definition: XMLBinding.java:179
javolution.xml.XMLFormat.OutputElement._tmpTextBuilder
TextBuilder _tmpTextBuilder
Definition: XMLFormat.java:866
javolution.xml.XMLFormat.NULL
static final String NULL
Definition: XMLFormat.java:121
javolution.xml.XMLReferenceResolver.writeReference
boolean writeReference(Object obj, XMLFormat.OutputElement xml)
Definition: XMLReferenceResolver.java:130
javolution.xml.XMLBinding.DEFAULT
static final XMLBinding DEFAULT
Definition: XMLBinding.java:105
javolution.xml.internal.stream.XMLStreamWriterImpl.writeCharacters
void writeCharacters(CharSequence text)
Definition: XMLStreamWriterImpl.java:574
javolution.xml.XMLBinding.writeClass
void writeClass(Class<?> cls, XMLStreamWriter writer, boolean useAttributes)
Definition: XMLBinding.java:264