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

java.lang.Object
  extended by at.ac.tuwien.infosys.sm4all.copal.api.xml.Optional<T>
Type Parameters:
T - the type of unmarshaled and marshaled value.
All Implemented Interfaces:
Marshaller<T>, Unmarshaller<T>

public class Optional<T>
extends java.lang.Object
implements Unmarshaller<T>

Unmarshals and marshals an optional value from/to an Element.

Author:
sanjin

Constructor Summary
Optional(Attribute<T> attribute)
          Creates instance of optional value Unmarshaller from specified Attribute.
 
Method Summary
 void marshal(T value)
          Marshals specified value into the attribute in the Element.
 void remove()
          Removes the attribute from the Element.
 T unmarshal()
          Unmarshals the attribute from the Element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Optional

public Optional(Attribute<T> attribute)
Creates instance of optional value Unmarshaller from specified Attribute.

Parameters:
attribute - the Attribute.
Throws:
java.lang.NullPointerException - if specified Attribute is null.
Method Detail

unmarshal

public T unmarshal()
            throws InvalidFieldValueException
Unmarshals the attribute from the Element. If attribute is missing then the null is returned.

Specified by:
unmarshal in interface Unmarshaller<T>
Returns:
the unmarshaled attribute or null if attribute is missing.
Throws:
InvalidFieldValueException - if the attribute is empty or blank string or invalid value.

marshal

public void marshal(T value)
Marshals specified value into the attribute in the Element. If specified value is null then attribute is removed from the Element.

Specified by:
marshal in interface Marshaller<T>
Parameters:
value - the value of the attribute.

remove

public void remove()
Removes the attribute from the Element.

Specified by:
remove in interface Marshaller<T>


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