public class SyntaxFragment extends SyntaxNodeExtension
Modifier and Type | Field and Description |
---|---|
static String |
USAGE_STRING_SEPARATOR
Separator between components in usage String.
|
ABBREV_DELIMITER, RESOURCE_PREFIX, 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 |
SyntaxFragment()
Default constructor.
|
|
SyntaxFragment(SyntaxNode node,
SyntaxNodeExtension parent,
List<SyntaxNode> anchoredNodes,
List<SyntaxNode> floatingNodes)
Constructs a new syntax fragment.
|
Modifier and Type | Method and Description |
---|---|
void |
applyDefaults(Parameters parameters)
Scans through all floating and anchored nodes of the node and if the
value of the parameter is not already in the map, it places an entry in
the map using the default parameter value of the, if one is specified.
|
List<SyntaxNode> |
getAnchoredNodes()
Get the list of anchored, i.e.
|
void |
getCanonicNodeLists(List<SyntaxNode> anchored,
List<SyntaxNode> floating)
Augments the given lists with "flattened" lists of anchored and
floating nodes, where SyntaxFragments are replaced by their constituent
SyntaxNode subclasses.
|
SyntaxNode |
getFirstAnchoredNode()
Get the first anchored node or null if there is not one.
|
List<SyntaxNode> |
getFloatingNodes()
Get the list of floating nodes in this fragment.
|
String |
getHelpTopics()
Get the list of help topics associated with this syntax fragment.
|
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 boolean |
matchesAnchor(String[] args,
Parameters parameters,
Parameters committedParameters,
ParsePosition position,
ParsePosition start,
SyntaxPosition farthestMismatchPosition,
boolean indexParameters)
Returns true if the currently parsed argument matches the next anchored
positional syntax node.
|
protected boolean |
matchesFloater(String[] args,
Parameters parameters,
Parameters committedParameters,
ParsePosition position,
SyntaxPosition farthestMismatchPosition,
boolean indexParameters)
Returns true if the currently parsed argument matches any floating,
non-positional syntax node.
|
protected boolean |
matchesOnce(String[] args,
Parameters parameters,
Parameters committedParameters,
ParsePosition position,
ParsePosition start,
SyntaxPosition farthestMismatchPosition,
boolean indexParameters)
Returns true if the fragment matches once the given arguments starting
with the specified position.
|
void |
setHelpTopics(String helpTopics)
Sets the help topics associated with this syntax fragment.
|
String |
toString()
Returns the string image of this syntax fragment.
|
getMaxOccurrences, getMinOccurrences, getParent
error, getContainer, getDB, getDescription, getHelpText, getLocale, getName, getResourceBundle, getShortName, isFloating, setDescription, setFloating, setHelpText, setName, setResourceBundle, translate
public static final String USAGE_STRING_SEPARATOR
protected SyntaxFragment()
public SyntaxFragment(SyntaxNode node, SyntaxNodeExtension parent, List<SyntaxNode> anchoredNodes, List<SyntaxNode> floatingNodes)
node
- originating nodeparent
- parent nodeanchoredNodes
- list of anchored nodesfloatingNodes
- list of floating nodespublic List<SyntaxNode> getAnchoredNodes()
syntax nodes
public List<SyntaxNode> getFloatingNodes()
syntax nodes
public String getHelpTopics()
public void setHelpTopics(String helpTopics)
helpTopics
- The help topic list to set for this fragment.public SyntaxNode getFirstAnchoredNode()
public void getCanonicNodeLists(List<SyntaxNode> anchored, List<SyntaxNode> floating)
anchored
- List into which anchored nodes should be addedfloating
- List into which floating nodes should be addedpublic 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.matches
in class SyntaxNode
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.SyntaxNode.matches(java.lang.String[], com.hp.util.syntax.Parameters, com.hp.util.syntax.Parameters, java.text.ParsePosition, java.text.ParsePosition, com.hp.util.syntax.SyntaxPosition, boolean)
protected boolean matchesOnce(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.args
- arguments to be matchedparameters
- parameters tentatively parsed thus farcommittedParameters
- parameters definitely parsed thus farposition
- current parse positionstart
- starting parse positionfarthestMismatchPosition
- farthest parse position where mismatch
occurredindexParameters
- true if parameters are to be indexed; false
otherwiseSyntaxNode.matches(java.lang.String[], com.hp.util.syntax.Parameters, com.hp.util.syntax.Parameters, java.text.ParsePosition, java.text.ParsePosition, com.hp.util.syntax.SyntaxPosition, boolean)
protected boolean matchesFloater(String[] args, Parameters parameters, Parameters committedParameters, ParsePosition position, SyntaxPosition farthestMismatchPosition, boolean indexParameters)
args
- arguments to be matchedparameters
- parameters tentatively parsed thus farcommittedParameters
- parameters definitely parsed thus farposition
- current parse positionfarthestMismatchPosition
- farthest parse position where mismatch
occurredindexParameters
- true if parameters are to be indexed; false
otherwiseprotected boolean matchesAnchor(String[] args, Parameters parameters, Parameters committedParameters, ParsePosition position, ParsePosition start, SyntaxPosition farthestMismatchPosition, boolean indexParameters)
args
- arguments to be matchedparameters
- parameters tentatively parsed thus farcommittedParameters
- parameters definitely parsed thus farposition
- current parse positionstart
- starting parse positionfarthestMismatchPosition
- farthest parse position where mismatch
occurredindexParameters
- true if parameters are to be indexed; false
otherwisepublic void applyDefaults(Parameters parameters)
parameters
- parameters with default valuespublic String toString()
toString
in class SyntaxNode
Copyright © 2015. All Rights Reserved.