You are currently viewing a snapshot of www.mozilla.org taken on April 21, 2008. Most of this content is highly out of date (some pages haven't been updated since the project began in 1998) and exists for historical purposes only. If there are any pages on this archive site that you think should be added back to www.mozilla.org, please file a bug.



All Packages  This Package  Class Hierarchy  Class Search  Index

Class calypso.util.SignedInteger

java.lang.Object
   |
   +----calypso.util.SignedInteger

Utility class that represents the parse state from parsing a signed integer. The sign of the integer is maintained so that "10" can be distinguished from "+10". In addition, we can optionally handle numbers expressed as percentages.

See Also: Integer.parseInt


public class  SignedInteger
     extends java.lang.Object
{
          // Fields 6
     public static final int MINUS;
     public static final int NONE;
     public static final int PLUS;
     protected boolean fPct;
     protected int fSign;
     protected int fValue;

          // Constructors 2
     public SignedInteger(int, int);
     public SignedInteger(String, boolean) throws NumberFormatException;

          // Methods 5
     public int computeValue(int);
     public int getSign();
     public int intValue();
     public boolean isPct();
     public String toString();
}



Fields


PLUS

   public static final int PLUS


MINUS

   public static final int MINUS


NONE

   public static final int NONE


fValue

   protected int fValue


fSign

   protected int fSign


fPct

   protected boolean fPct



Constructors


SignedInteger

   public SignedInteger(String aString, 
                        boolean aAllowPct)  throws NumberFormatException

The integer part works (almost) the same as atoi():

  • Skip leading white spaces.
  • Non-digit char terminates convertion.
  • If got a valid integer, don't throw NumberFormatException.
  • Throw exception if first nonspace char is not digit(atoi returns 0). Example: " +4z" works as 4.



SignedInteger

   public SignedInteger(int aValue, 
                        int aSign) 



Methods


intValue

   public int intValue() 


isPct

   public boolean isPct() 


computeValue

   public int computeValue(int aBaseValue) 

Compute a value based on "aBaseValue". Apply the sign of this SignedInteger to determine the value to return.



getSign

   public int getSign() 

Return the sign of the value.



toString

   public String toString() 
Overrides:
toString in class Object


All Packages  This Package  Class Hierarchy  Class Search  Index
Freshly brewed Java API Documentation automatically generated with polardoc Version 1.0.4