Enum Class ParserMessage

java.lang.Object
java.lang.Enum<ParserMessage>
org.springframework.shell.command.parser.ParserMessage
All Implemented Interfaces:
Serializable, Comparable<ParserMessage>, Constable

public enum ParserMessage extends Enum<ParserMessage>
Contains all the messages that can be produced during parsing. Each message has a kind (WARNING, ERROR) and a code number. Code is used to identify particular message and makes it easier to test what messages are produced. Code numbers are split so that ones within 1xxx are from lexer and 2xxx from parser. Messages with ERROR should be treated as terminating messages because those are most likely hard errors based on manual validation or exception thrown within lexing or parsing. Messages with WARNING can be ignored but can be used to provide info to user. For example parsing may detect some ambiguities with a command and option model related to what user tries to use as an input. This because there are limits how clever a parser can be as command model is beyond its control.
  • Enum Constant Details

    • ILLEGAL_CONTENT_BEFORE_COMMANDS

      public static final ParserMessage ILLEGAL_CONTENT_BEFORE_COMMANDS
    • MANDATORY_OPTION_MISSING

      public static final ParserMessage MANDATORY_OPTION_MISSING
    • UNRECOGNISED_OPTION

      public static final ParserMessage UNRECOGNISED_OPTION
    • ILLEGAL_OPTION_VALUE

      public static final ParserMessage ILLEGAL_OPTION_VALUE
    • NOT_ENOUGH_OPTION_ARGUMENTS

      public static final ParserMessage NOT_ENOUGH_OPTION_ARGUMENTS
    • TOO_MANY_OPTION_ARGUMENTS

      public static final ParserMessage TOO_MANY_OPTION_ARGUMENTS
  • Method Details

    • values

      public static ParserMessage[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static ParserMessage valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • getCode

      public int getCode()
    • getType

      public ParserMessage.Type getType()
    • formatMessage

      public String formatMessage(Object... inserts)
      Format message without code and position parts.
      Parameters:
      inserts - the inserts
      Returns:
      formatted message
    • formatMessage

      public String formatMessage(boolean useCode, int position, Object... inserts)
      Format message.

      For example code and position 2000E:(pos 0):

      Parameters:
      useCode - Add code part
      position - position info, not printed if negative
      inserts - the inserts
      Returns:
      formatted message