Package com.highdeal.pnr.hci
Class CounterDescriptionModel
java.lang.Object
com.highdeal.pnr.hci.CounterDescriptionModel
- All Implemented Interfaces:
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 Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConstructs an empty counter model.CounterDescriptionModel(String name, String description, BigDecimal initialValue) Constructs a counter without the mapped counter name.CounterDescriptionModel(String name, String description, BigDecimal initialValue, boolean isTransient) Constructs a counter without the mapped counter name.CounterDescriptionModel(String name, String description, BigDecimal initialValue, boolean isTransient, DistributedCounterOperationType distributedCounterOperationType) Constructs a counter without the mapped counter name with distributedCounterOperationType.CounterDescriptionModel(String name, String description, BigDecimal initialValue, String counterName) Constructs a full counter.CounterDescriptionModel(String name, String description, BigDecimal initialValue, String counterName, boolean isTransient, DistributedCounterOperationType distributedCounterOperationType) Constructs a full counter. -
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.Returns the mapped counter name.Returns the description of the counter.Returns the initial value of the counter.getName()Returns the name of the counter.Gets the type of distributed counter: increment or decrement.booleanReturns true if the counter is shareable and is of type increment, false otherwise.booleanChecks if counter is transient.voidmarshal(XMLOutputter output) Gives an XML representation of this object, including its children.voidsetAttributes(XMLAttributes atts) Sets the attributes of the XML representation of the element being processed.voidsetCounterName(String counterName) Sets the mapped counter name.voidsetDescription(String description) Sets the description of the counter.voidsetInitialValue(BigDecimal initialValue) Sets the initial value of the counter.voidSets the name of the counter.voidsetOperationType(DistributedCounterOperationType operationType) Sets the operation type of the distributed counter.voidSets counter transient.validate(Vector<CounterDescriptionModel> sharedCounters, boolean link) Checks if this counter description is valid.
-
Field Details
-
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
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 otherwisedistributedCounterOperationType- 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 otherwisedistributedCounterOperationType- type of distributed counters: increment or decrement, null for persistent counters
-
-
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.
-
setDescription
Sets the description of the counter.- Parameters:
description- the description of the counter.- See Also:
-
getDescription
Returns the description of the counter.- Returns:
- the counter description.
- See Also:
-
getInitialValue
Returns the initial value of the counter.- Returns:
- the initial value of the counter.
-
setInitialValue
Sets the initial value of the counter.- Parameters:
initialValue- the initial value of the counter.
-
getCounterName
Returns the mapped counter name.- Returns:
- the name of the mapped counter.
-
setCounterName
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
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:
operationType-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.
-
validate
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.
- 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 ofCounterDescriptionModelthat 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
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
-