Package org.jibx.schema.elements
Class SchemaPath
java.lang.Object
org.jibx.schema.elements.SchemaPath
Path specification within a schema definition. This implements simple XPath-like expressions, consisting of any
number of path components given as element names or '*' for any element or '**' for any nesting of elements, along
with optional position number or name attribute predicates in square brackets.
- Author:
- Dennis M. Sosnoski
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ObjectSource object for path expression.private SchemaPath.StepBase[]Path steps.private final ValidationContextValidation context used for reporting errors.private static final SchemaPath.StepBaseSingle element wildcard step.private static final SchemaPath.StepBaseNesteing element wildcard step. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateSchemaPath(Object obj, ValidationContext vctx) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionstatic SchemaPathbuildPath(String path, String elemname, String nameattr, String postext, Object obj, ValidationContext vctx) Build a path.private SchemaPath.StepBasebuildPathStep(String step) Build a path step.private intconvertPosition(String postext) Validate and convert a position value.intGet length of this path (minimum number of nested elements).booleanCheck if the first path step is a wildcard.private voidmatch(int offset, int end, OpenAttrBase base, ArrayList matches) Find matches for expression starting from a supplied schema element.matchUnique(OpenAttrBase base) Find unique match for expression starting from a supplied schema element annotation.partialMatchMultiple(int first, int last, OpenAttrBase base) Find any number of matches for subexpression starting from a supplied schema element annotation.partialMatchUnique(int first, int last, OpenAttrBase base) Find unique match for subexpression starting from a supplied schema element annotation.private booleanvalidateName(String nameattr) Validate a name attribute value.
-
Field Details
-
WILDCARD_ELEMENT_STEP
Single element wildcard step. -
WILDCARD_NESTING_STEP
Nesteing element wildcard step. -
m_sourceObject
Source object for path expression. -
m_validationContext
Validation context used for reporting errors. -
m_steps
Path steps.
-
-
Constructor Details
-
SchemaPath
Constructor.- Parameters:
obj- source object for expressionvctx- validation context
-
-
Method Details
-
validateName
Validate a name attribute value.- Parameters:
nameattr- name value- Returns:
trueif valid,falseif not
-
convertPosition
Validate and convert a position value.- Parameters:
postext- position text- Returns:
- position value (strictly positive), or
-1if error
-
buildPathStep
Build a path step.- Parameters:
step- expression- Returns:
- constructed step, or
nullif error
-
match
Find matches for expression starting from a supplied schema element.- Parameters:
offset- current path step offsetend- ending match list offsetbase- starting element for matchmatches- elements matching expression
-
getPathLength
public int getPathLength()Get length of this path (minimum number of nested elements).- Returns:
- path length
-
isWildStart
public boolean isWildStart()Check if the first path step is a wildcard.- Returns:
trueif wildcard,falseif not
-
partialMatchMultiple
Find any number of matches for subexpression starting from a supplied schema element annotation.- Parameters:
first- starting path step indexlast- ending path step indexbase- starting element for match- Returns:
- matching element, or
nullif error
-
partialMatchUnique
Find unique match for subexpression starting from a supplied schema element annotation. An error is reported if no match is found, or if multiple matches are found.- Parameters:
first- starting path step indexlast- ending path step indexbase- starting element for match- Returns:
- matching element, or
nullif error
-
matchUnique
Find unique match for expression starting from a supplied schema element annotation. An error is reported if no match is found, or if multiple matches are found.- Parameters:
base- starting element for match- Returns:
- matching element, or
nullif error
-
buildPath
public static SchemaPath buildPath(String path, String elemname, String nameattr, String postext, Object obj, ValidationContext vctx) Build a path. If a path expression is supplied, the final path step in the expression must either not use an element name, or the element name must match the actual element supplied.- Parameters:
path- expression (nullif none)elemname- element name for final step in pathnameattr- name attribute (applied to final step in path,nullif none)postext- position (applied to final step in path,nullif none)obj- object defining the pathvctx- validation context- Returns:
- constructed path, or
nullif error
-