Class ExpressionType

java.lang.Object
games.stendhal.common.parser.ExpressionType
All Implemented Interfaces:
Serializable

public final class ExpressionType extends Object implements Serializable
An ExpressionType defines the type of an Expression object. It uses a human readable string representation like "VER" (verb) or "OBJ" (object). Derived types like negative verbs are written in a concatenated form like "VER-NEG". ExpressionType objects are immutable. To alter expression types, there is always created a new ExpressionType object (similar to the immutable Java String class).
Author:
Martin Fuchs
See Also:
Serialized Form
  • Field Details

  • Constructor Details

    • ExpressionType

      public ExpressionType(String s)
  • Method Details

    • getTypeString

      public String getTypeString()
      Returns:
      type string Note: There is no setTypeString to make ExpressionType objects immutable.
    • getMainType

      public String getMainType()
      Returns:
      main Expression type string (first 3 letters).
    • isEmpty

      public boolean isEmpty()
      Returns true if, and only if, length() is 0.
      Returns:
      true if length() is 0, otherwise false
    • isVerb

      public boolean isVerb()
      Determine if the Expression consists of verbs.
      Returns:
      true if the typeString starts with the verb-constant
    • isGerund

      public boolean isGerund()
      Determine if the Expression contains a verb in gerund form.
      Returns:
      true if so
    • isObject

      public boolean isObject()
      Determine if the Expression is an object. (a thing, not a person)
      Returns:
      false if not an object or null, true otherwise
    • isSubject

      public boolean isSubject()
      Determine if the Expression is an subject. (a thing, not a person)
      Returns:
      false if not a subject, true otherwise
    • isNumeral

      public boolean isNumeral()
      Determine if the Expression consists of numeral words.
      Returns:
      true if typeString start with 'NUM'; false otherwise.
    • isAdjective

      public boolean isAdjective()
      Determine if the Expression consists of adjectives or adverbs.
      Returns:
      true if typeString start with 'ADJ'; false otherwise.
    • isPreposition

      public boolean isPreposition()
      Determine if the Expression consists of prepositions.
      Returns:
      true if typeString start with 'PRE'; false otherwise.
    • isIgnore

      public boolean isIgnore()
      Determine Expressions to ignore.
      Returns:
      true if typeString start with 'IGN'; false otherwise.
    • isPlural

      public boolean isPlural()
      Determine if the Expression is in plural form.
      Returns:
      true if typeString contains '-PLU'; false otherwise.
    • isName

      public boolean isName()
      Determine if the Expression is a creature name.
      Returns:
      true if typeString contains '-NAM'; false otherwise.
    • isAnimal

      public boolean isAnimal()
      Determine if the Expression is an animal.
      Returns:
      true if typeString contains '-ANI'; false otherwise.
    • isFood

      public boolean isFood()
      Determine if the Expression is some food.
      Returns:
      true if typeString contains '-FOO'; false otherwise.
    • isFluid

      public boolean isFluid()
      Determine if the Expression is some fluid.
      Returns:
      true if typeString contains '-FLU'; false otherwise.
    • isQuestion

      public boolean isQuestion()
      Determine if the Expression consists of question words.
      Returns:
      true if typeString start with 'QUE'; false otherwise.
    • hasQuestion

      public boolean hasQuestion()
      Determine if the Expression is a or is merged with a question word.
      Returns:
      true if typeString contains 'QUE'; false otherwise.
    • isObsessional

      public boolean isObsessional()
      Determine if the Expression is a obsessional one.
      Returns:
      true if typeString contains '-OBS'; false otherwise.
    • hasColor

      public boolean hasColor()
      Determine if the Expression specifies a color.
      Returns:
      true if typeString contains 'COL'; false otherwise.
    • isPronoun

      public boolean isPronoun()
      Determine if the Expression is a pronoun.
      Returns:
      true if typeString contains '-PRO'; false otherwise.
    • isConditional

      public boolean isConditional()
      Determine if the Expression is in conditional form.
      Returns:
      true if typeString contains '-CON'; false otherwise.
    • isNegated

      public boolean isNegated()
      Determine if the Expression is negated.
      Returns:
      true if typeString contains '-NEG'; false otherwise.
    • isDynamic

      public boolean isDynamic()
      Determine if the Expression contains a dynamically defined word.
      Returns:
      true if typeString contains '-DYN'; false otherwise.
    • isTypeString

      public static boolean isTypeString(String str)
      Check if the given String contains a type string specifier.
      Parameters:
      str -
      Returns:
      true if first letter is upper case and contains any of the predefined TYPESTRINGs
    • merge

      public ExpressionType merge(ExpressionType other)
      Merge with another ExpressionType.
      Parameters:
      other -
      Returns:
      new ExpressionType object or this
    • negate

      public ExpressionType negate()
      Negate the type. This are the two typical cases: VER -> VER-NEG VER-NEG -> VER
      Returns:
      negated expression
    • toString

      public String toString()
      Overrides:
      toString in class Object