public class SyntaxNode extends Object implements Serializable, TokenTranslator, SyntaxKeywords
Modifier and Type | Field and Description |
---|---|
static String |
ABBREV_DELIMITER |
static String |
RESOURCE_PREFIX |
static String |
VALUE_DELIMITER |
KW_ACTION_NAME, KW_CLASS, KW_CONSTRAINTS_PARSER, KW_CONSTRAINTS_TYPE, KW_DEFAULT, KW_DESCRIPTION, KW_EXTENDS, KW_FLOATING, KW_HELP_TEXT, KW_HELP_TOPICS, KW_NAME, KW_PACKAGE, KW_PARAMETER, KW_PARAMETER_PARSER, KW_PRIORITY, KW_PROPERTY, KW_RESOURCES, KW_SUPER, KW_SYNTAX, KW_USAGE, KW_VALUE, KW_VALUE_TYPE, MAX_OCCURRENCES, MIN_OCCURRENCES, OPTIONAL
Modifier | Constructor and Description |
---|---|
protected |
SyntaxNode()
Default constructor.
|
protected |
SyntaxNode(SyntaxNode node)
Constructs a new syntax node using data from another one.
|
protected |
SyntaxNode(SyntaxNode container,
Properties db,
Locale locale)
Constructs a new syntax node from the data in the given properties.
|
|
SyntaxNode(SyntaxNode container,
Properties db,
Locale locale,
Class<?> classHint)
Constructs a new syntax node from the data in the given properties.
|
Modifier and Type | Method and Description |
---|---|
protected BadSyntaxException |
error(String message,
SyntaxNode node)
Creates an instance of
BadSyntaxException from the given data. |
SyntaxNode |
getContainer()
Returns the node, which contains the definition of this one.
|
Properties |
getDB()
Returns the property database from which this element was created.
|
String |
getDescription()
Returns the description of this syntax node.
|
String |
getHelpText()
Returns the help text associated with this syntax node.
|
Locale |
getLocale()
Returns the locale with which this node is associated.
|
String |
getName()
Returns the name of this syntax element.
|
ResourceBundle |
getResourceBundle()
Returns the resource bundle defined for this syntax set.
|
String |
getShortName()
Returns the short name of this syntax element.
|
boolean |
isFloating()
Returns true if this node is floating, i.e.
|
boolean |
matches(String[] args,
Parameters parameters,
Parameters committedParameters,
ParsePosition position,
ParsePosition start,
SyntaxPosition farthestMismatchPosition,
boolean indexParameters)
Returns true if the node matches the given arguments starting with the
specified position.
|
protected void |
setDescription(String description)
Allows the derived classes to override the description.
|
protected void |
setFloating(boolean yesNo)
Allows the derived classes to override the floating flag.
|
protected void |
setHelpText(String helpText)
Allows the derived classes to override the help text.
|
protected void |
setName(String name)
Allows the derived classes to override the name.
|
protected void |
setResourceBundle(ResourceBundle res)
Allows the derived classes to override the resource bundle.
|
String |
toString()
Returns a simple string image of the syntax node.
|
String |
translate(String string)
Translates, if neccessary, the specified token name, using the resource
bundle associated with this node.
|
public static final String RESOURCE_PREFIX
public static final String VALUE_DELIMITER
public static final String ABBREV_DELIMITER
protected SyntaxNode()
public SyntaxNode(SyntaxNode container, Properties db, Locale locale, Class<?> classHint)
container
- Syntax node which contains this node.db
- Properties containing definition of this node.locale
- Locale context for this node's attributes.classHint
- Subclass of SyntaxNode into which this instance should
eventually resolve.protected SyntaxNode(SyntaxNode container, Properties db, Locale locale)
container
- Syntax node which contains this node.db
- Properties containing definition of this node.locale
- Locale context for this node's attributes.protected SyntaxNode(SyntaxNode node)
node
- The original unresolved node from which to construct this
fully resolved node.public String getName()
protected void setName(String name)
name
- new syntax element namepublic String getShortName()
public SyntaxNode getContainer()
public Properties getDB()
public ResourceBundle getResourceBundle()
protected void setResourceBundle(ResourceBundle res)
res
- new resource bundle for this syntax nodepublic boolean isFloating()
protected void setFloating(boolean yesNo)
yesNo
- if true this node will be considered floatingpublic Locale getLocale()
public String getDescription()
protected void setDescription(String description)
description
- new description of this nodepublic String getHelpText()
protected void setHelpText(String helpText)
helpText
- new help text for this nodepublic String translate(String string)
RESOURCE_PREFIX
constant. This prefix is stripped
from the string and then the translation is attempted.translate
in interface TokenTranslator
string
- Token to be translated, if neccessaryTokenTranslator.translate(java.lang.String)
public boolean matches(String[] args, Parameters parameters, Parameters committedParameters, ParsePosition position, ParsePosition start, SyntaxPosition farthestMismatchPosition, boolean indexParameters)
farthestMismatchPosition
parameter will hold the index of
the farthest argument that failed to match and the reference to the
syntax node against which that match failed. This base implementation
always returns false.args
- Command-line argument stringsparameters
- Parameter map into which this matching attempt should
accumulate its (String, Serializable) bindings.committedParameters
- Parameter map of (String, Serializable)
bindings that has been committed thus far through the entire
syntax matching process.position
- Position within the args, where this matching attempt
should start.start
- Position within the defined syntax, where this matching
attempt should start.farthestMismatchPosition
- The farthest position where mismatch
occured within this matching attempt.indexParameters
- flag indicating whether parameters contained
within this node should be added as indexed.public String toString()
protected BadSyntaxException error(String message, SyntaxNode node)
BadSyntaxException
from the given data.message
- message string for the exceptionnode
- context syntax nodeCopyright © 2016. All Rights Reserved.