Class XmlFactoryFromAttribute<T>

java.lang.Object
xml.factories.attribute.XmlFactoryFromAttribute<T>
Direct Known Subclasses:
XmlColourFactory, XmlDoubleFactory, XmlFactorsFactory, XmlIntegerFactory, XmlResolutionFactory, XmlTripleFactory

public abstract class XmlFactoryFromAttribute<T>
extends java.lang.Object
This interface represents a class which constructs an object of type T from an XML attribute string.
  • Constructor Summary

    Constructors
    Constructor Description
    XmlFactoryFromAttribute()  
  • Method Summary

    Modifier and Type Method Description
    protected abstract T create​(java.lang.String attribute)
    Create an instance of type T from the given attribute string.
    T create​(org.w3c.dom.Element element, java.lang.String attrName)
    Get and create an object from an XML attribute, if it exists, otherwise throw an XmlParserException.
    T create​(org.w3c.dom.Element element, java.lang.String attrName, T defaultValue)
    Get and create an object from an XML attribute, if it exists, otherwise return the default value.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • XmlFactoryFromAttribute

      public XmlFactoryFromAttribute()
  • Method Details

    • create

      protected abstract T create​(java.lang.String attribute)
      Create an instance of type T from the given attribute string.
      Parameters:
      attribute - The XML attribute string from which to construct the T.
      Returns:
      An instance of type T whose value is the data in the given string.
      Throws:
      XmlParserException - if the attribute was in the wrong format.
    • create

      public T create​(org.w3c.dom.Element element, java.lang.String attrName)
      Get and create an object from an XML attribute, if it exists, otherwise throw an XmlParserException.
      Parameters:
      element - The XML element containing the required attribute.
      attrName - The name of the attribute string.
      Returns:
      The object of type T created from the attribute string.
      Throws:
      XmlParserException - if the attribute was in the wrong format.
    • create

      public T create​(org.w3c.dom.Element element, java.lang.String attrName, T defaultValue)
      Get and create an object from an XML attribute, if it exists, otherwise return the default value.
      Parameters:
      element - The XML element containing the required attribute.
      attrName - The name of the attribute string.
      defaultValue - The default value to return if the attribute does not exist.
      Returns:
      The object of type T created from the attribute string.
      Throws:
      XmlParserException - if the attribute was in the wrong format.