Class CounterDescriptionModel

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

public class CounterDescriptionModel extends Object implements XMLMarshallable
This class represents a counter description. A counter description has a name, an initial value and a mapping.

XML API for HCI

The XML APIs specify the following XSD fragment:

XSD Fragment

<xs:simpleType name="CounterOperationType">
   <xs:restriction base="xs:string">
      <xs:enumeration value="increment"/>
      <xs:enumeration value="decrement"/>
   </xs:restriction>
 </xs:simpleType>
 <xs:element name="counterDescription">
   <xs:complexType>
     <xs:attribute name="name" type="xs:string" use="required"/>
     <xs:attribute name="description" type="xs:string"/>
     <xs:attribute name="initialValue" type="xs:decimal"/>
     <xs:attribute name="counterName" type="xs:string"/>
     <xs:attribute name="isTransient" type="xs:boolean" use="optional" default="false"/>
     <xs:attribute name="operation" type="CounterOperationType" use="optional" />
   </xs:complexType>
 </xs:element>

  • Field Details

    • TAG_NAME

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

    • CounterDescriptionModel

      public CounterDescriptionModel()
      Constructs an empty counter model.
    • CounterDescriptionModel

      public CounterDescriptionModel(String name, String description, BigDecimal initialValue)
      Constructs a counter without the mapped counter name.
      Parameters:
      name - the name of the counter.
      description - the description of the counter.
      initialValue - the initial value of the counter.
    • CounterDescriptionModel

      public CounterDescriptionModel(String name, String description, BigDecimal initialValue, boolean isTransient)
      Constructs a counter without the mapped counter name.
      Parameters:
      name - the name of the counter.
      description - the description of the counter.
      initialValue - the initial value of the counter.
      isTransient - counter is transient if true, persistent otherwise
    • CounterDescriptionModel

      public CounterDescriptionModel(String name, String description, BigDecimal initialValue, boolean isTransient, DistributedCounterOperationType distributedCounterOperationType)
      Constructs a counter without the mapped counter name with distributedCounterOperationType.
      Parameters:
      name - the name of the counter.
      description - the description of the counter.
      initialValue - the initial value of the counter.
      isTransient - counter is transient if true, persistent otherwise
      distributedCounterOperationType - type of distributed counters: increment or decrement, null for persistent counters
    • CounterDescriptionModel

      public CounterDescriptionModel(String name, String description, BigDecimal initialValue, String counterName)
      Constructs a full counter.
      Parameters:
      name - the name of the counter.
      description - the description of the counter.
      initialValue - the initial value of the counter.
      counterName - the name of the mapped counter.
    • CounterDescriptionModel

      public CounterDescriptionModel(String name, String description, BigDecimal initialValue, String counterName, boolean isTransient, DistributedCounterOperationType distributedCounterOperationType)
      Constructs a full counter.
      Parameters:
      name - the name of the counter.
      description - the description of the counter.
      initialValue - the initial value of the counter.
      counterName - the name of the mapped counter.
      isTransient - counter is transient if true, persistent otherwise
      distributedCounterOperationType - type of distributed counters: increment or decrement, null for persistent counters
  • 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.
    • setDescription

      public void setDescription(String description)
      Sets the description of the counter.
      Parameters:
      description - the description of the counter.
      See Also:
    • getDescription

      public String getDescription()
      Returns the description of the counter.
      Returns:
      the counter description.
      See Also:
    • getInitialValue

      public BigDecimal getInitialValue()
      Returns the initial value of the counter.
      Returns:
      the initial value of the counter.
    • setInitialValue

      public void setInitialValue(BigDecimal initialValue)
      Sets the initial value of the counter.
      Parameters:
      initialValue - the initial value of the counter.
    • getCounterName

      public String getCounterName()
      Returns the mapped counter name.
      Returns:
      the name of the mapped counter.
    • setCounterName

      public void setCounterName(String counterName)
      Sets the mapped counter name.
      Parameters:
      counterName - the name of the mapped counter.
    • isTransient

      public boolean isTransient()
      Checks if counter is transient.
      Returns:
      true if counter is transient, false if counter is persistent
    • setTransient

      public void setTransient()
      Sets counter transient.
    • 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 operationType)
      Sets the operation type of the distributed counter.
      Parameters:
      operationType - 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.
    • validate

      public String validate(Vector<CounterDescriptionModel> sharedCounters, boolean link)
      Checks if this counter description is valid. A counter description that describes a counter is valid if:
      • its name is not empty or null,
      • its initial value is not null.
      A counter description that describes a mapped counter is valid if:
      • its name is not empty or null,
      • its mapped counter name is not null,
      • its mapped counter name is the name of a shared counter.
      Parameters:
      sharedCounters - a list of CounterDescriptionModel that represents the available shared counters.
      link - true if the counter described by this counter description maps a shared counters, false otherwise.
      Returns:
      null if the counter is valid, the string explanation 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