Class CommandParser.Command

java.lang.Object
edu.uky.cs.nil.tt.CommandParser.Command
Enclosing class:
CommandParser

public static class CommandParser.Command extends Object
A command is a type of operation that can be parsed by a command parser and executed on a server.
Author:
Stephen G. Ware
  • Field Details

    • format

      public final String format
      A human-readable description of the command's format
    • pattern

      public final Pattern pattern
      A regular expression used to detect if this command is being invoked
    • operation

      public final CommandParser.Operation operation
      The operation to execute if this command is parsed
  • Constructor Details

    • Command

      public Command(String format, Pattern pattern, CommandParser.Operation operation)
      Constructs a new command from a description, regular expression, and operation to be executed when the command is parsed.
      Parameters:
      format - a human-readable description of the command's format
      pattern - a regular expression used to detect if the command is being invoked
      operation - the operation to execute when this command is parsed
    • Command

      public Command(String[] words, CommandParser.Operation operation)
      Constructs a new command (including its human-readable description and its regular expression) from a sequence of keywords.
      Parameters:
      words - a sequence of key words used to invoke the command
      operation - the operation to execute when this command is parsed