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
Modifier and TypeFieldDescriptionstatic String
String constant representing an adjective or adverb.static String
String constant representing an animal.static String
String constant representing a color.static String
String constant representing conditional form.static String
String constant representing a n expression dynamically defined at runtime.static String
String constant representing a fluid.static String
String constant representing food.static String
String constant representing gerund form.static String
String constant representing an expression which is to be ignored.static String
String constant representing a person's name.static String
String constant representing negated form.static String
String constant representing a numeral.static String
String constant representing an object (syntax).static String
String constant representing an obsessional word.static String
String constant representing plural form.static String
String constant representing a preposition.static String
String constant representing pronoun.static String
String constant representing a question word.static String
String constant representing a subject.static String
static String
String constant representing a suffix.static String
static String
static String
static String
static String
static String
static String
static String
static String
static String
static String
static String
static String
Type string specifiers, which can be used in sentence matching.static String
String constant representing a type less expression.static String
String constant representing verb form.static String
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
hasColor()
Determine if the Expression specifies a color.boolean
Determine if the Expression is a or is merged with a question word.boolean
Determine if the Expression consists of adjectives or adverbs.boolean
isAnimal()
Determine if the Expression is an animal.boolean
Determine if the Expression is in conditional form.boolean
Determine if the Expression contains a dynamically defined word.boolean
isEmpty()
Returns true if, and only if, length() is 0.boolean
isFluid()
Determine if the Expression is some fluid.boolean
isFood()
Determine if the Expression is some food.boolean
isGerund()
Determine if the Expression contains a verb in gerund form.boolean
isIgnore()
Determine Expressions to ignore.boolean
isName()
Determine if the Expression is a creature name.boolean
Determine if the Expression is negated.boolean
Determine if the Expression consists of numeral words.boolean
isObject()
Determine if the Expression is an object.boolean
Determine if the Expression is a obsessional one.boolean
isPlural()
Determine if the Expression is in plural form.boolean
Determine if the Expression consists of prepositions.boolean
Determine if the Expression is a pronoun.boolean
Determine if the Expression consists of question words.boolean
Determine if the Expression is an subject.static boolean
isTypeString(String str)
Check if the given String contains a type string specifier.boolean
isVerb()
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
-