wyvern.kernel.commands
Class QuantityParser

java.lang.Object
  extended bywyvern.kernel.commands.QuantityParser

public class QuantityParser
extends java.lang.Object

This class takes an object description and checks to see if a quantity was specified. If so, it sets various flags.

Version:
1.0, Oct 31, 1998
Author:
Steve Yegge

Constructor Summary
QuantityParser(java.lang.String desc)
          Constructs a new QuantityParser
QuantityParser(java.lang.String[] desc)
          Constructs a new QuantityParser
 
Method Summary
 boolean foundQuantity()
          Returns true if a quantity was specified.
 java.lang.String getName()
          Returns the name of the object with the quantity specified stripped from the front.
 int getQuantity()
          Returns the quantity found.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QuantityParser

public QuantityParser(java.lang.String desc)
Constructs a new QuantityParser


QuantityParser

public QuantityParser(java.lang.String[] desc)
Constructs a new QuantityParser

Parameters:
desc - the object description, broken into a String array. If the first String in the array can be parsed by Integer.parseInt, we'll set the foundQuantity() flag.
Method Detail

foundQuantity

public boolean foundQuantity()
Returns true if a quantity was specified.

Returns:
true if the first token of the description was able to be parsed by Integer.parseInt().

getQuantity

public int getQuantity()
Returns the quantity found. Only valid if foundQuantity() returns true.

Returns:
the quantity specified by the first token in the object description.

getName

public java.lang.String getName()
Returns the name of the object with the quantity specified stripped from the front. If no quantity was specified, just returns the original string (or string array concatenated with spaces) passed to the constructor.