Package com.highdeal.pnr.hci
Class CounterModel
java.lang.Object
com.highdeal.pnr.hci.CounterModel
- All Implemented Interfaces:
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 Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConstructs an empty counter object.CounterModel(CounterDescriptionModel counterDesc) Constructs a counter object from a Counter description objectCounterModel(String name) Constructs a counter object with a name.CounterModel(String name, BigDecimal value) Constructs a counter object with a name and a current value.CounterModel(String name, BigDecimal value, DistributedCounterOperationType operationType) Constructs a counter object with a name, a current value and the smartMeter flag. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCharacterData(String cData) Adds character data to the content element.voidaddChild(String name, XMLMarshallable child) Adds a child to the object, thechildrepresenting the marshallable object which must be added to the element.booleanReturns true if the counter is valid.getName()Returns the name of the counter.Gets the type of distributed counter: increment or decrement.getValue()Returns the value of the counter.booleanReturns true if the counter is shareable and is of type increment, false otherwise.voidmarshal(XMLOutputter output) Gives an XML representation of this object, including its children.voidmarshal(XMLOutputter output, String tagName) voidsetAttributes(XMLAttributes atts) Sets the attributes of the XML representation of the element being processed.voidSets the name of the counter.voidsetOperationType(DistributedCounterOperationType distributedCounterOperationType) Sets the operation type of the distributed counter.voidsetValue(BigDecimal value) Sets the value of the counter.toString()
-
Field Details
-
TAG_NAME
The value of that constant is the XML tag name of theCounterModel.- See Also:
-
-
Constructor Details
-
CounterModel
public CounterModel()Constructs an empty counter object. -
CounterModel
Constructs a counter object with a name.- Parameters:
name- the name of the counter.
-
CounterModel
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
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
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
Returns the name of the counter.- Returns:
- the name of the counter.
-
setName
Sets the name of the counter.- Parameters:
name- the name of the counter.
-
getValue
Returns the value of the counter.- Returns:
- the value of the counter.
-
setValue
Sets the value of the counter.- Parameters:
value- the value of the counter.
-
getOperationType
Gets the type of distributed counter: increment or decrement. Null for persistent counters.- Returns:
DistributedCounterOperationTypethe type of distributed counters: increment or decrement. Null for persistent counters.
-
setOperationType
Sets the operation type of the distributed counter.- Parameters:
distributedCounterOperationType-DistributedCounterOperationTypethe 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
Description copied from interface:XMLMarshallableSets the attributes of the XML representation of the element being processed.- Specified by:
setAttributesin interfaceXMLMarshallable- Parameters:
atts- TheXML attributesof the current element
-
addChild
Description copied from interface:XMLMarshallableAdds a child to the object, thechildrepresenting the marshallable object which must be added to the element.- Specified by:
addChildin interfaceXMLMarshallable- Parameters:
name- The name of tag for the childchild- The child to be added
-
addCharacterData
Description copied from interface:XMLMarshallableAdds character data to the content element.- Specified by:
addCharacterDatain interfaceXMLMarshallable- Parameters:
cData- The character data to be added
-
marshal
Description copied from interface:XMLMarshallableGives an XML representation of this object, including its children.- Specified by:
marshalin interfaceXMLMarshallable- Parameters:
output- TheXML outputto marshal the object into
-
marshal
-
toString
-