roast
Class FixedPointArgType

java.lang.Object
  |
  +--roast.ArgType
        |
        +--roast.FixedPointArgType

public class FixedPointArgType
extends roast.ArgType

A FixedPointArgType determines whether a given string contains only digits and one decimal (optional). The number of digits before and after the decimal must be in given ranges.

State variables
leftMaxLength: maximum possible number of digits before the decimal rightMaxLength: maximum possible number of digits after the decimal


Constructor Summary
FixedPointArgType(int leftMaxLength0, int rightMaxLength0)
          Creates a new instance.
 
Method Summary
 boolean isValid(java.lang.String s)
          Determines whether s contains only digits and one decimal (optional) and that the number of digits before and after the decimal are in range.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FixedPointArgType

public FixedPointArgType(int leftMaxLength0,
                         int rightMaxLength0)
Creates a new instance.
Transitions
leftMaxLength = leftMaxLength0 rightMaxLength = rightMaxLength0
Method Detail

isValid

public boolean isValid(java.lang.String s)
Determines whether s contains only digits and one decimal (optional) and that the number of digits before and after the decimal are in range.
Output
Let
i = index of decimal in s || if no decimal i = s.length
s1 = s[0..i-1]
s2 = s[i+1..|s|] || if no decimal s = ""

i != s.length-1 && s1 is a string of numeric characters && |s1| in [1..leftMaxLength] && s2 is a string of numeric characters && |s2| in [0..rightMaxLength]