Class CounterModel

java.lang.Object
com.highdeal.pnr.hci.CounterModel
All Implemented Interfaces:
XMLMarshallable

public class CounterModel extends Object implements XMLMarshallable
This class represents a counter in a business relationship. A counter has a name and a current value.

XML API for HCI

The XML APIs specify the following XSD fragment:

XSD Fragment

<xs:element name="counter" type="CounterModelObjectType" />
   <xs:complexType name="CounterModelObjectType">
     <xs:attribute name="name" type="xs:string" use="required"/>
     <xs:attribute name="value" type="xs:decimal"/>
     <xs:attribute name="operation" type="CounterOperationType" use="optional" />
   </xs:complexType>

  • Field Details

    • TAG_NAME

      public static final String TAG_NAME
      The value of that constant is the XML tag name of the CounterModel.
      See Also:
  • Constructor Details

    • CounterModel

      public CounterModel()
      Constructs an empty counter object.
    • CounterModel

      public CounterModel(String name)
      Constructs a counter object with a name.
      Parameters:
      name - the name of the counter.
    • CounterModel

      public CounterModel(String name, BigDecimal value)
      Constructs a counter object with a name and a current value.
      Parameters:
      name - the name of the counter.
      value - the current value of the counter.
    • CounterModel

      public CounterModel(String name, BigDecimal value, DistributedCounterOperationType operationType)
      Constructs a counter object with a name, a current value and the smartMeter flag.
      Parameters:
      name - the name of the counter.
      value - the current value of the counter.
      operationType - type of distributed counters: increment or decrement, null for persistent counters
    • CounterModel

      public CounterModel(CounterDescriptionModel counterDesc)
      Constructs a counter object from a Counter description object
      Parameters:
      counterDesc - the Counter description object used as base for the construction of the Counter object.
  • Method Details

    • getName

      public String getName()
      Returns the name of the counter.
      Returns:
      the name of the counter.
    • setName

      public void setName(String name)
      Sets the name of the counter.
      Parameters:
      name - the name of the counter.
    • getValue

      public BigDecimal getValue()
      Returns the value of the counter.
      Returns:
      the value of the counter.
    • setValue

      public void setValue(BigDecimal value)
      Sets the value of the counter.
      Parameters:
      value - the value of the counter.
    • getOperationType

      public DistributedCounterOperationType getOperationType()
      Gets the type of distributed counter: increment or decrement. Null for persistent counters.
      Returns:
      DistributedCounterOperationType the type of distributed counters: increment or decrement. Null for persistent counters.
    • setOperationType

      public void setOperationType(DistributedCounterOperationType distributedCounterOperationType)
      Sets the operation type of the distributed counter.
      Parameters:
      distributedCounterOperationType - DistributedCounterOperationType the type of distributed counters: increment or decrement. Null for persistent counters
    • isIncrementCounter

      public boolean isIncrementCounter()
      Returns true if the counter is shareable and is of type increment, false otherwise.
      Returns:
      true if the counter is shareable and is of type increment, false otherwise
    • checkValidity

      public boolean checkValidity()
      Returns true if the counter is valid. Counter is valid if its name is not null or empty and if its current value is set to a non null value.
      Returns:
      true if the counter is valid, false otherwise.
    • 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 name, 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:
      name - The name of tag for the child
      child - The child to be added
    • 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

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

      public void marshal(XMLOutputter output, String tagName)
    • toString

      public String toString()
      Overrides:
      toString in class Object