jasp.webcom
Class Counters

java.lang.Object
  |
  +--jasp.webcom.Counters

public class Counters
extends java.lang.Object

The Counter component creates a Counters object that can create, store, increment, and retrieve any number of individual counters. A counter is a persistent value that contains an integer. You can manipulate a counter with the Get, Increment, Set, and Remove methods of the Counters object. Once you create the counter, it persists until you remove it. Counters do not automatically increment on an event like a page hit. You must manually set or increment counters using the Set and Increment methods. Counters are not limited in scope. Once you create a counter, any page on your site can retrieve or manipulate its value. For example, if you increment and display a counter named hits in a page called Page1.asp, and you increment hits in another page called Page2.asp, both pages will increment the same counter. If you hit Page1.asp, and increment hits to 34, hitting Page2.asp will increment hits to 35. The next time you hit Page1.asp, hits will increment to 36


Constructor Summary
Counters()
          Creates a Counters object that can create, store, increment, and retrieve any number of individual counters
 
Method Summary
 int Get(java.lang.String countername)
          Takes the name of a counter and returns the current value of the counter.
 java.lang.String Increment(java.lang.String countername)
          Increases the counter by 1.
 void Remove(java.lang.String countername)
          Removes the counter from the Counters.txt file.
 void Set(java.lang.String countername, int newvalue)
          Sets the value of the counter to a specific integer
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Counters

public Counters()
Creates a Counters object that can create, store, increment, and retrieve any number of individual counters
Method Detail

Set

public void Set(java.lang.String countername,
                int newvalue)
         throws java.lang.Exception
Sets the value of the counter to a specific integer
Parameters:
contername - A string containing the name of the counter
newvalue - The new integer value for CounterName.

Get

public int Get(java.lang.String countername)
        throws java.lang.Exception
Takes the name of a counter and returns the current value of the counter. If the counter doesn't exist, the method creates it and sets it to 0.
Parameters:
contername - A string containing the name of the counter
Returns:
the value of the counter.

Remove

public void Remove(java.lang.String countername)
            throws java.lang.Exception
Removes the counter from the Counters.txt file.
Parameters:
countername - A string containing the name of the counter.

Increment

public java.lang.String Increment(java.lang.String countername)
                           throws java.lang.Exception
Increases the counter by 1.
Parameters:
countername - A string containing the name of the counter.
Returns:
the counter's new value. If the counter doesn't exist, the method creates it and sets its value to 1