at.ac.tuwien.infosys.sm4all.copal.api.xml
Class ElementMarshaller<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.ElementMarshaller<T>
Type Parameters:
T - the type of marshaled value.
All Implemented Interfaces:
Marshaller<T>
Direct Known Subclasses:
ElementUnmarshaller

public class ElementMarshaller<T>
extends Base
implements Marshaller<T>

Marshals a child Element of a parent Element.

Author:
sanjin

Nested Class Summary
static class ElementMarshaller.Builder<T>
          Builder of ElementMarshaller.
 
Constructor Summary
ElementMarshaller(org.w3c.dom.Element parent, java.lang.String childName, MarshallerBuilder<T> builder, RemoveStrategy strategy)
          Creates instance of child Element Marshaller of specified parent Element.
 
Method Summary
 MarshallerBuilder<T> getBuilder()
          Returns the MarshallerBuilder to create a Marshaller for the child Element.
protected  org.w3c.dom.Element getChildElement()
          Returns the first child Element of the parent Element.
 java.lang.String getChildName()
          Returns the local name of the child Element.
 org.w3c.dom.Element getParent()
          Returns the parent Element.
 RemoveStrategy getStrategy()
          Returns the RemoveStrategy used to remove marshaled value.
 void marshal(T value)
          Marshals specified value into the child Element using a Marshaller created with the MarshallerBuilder.
 void remove()
          Removes the child Element.
 
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

ElementMarshaller

public ElementMarshaller(org.w3c.dom.Element parent,
                         java.lang.String childName,
                         MarshallerBuilder<T> builder,
                         RemoveStrategy strategy)
Creates instance of child Element Marshaller of specified parent Element. Child Element 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 the child Element and specified RemoveStrategy is used to remove marshaled value.

Parameters:
parent - the parent Element.
childName - the local name of the child Element.
builder - the MarshallerBuilder to create a Marshaller for the child Element.
strategy - the RemoveStrategy.
Throws:
java.lang.NullPointerException - if specified parent Element, name of child Element, MarshallerBuilder or RemoveStrategy is null.
java.lang.IllegalArgumentException - if specified name of child Element 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 Element.

Returns:
the local name of the child Element.

getBuilder

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

Returns:
the MarshallerBuilder to create a Marshaller for the child Element.

getStrategy

public RemoveStrategy getStrategy()
Returns the RemoveStrategy used to remove marshaled value.

Returns:
the RemoveStrategy used to remove marshaled value.

marshal

public void marshal(T value)
Marshals specified value into the child Element using a Marshaller created with the MarshallerBuilder. If child Element is missing in the parent Element, a new child Element will be created and appended.

Specified by:
marshal in interface Marshaller<T>
Parameters:
value - the value to be marshaled into the child Element.

remove

public void remove()
Removes the child Element.

Specified by:
remove in interface Marshaller<T>

getChildElement

protected org.w3c.dom.Element getChildElement()
                                       throws MissingFieldException
Returns the first child Element of the parent Element.

Returns:
first child Element.
Throws:
MissingFieldException - if there is no such child Element.


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