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

java.lang.Object
  extended by at.ac.tuwien.infosys.sm4all.copal.api.xml.OptionalAttributeUnmarshaller<T>
Type Parameters:
T - the class of unmarshaled value.
All Implemented Interfaces:
Unmarshaller<T>
Direct Known Subclasses:
Criteria, DefaultActionRequirement, Namespace, Priority, RootElement, TimeToLive

public abstract class OptionalAttributeUnmarshaller<T>
extends Object
implements Unmarshaller<T>

Command that unmarshalls an optional attribute from an Element.

Author:
sanjin

Constructor Summary
OptionalAttributeUnmarshaller(Element element, String attributeName)
          Creates instance of optional attribute unmarshaller which uses specified Element to unmarshal the optional attribute.
 
Method Summary
 T unmarshal()
          Returns the optional attribute of specified Element.
protected abstract  T valueOf(String value)
          Converts specified String value of the optional attribute to desired class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OptionalAttributeUnmarshaller

public OptionalAttributeUnmarshaller(Element element,
                                     String attributeName)
Creates instance of optional attribute unmarshaller which uses specified Element to unmarshal the optional attribute.

Parameters:
element - the Element used for unmarshalling.
attributeName - the name of optional attribute.
Throws:
NullPointerException - if specified Element or attribute name is null.
IllegalArgumentException - if specified attribute name is an empty or blank string.
Method Detail

unmarshal

public T unmarshal()
            throws ParsingException
Returns the optional attribute of specified Element.

Specified by:
unmarshal in interface Unmarshaller<T>
Returns:
the optional attribute of specified Element or null if the optional attribute is missing or is empty or blank string.
Throws:
InvalidFieldValueException - if specified value is not valid.
ParsingException

valueOf

protected abstract T valueOf(String value)
                      throws InvalidFieldValueException
Converts specified String value of the optional attribute to desired class.

Parameters:
value - the String value of the optional attribute.
Returns:
the optional attribute as instance of the desired class.
Throws:
InvalidFieldValueException - if specified value is not valid.


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