Business components : Business components : Branch application components : Counter : Tasks
  
Tasks
See also
Defining counters from externalize file
Dynamic instantiating counters
Using Counters
Counter
Defining counters from externalize file
Counters are external objects that can be created by the toolkit using XML definition files, which are stored outside of the system. Counters created from external definitions through ElementFactory are static and you need to declare them at installation or configuration time. Besides using external definition files to create counters, you can also dynamically create counters during the runtime of the application.
Following is an example of a counter declaration in the XML file:
<com.ibm.btt.bc.counter.Counter id="counterTest"
incraseMaxLimit="10000" totalMaxLimit="100000"
increaseTimesMaxLimit="100">
</com.ibm.btt.bc.counter.Counter>
Each counter consists of a total field (called total), an increase field (called increase), and an increase times field (called totIncrs).
See also
Tasks
Dynamic instantiating counters
You must instantiate the counter before use. A counter that is based on the XML file is instantiated automatically when reading it from the file.
To instantiate a dynamic counter and its counter elements that are not defined in an XML file, you need to use the default counter constructor. Following is an example:
Counter counter = new Counter();
counter.setIncreaseMaxLimit(1000f);
counter.setTotalMaxLimit(10000f);
counter.setIncreaseTimesMaxLimit(100);
You can also initiate the same counter as previous through the following constructor:
Counter counter=new Counter(1000f,10000f,100);
See also
Tasks
Using Counters
The function of counter is to keep track of numeric values, every time you want to update a value through a counter you can invoke the following API:
counter.increase(float value);
This operation will add the increase value to total element of the counter, and plus one to increase time. Then you can check the current total value and increase times through the following two APIs:
counter.currentTotal(); //retrieve current total value.
counter.increaseTimes(); //retrieve increase times value.
See also
Tasks