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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringString constant representing an adjective or adverb.static final StringString constant representing an animal.static final StringString constant representing a color.static final StringString constant representing conditional form.static final StringString constant representing a n expression dynamically defined at runtime.static final StringString constant representing a fluid.static final StringString constant representing food.static final StringString constant representing gerund form.static final StringString constant representing an expression which is to be ignored.static final StringString constant representing a person's name.static final StringString constant representing negated form.static final StringString constant representing a numeral.static final StringString constant representing an object (syntax).static final StringString constant representing an obsessional word.static final StringString constant representing plural form.static final StringString constant representing a preposition.static final StringString constant representing pronoun.static final StringString constant representing a question word.static final StringString constant representing a subject.static final Stringstatic final StringString constant representing a suffix.static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringType string specifiers, which can be used in sentence matching.static final StringString constant representing a type less expression.static final StringString constant representing verb form.static final 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:
-
GERUND
String constant representing gerund form.- See Also:
-
CONDITIONAL
String constant representing conditional form.- See Also:
-
NEGATED
String constant representing negated form.- See Also:
-
PRONOUN
String constant representing pronoun.- See Also:
-
OBJECT
String constant representing an object (syntax).- See Also:
-
FLUID
String constant representing a fluid.- See Also:
-
FOOD
String constant representing food.- See Also:
-
OBSESSIONAL
String constant representing an obsessional word.- See Also:
-
SUBJECT
String constant representing a subject.- See Also:
-
ANIMAL
String constant representing an animal.- See Also:
-
NAME
String constant representing a person's name.- See Also:
-
ADJECTIVE
String constant representing an adjective or adverb.- See Also:
-
COLOR
String constant representing a color.- See Also:
-
NUMERAL
String constant representing a numeral.- See Also:
-
PREPOSITION
String constant representing a preposition.- See Also:
-
QUESTION
String constant representing a question word.- See Also:
-
IGNORE
String constant representing an expression which is to be ignored.- See Also:
-
SUFFIX
String constant representing a suffix.- See Also:
-
PLURAL
String constant representing plural form.- See Also:
-
DYNAMIC
String constant representing a n expression dynamically defined at runtime.- See Also:
-
UNKNOWN
String constant representing a type less expression.- See Also:
-
SUFFIX_GERUND
- See Also:
-
SUFFIX_COLOR
- See Also:
-
SUFFIX_CONDITIONAL
- See Also:
-
SUFFIX_NEGATED
- See Also:
-
SUFFIX_PRONOUN
- See Also:
-
SUFFIX_FOOD
- See Also:
-
SUFFIX_OBSESSIONAL
- See Also:
-
SUFFIX_FLUID
- See Also:
-
SUFFIX_ANIMAL
- See Also:
-
SUFFIX_NAME
- See Also:
-
SUBJECT_NAME
- See Also:
-
SUFFIX_PLURAL
- See Also:
-
SUFFIX_QUESTION
- See Also:
-
VERB_GERUND
- See Also:
-
SUFFIX_DYNAMIC
- See Also:
-
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
-