public abstract class GTIngredient
extends java.lang.Object
Red (tfeng) |
Yellow (tfeng) |
Modifier and Type | Class and Description |
---|---|
protected static class |
GTIngredient.FieldIterator
An iterator to read the fields one by one in a string that describes the
values of all the elements.
|
Modifier and Type | Field and Description |
---|---|
static char |
FIELD_SEPARATOR
The string to separate elements in a string that describes their values.
|
Modifier | Constructor and Description |
---|---|
protected |
GTIngredient(GTIngredientList owner,
int elementCount)
Construct a GTIngredient within the given list as its owner containing a
given number of elements.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
_decodeBooleanField(int index,
GTIngredient.FieldIterator iterator)
Decode a Boolean field and store the value into the index-th element.
|
protected java.lang.String |
_decodeStringField(int index,
GTIngredient.FieldIterator iterator)
Decode a string field and store the value into the index-th element.
|
protected void |
_encodeBooleanField(java.lang.StringBuffer buffer,
int index,
boolean value)
Encode a Boolean field with the given value using the enablement of the
index-th element, and append the encoded string to the end of the
buffer.
|
protected void |
_encodeStringField(java.lang.StringBuffer buffer,
int index,
java.lang.String value)
Encode a string field with the given value using the enablement of the
index-th element, and append the encoded string to the end of the
buffer.
|
protected static java.lang.String |
_escapeElementString(java.lang.String elementString)
Escape a string that describes the value of a single element, so that it
is enclosed in quotes and between the quotes, there are no quotes
(single or double) or backslashes.
|
protected static int |
_findMatchingParen(java.lang.String s,
int startPos)
Find the closing parenthesis that matches the the open parenthesis at
startPos position in string s.
|
protected static int |
_findSeparator(java.lang.String s,
int startPos,
char separator)
Find the separator character in string s starting from position
startPos.
|
protected static java.lang.String |
_unescapeElementString(java.lang.String elementString)
Unescape a string that has been escaped previously from an original
string that describes the value of a single element, and get back the
original string.
|
void |
disableAll()
Disable all elements.
|
void |
enableAll()
Enable all elements.
|
abstract GTIngredientElement[] |
getElements()
Get the array of elements defined in this GTIngredient.
|
GTIngredientList |
getOwner()
Get the list that contains this GTIngredient.
|
abstract java.lang.Object |
getValue(int index)
Get the value of the index-th elements.
|
abstract java.lang.String |
getValues()
Get a string that describes the values of all the elements.
|
boolean |
isApplicable(NamedObj object)
Check whether this GTIngredient is applicable to the object.
|
boolean |
isEnabled(int index)
Check whether the index-th element is enabled.
|
void |
setEnabled(int index,
boolean isEnabled)
Set the enablement of the index-th element.
|
abstract void |
setValue(int index,
java.lang.Object value)
Set the value of the index-th element.
|
abstract void |
setValues(java.lang.String values)
Set the values of all the elements with a string that describes them.
|
java.lang.String |
toString()
Return a readable string about this GTIngredient.
|
abstract void |
validate()
Validate the enablements and values of all the elements.
|
public static final char FIELD_SEPARATOR
protected GTIngredient(GTIngredientList owner, int elementCount)
owner
- The list as the owner of the constructed GTIngredientList.elementCount
- The number of elements that the GTIngredient has.public void disableAll()
public void enableAll()
public abstract GTIngredientElement[] getElements()
public GTIngredientList getOwner()
public abstract java.lang.Object getValue(int index)
index
- The index.setValue(int, Object)
public abstract java.lang.String getValues()
setValues(String)
public boolean isApplicable(NamedObj object)
object
- The object.public boolean isEnabled(int index)
index
- The index.setEnabled(int, boolean)
public void setEnabled(int index, boolean isEnabled)
index
- The index.isEnabled
- true if the element is set to be enabled; false if it
is disabled.isEnabled(int)
public abstract void setValue(int index, java.lang.Object value)
index
- The index.value
- The value.getValue(int)
public abstract void setValues(java.lang.String values)
values
- A string that describes the new values of all the
elements.getValues()
public java.lang.String toString()
toString
in class java.lang.Object
public abstract void validate() throws ValidationException
ValidationException
- If some elements are invalid.protected boolean _decodeBooleanField(int index, GTIngredient.FieldIterator iterator)
index
- The index.iterator
- The iterator used to iterate over all fields in a string
describing all the values.protected java.lang.String _decodeStringField(int index, GTIngredient.FieldIterator iterator)
index
- The index.iterator
- The iterator used to iterate over all fields in a string
describing all the values.protected void _encodeBooleanField(java.lang.StringBuffer buffer, int index, boolean value)
buffer
- The buffer.index
- The index.value
- The value to be encoded.protected void _encodeStringField(java.lang.StringBuffer buffer, int index, java.lang.String value)
buffer
- The buffer.index
- The index.value
- The value to be encoded.protected static java.lang.String _escapeElementString(java.lang.String elementString)
elementString
- The string to be escaped._unescapeElementString(String)
protected static int _findMatchingParen(java.lang.String s, int startPos)
s
- The string.startPos
- The position of the open parenthesis to be matched.protected static int _findSeparator(java.lang.String s, int startPos, char separator)
s
- The string.startPos
- The start position.separator
- The separator character.protected static java.lang.String _unescapeElementString(java.lang.String elementString)
elementString
- The string to be unescaped._escapeElementString(String)