Package games.stendhal.common.parser
Class ExpressionType
java.lang.Object
games.stendhal.common.parser.ExpressionType
- All Implemented Interfaces:
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 Summary
FieldsModifier and TypeFieldDescriptionstatic StringString constant representing an adjective or adverb.static StringString constant representing an animal.static StringString constant representing a color.static StringString constant representing conditional form.static StringString constant representing a n expression dynamically defined at runtime.static StringString constant representing a fluid.static StringString constant representing food.static StringString constant representing gerund form.static StringString constant representing an expression which is to be ignored.static StringString constant representing a person's name.static StringString constant representing negated form.static StringString constant representing a numeral.static StringString constant representing an object (syntax).static StringString constant representing an obsessional word.static StringString constant representing plural form.static StringString constant representing a preposition.static StringString constant representing pronoun.static StringString constant representing a question word.static StringString constant representing a subject.static Stringstatic StringString constant representing a suffix.static Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic StringType string specifiers, which can be used in sentence matching.static StringString constant representing a type less expression.static StringString constant representing verb form.static String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanhasColor()Determine if the Expression specifies a color.booleanDetermine if the Expression is a or is merged with a question word.booleanDetermine if the Expression consists of adjectives or adverbs.booleanisAnimal()Determine if the Expression is an animal.booleanDetermine if the Expression is in conditional form.booleanDetermine if the Expression contains a dynamically defined word.booleanisEmpty()Returns true if, and only if, length() is 0.booleanisFluid()Determine if the Expression is some fluid.booleanisFood()Determine if the Expression is some food.booleanisGerund()Determine if the Expression contains a verb in gerund form.booleanisIgnore()Determine Expressions to ignore.booleanisName()Determine if the Expression is a creature name.booleanDetermine if the Expression is negated.booleanDetermine if the Expression consists of numeral words.booleanisObject()Determine if the Expression is an object.booleanDetermine if the Expression is a obsessional one.booleanisPlural()Determine if the Expression is in plural form.booleanDetermine if the Expression consists of prepositions.booleanDetermine if the Expression is a pronoun.booleanDetermine if the Expression consists of question words.booleanDetermine if the Expression is an subject.static booleanisTypeString(String str)Check if the given String contains a type string specifier.booleanisVerb()Determine if the Expression consists of verbs.merge(ExpressionType other)Merge with another ExpressionType.negate()Negate the type.toString()
-
Field Details
-
VERB
String constant representing verb form.- See Also:
- Constant Field Values
-
GERUND
String constant representing gerund form.- See Also:
- Constant Field Values
-
CONDITIONAL
String constant representing conditional form.- See Also:
- Constant Field Values
-
NEGATED
String constant representing negated form.- See Also:
- Constant Field Values
-
PRONOUN
String constant representing pronoun.- See Also:
- Constant Field Values
-
OBJECT
String constant representing an object (syntax).- See Also:
- Constant Field Values
-
FLUID
String constant representing a fluid.- See Also:
- Constant Field Values
-
FOOD
String constant representing food.- See Also:
- Constant Field Values
-
OBSESSIONAL
String constant representing an obsessional word.- See Also:
- Constant Field Values
-
SUBJECT
String constant representing a subject.- See Also:
- Constant Field Values
-
ANIMAL
String constant representing an animal.- See Also:
- Constant Field Values
-
NAME
String constant representing a person's name.- See Also:
- Constant Field Values
-
ADJECTIVE
String constant representing an adjective or adverb.- See Also:
- Constant Field Values
-
COLOR
String constant representing a color.- See Also:
- Constant Field Values
-
NUMERAL
String constant representing a numeral.- See Also:
- Constant Field Values
-
PREPOSITION
String constant representing a preposition.- See Also:
- Constant Field Values
-
QUESTION
String constant representing a question word.- See Also:
- Constant Field Values
-
IGNORE
String constant representing an expression which is to be ignored.- See Also:
- Constant Field Values
-
SUFFIX
String constant representing a suffix.- See Also:
- Constant Field Values
-
PLURAL
String constant representing plural form.- See Also:
- Constant Field Values
-
DYNAMIC
String constant representing a n expression dynamically defined at runtime.- See Also:
- Constant Field Values
-
UNKNOWN
String constant representing a type less expression.- See Also:
- Constant Field Values
-
SUFFIX_GERUND
- See Also:
- Constant Field Values
-
SUFFIX_COLOR
- See Also:
- Constant Field Values
-
SUFFIX_CONDITIONAL
- See Also:
- Constant Field Values
-
SUFFIX_NEGATED
- See Also:
- Constant Field Values
-
SUFFIX_PRONOUN
- See Also:
- Constant Field Values
-
SUFFIX_FOOD
- See Also:
- Constant Field Values
-
SUFFIX_OBSESSIONAL
- See Also:
- Constant Field Values
-
SUFFIX_FLUID
- See Also:
- Constant Field Values
-
SUFFIX_ANIMAL
- See Also:
- Constant Field Values
-
SUFFIX_NAME
- See Also:
- Constant Field Values
-
SUBJECT_NAME
- See Also:
- Constant Field Values
-
SUFFIX_PLURAL
- See Also:
- Constant Field Values
-
SUFFIX_QUESTION
- See Also:
- Constant Field Values
-
VERB_GERUND
- See Also:
- Constant Field Values
-
SUFFIX_DYNAMIC
- See Also:
- Constant Field Values
-
TYPESTRINGS
Type string specifiers, which can be used in sentence matching.
-
-
Constructor Details
-
ExpressionType
-
-
Method Details
-
getTypeString
- Returns:
- type string Note: There is no setTypeString to make ExpressionType objects immutable.
-
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
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
Merge with another ExpressionType.- Parameters:
other-- Returns:
- new ExpressionType object or this
-
negate
Negate the type. This are the two typical cases: VER -> VER-NEG VER-NEG -> VER- Returns:
- negated expression
-
toString
-