|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object wyvern.kernel.commands.PrepositionParser
This class splits a string into a direct object and an indirect object, splitting it on a passed preposition token. For example, if the string is "all from corpse", and your preposition is "from", it'll extract the "all" and "corpse" parts, which can be obtained by calling getDirectObject() and getIndirectObject().
Because many commands that use this class also need to check for quantity, the parser sets a flag if it finds a quantity specified for the direct object. If so, it saves the quantity and direct object separately. E.g. "get 20 coins from bag" will set the quantity to 20 and the direct object to "coins".
Constructor Summary | |
PrepositionParser()
|
Method Summary | |
boolean |
foundQuantity()
Returns true if there was a quantity specified. |
java.lang.String |
getDirectObject()
Returns the direct object from our sentence-parsing. |
java.lang.String |
getIndirectObject()
Returns the indirect object from our sentence-parsing. |
int |
getQuantity()
Returns the quantity specified. |
boolean |
parse(java.lang.String sentence,
java.lang.String preposition)
Split the passed string into direct & indirect objects. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public PrepositionParser()
Method Detail |
public boolean parse(java.lang.String sentence, java.lang.String preposition)
sentence
- the String to parsepreposition
- the token to split the sentence on
public java.lang.String getDirectObject()
public java.lang.String getIndirectObject()
public boolean foundQuantity()
public int getQuantity()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |