Class DurationModel

java.lang.Object
com.highdeal.pnr.hci.DurationModel
All Implemented Interfaces:
IXMLMarshallable, XMLMarshallable

public class DurationModel extends Object implements IXMLMarshallable
This class represents the model of the duration.

A duration is composed by a quantity and a unit of time. The quantity can be zero or a positive or negative integer. By default the quantity is zero and the time unit is null.

XML API for HCI

The XML APIs specify the following XSD fragment:

XSD Fragment

<xs:simpleType name="TimeUnit">
   <xs:restriction base="xs:string">
      <xs:enumeration value="second"/>
      <xs:enumeration value="minute"/>
      <xs:enumeration value="hour"/>
      <xs:enumeration value="day"/>
      <xs:enumeration value="month"/>
      <xs:enumeration value="year"/>
   </xs:restriction>
 </xs:simpleType>
 <xs:complexType name="Duration">
     <xs:attribute name="quantity" type="xs:integer" use="required"/>
     <xs:attribute name="timeUnit" type="TimeUnit" use="required"/>
 </xs:complexType>

  • Constructor Details

    • DurationModel

      public DurationModel()
  • Method Details

    • getQuantity

      public int getQuantity()
      Returns the quantity of unit of time of this duration.
      Returns:
      zero, a positive or negative integer representing the number of unit of time of this duration.
    • setQuantity

      public void setQuantity(int quantity)
      Sets the quantity of time of time unit of this duration.
      Parameters:
      quantity - zero, a positive or negative integer whether the duration means after or before respectively.
    • getUnitOfTime

      public com.highdeal.util.UnitOfTime getUnitOfTime()
      Returns the unit of time of this duration.
      Returns:
      an item of the enumeration UnitOfTime if set, null otherwise.
      See Also:
    • setUnitOfTime

      public void setUnitOfTime(com.highdeal.util.UnitOfTime timeUnit)
      Sets the unit of time of this duration.
      Parameters:
      timeUnit - an item of the enumeration UnitOfTime, null is accepted but this duration will not be well formed.
      See Also:
    • isWellFormed

      public boolean isWellFormed()
      Check whether this duration is well formed or not.

      Returns:
      true if this duration has a UnitOfTime, false otherwise.
    • getAuthorizedUnitOfTime

      public static com.highdeal.util.UnitOfTime[] getAuthorizedUnitOfTime()
      Gets the list of authorized unit of time.
      Returns:
      the list of authorized unit of time.
    • setAttributes

      public void setAttributes(XMLAttributes atts)
      Description copied from interface: XMLMarshallable
      Sets the attributes of the XML representation of the element being processed.
      Specified by:
      setAttributes in interface XMLMarshallable
      Parameters:
      atts - The XML attributes of the current element
    • addChild

      public void addChild(String tagName, XMLMarshallable child)
      Description copied from interface: XMLMarshallable
      Adds a child to the object, the child representing the marshallable object which must be added to the element.
      Specified by:
      addChild in interface XMLMarshallable
      Parameters:
      tagName - The name of tag for the child
      child - The child to be added
    • marshalAttributes

      public void marshalAttributes(XMLOutputter output)
      Description copied from interface: IXMLMarshallable
      Gives an XML representation of the attributes of an object.
      Specified by:
      marshalAttributes in interface IXMLMarshallable
      Parameters:
      output - The XML output to marshal the object attributes into
    • marshalChildren

      public void marshalChildren(XMLOutputter output)
      Description copied from interface: IXMLMarshallable
      Gives an XML representation of the child objects of an object.
      Specified by:
      marshalChildren in interface IXMLMarshallable
      Parameters:
      output - The XML output to marshal the child objects into
    • addCharacterData

      public void addCharacterData(String cData)
      Description copied from interface: XMLMarshallable
      Adds character data to the content element.
      Specified by:
      addCharacterData in interface XMLMarshallable
      Parameters:
      cData - The character data to be added
    • marshal

      @Deprecated public void marshal(XMLOutputter output)
      Deprecated.
      Description copied from interface: XMLMarshallable
      Gives an XML representation of this object, including its children.
      Specified by:
      marshal in interface IXMLMarshallable
      Specified by:
      marshal in interface XMLMarshallable
      Parameters:
      output - The XML output to marshal the object into