at.ac.tuwien.infosys.sm4all.copal.api.xml
Class ListMarshaller<T>

java.lang.Object
  extended by at.ac.tuwien.infosys.sm4all.copal.api.xml.Base
      extended by at.ac.tuwien.infosys.sm4all.copal.api.xml.ListMarshaller<T>
Type Parameters:
T - the type of marshaled List elements.
All Implemented Interfaces:
Marshaller<java.util.List<T>>
Direct Known Subclasses:
ListUnmarshaller

public class ListMarshaller<T>
extends Base
implements Marshaller<java.util.List<T>>

Marshals a List of values to an Element.

Author:
sanjin

Nested Class Summary
static class ListMarshaller.Builder<T>
          Builder of ListMarshaller.
 
Constructor Summary
ListMarshaller(org.w3c.dom.Element parent, java.lang.String childName, MarshallerBuilder<T> builder)
          Creates instance of List Marshaller that marshals each value from a List into a separate child Element of specified parent Element.
 
Method Summary
 MarshallerBuilder<T> getBuilder()
          Returns the MarshallerBuilder to create a Marshallers for the child Elements.
protected  org.w3c.dom.Element[] getChildElements()
          Returns all child Elements.
 java.lang.String getChildName()
          Returns the local name of the child Elements.
 org.w3c.dom.Element getParent()
          Returns the parent Element.
 void marshal(java.util.List<T> list)
          Marshals each value in specified List into a child Element using a Marshaller created with the MarshallerBuilder.
 void remove()
          Removes all child Elements.
 
Methods inherited from class at.ac.tuwien.infosys.sm4all.copal.api.xml.Base
createElement
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ListMarshaller

public ListMarshaller(org.w3c.dom.Element parent,
                      java.lang.String childName,
                      MarshallerBuilder<T> builder)
Creates instance of List Marshaller that marshals each value from a List into a separate child Element of specified parent Element. Child Elements will have specified local name and will be in Constants.COPAL_NAMESPACE. Specified MarshallerBuilder is used to create a Marshaller that will marshal a value into a child Element .

Parameters:
parent - the parent Element.
childName - the local name of child Elements.
builder - the MarshallerBuilder to create Marshaller s for child Elements.
Throws:
java.lang.NullPointerException - if specified parent Element, name of child Elements or MarshallerBuilder is null.
java.lang.IllegalArgumentException - if specified name of child Elements is an empty or blank string.
Method Detail

getParent

public org.w3c.dom.Element getParent()
Returns the parent Element.

Returns:
the parent Element.

getChildName

public java.lang.String getChildName()
Returns the local name of the child Elements.

Returns:
the local name of the child Elements.

getBuilder

public MarshallerBuilder<T> getBuilder()
Returns the MarshallerBuilder to create a Marshallers for the child Elements.

Returns:
the MarshallerBuilder to create a Marshallers for the child Elements.

marshal

public void marshal(java.util.List<T> list)
Marshals each value in specified List into a child Element using a Marshaller created with the MarshallerBuilder. Child Elements already in the parent Element are reused.

Specified by:
marshal in interface Marshaller<java.util.List<T>>
Parameters:
list - the List of values to be marshaled into the parent Element.
Throws:
java.lang.NullPointerException - if specified List is null.

remove

public void remove()
Removes all child Elements.

Specified by:
remove in interface Marshaller<java.util.List<T>>

getChildElements

protected org.w3c.dom.Element[] getChildElements()
Returns all child Elements.

Returns:
the child Elements.


Copyright © 2010 Distributed Systems Group, Vienna University of Technology. All Rights Reserved.