org.xith3d.utility.cmdline
Class SimpleCommandPattern

java.lang.Object
  extended by org.xith3d.utility.cmdline.SimpleCommandPattern
All Implemented Interfaces:
org.jagatoo.datatypes.NamedObject, CommandPatternInterface

public class SimpleCommandPattern
extends java.lang.Object
implements CommandPatternInterface, org.jagatoo.datatypes.NamedObject

A simple command pattern supporting commands like /jump {x:int} {z:int}.


Constructor Summary
SimpleCommandPattern(java.lang.String name, java.lang.String pattern)
           
 
Method Summary
 java.lang.String getKey()
          This is used to match against the first token in the command line.
 java.lang.String getName()
           
 CommandParameters getParameters(CommandLine line)
           
 boolean match(CommandLine line)
           
 void printNodes()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleCommandPattern

public SimpleCommandPattern(java.lang.String name,
                            java.lang.String pattern)
Method Detail

printNodes

public void printNodes()

match

public boolean match(CommandLine line)
Specified by:
match in interface CommandPatternInterface
Parameters:
line -
Returns:
true if the command line matches this pattern.

getParameters

public CommandParameters getParameters(CommandLine line)
Specified by:
getParameters in interface CommandPatternInterface
Parameters:
line -
Returns:
the parameters from a commandline once a match has been found. This will attempt to turn all the parameters into the correct type. if the parameters fail to convert then an exception will be thrown.

getKey

public java.lang.String getKey()
This is used to match against the first token in the command line. This is meant to be used to isolate those commands which start with same word like /loot or /info so that more powerful (and slower) match checks can take place.

Specified by:
getKey in interface CommandPatternInterface

getName

public java.lang.String getName()
Specified by:
getName in interface org.jagatoo.datatypes.NamedObject
Specified by:
getName in interface CommandPatternInterface