OpMath

com.opmath.util.dmldoc
Class ParseCounter

java.lang.Object
  |
  +--com.opmath.util.dmldoc.ParseCounter

class ParseCounter
extends Object

An object representing a general-purpose counter.

ParseCounter methods are strictly imited to those required by the SGML parser contained within com.opmath.util.dmldoc.DMLDoc.

The chief advantage of this class is that it provides a full object wrapper around an int. Thus, it is possible to pass a ParseCounter into a method as a formal argument, then obtain its updated value on return.

Copyright: (c) 2002 The Open Math Company Limited

The Terms of Distribution of this software are stipulated in the javadoc Overview for this project.

Since:
J2SE 1.3
Version:
utilities-v011
Author:
Bruno Beloff bruno.beloff@opmath.com
See Also:
DMLDoc

Field Summary
static int NEGATIVE
          Returned by value().
static int POSITIVE
          Returned by value().
static int ZERO
          Returned by value().
 
Constructor Summary
ParseCounter(int newVal)
          Constructs a new ParseCounter whose starting value is given by newVal.
 
Method Summary
 void dec()
          Decrements the value of this ParseCounter instance by 1.
 void inc()
          Increments the value of this ParseCounter instance by 1.
 boolean negative()
          Returns true iff the value of this ParseCounter instance is less than zero.
 boolean positive()
          Returns true iff the value of this ParseCounter instance is greater than zero.
 String toString()
          Returns a new String, detailing the contents of this ParseCounter instance.
 int value()
          Returns an int representing the state of the counter.
 boolean zero()
          Returns true iff the value of this ParseCounter instance is zero.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

POSITIVE

public static final int POSITIVE

Returned by value().

See Also:
value()
Since:
J2SE 1.3

ZERO

public static final int ZERO

Returned by value().

See Also:
value()
Since:
J2SE 1.3

NEGATIVE

public static final int NEGATIVE

Returned by value().

See Also:
value()
Since:
J2SE 1.3
Constructor Detail

ParseCounter

public ParseCounter(int newVal)

Constructs a new ParseCounter whose starting value is given by newVal.

Parameters:
newVal - the starting value for this ParseCounter.
Since:
J2SE 1.3
Method Detail

inc

public void inc()

Increments the value of this ParseCounter instance by 1.

Returns:
a new com.opmath.util.dmldoc.ParseCounter.
Since:
J2SE 1.3

dec

public void dec()

Decrements the value of this ParseCounter instance by 1.

Returns:
a new com.opmath.util.dmldoc.ParseCounter.
Since:
J2SE 1.3

zero

public boolean zero()

Returns true iff the value of this ParseCounter instance is zero.

Returns:
a boolean.
Since:
J2SE 1.3

positive

public boolean positive()

Returns true iff the value of this ParseCounter instance is greater than zero.

Returns:
a boolean.
Since:
J2SE 1.3

negative

public boolean negative()

Returns true iff the value of this ParseCounter instance is less than zero.

Returns:
a boolean.
Since:
J2SE 1.3

value

public int value()

Returns an int representing the state of the counter. Thus:

Returns:
an int.
Since:
J2SE 1.3

toString

public String toString()

Returns a new String, detailing the contents of this ParseCounter instance.

Overrides:
toString in class Object
Returns:
a String.
Since:
J2SE 1.3

OpMath

Submit a bug or feature to Open Math
Copyright © 2002 Open Math Company Limited, Brighton, UK