Contents | Package | Class | Tree | Deprecated | Index | Help XML for Java 1.0.4
PREV | NEXT SHOW LISTS | HIDE LISTS

Class com.ibm.xml.xpointer.RelTerm

java.lang.Object
    |
    +----com.ibm.xml.xpointer.RelTerm

public class RelTerm
extends java.lang.Object
implements OtherTerm, java.io.Serializable
The RelTerm class provides support for relative location terms in XPointers. A relative term specifies a location in terms of another location, called the location source. The location source is the entire resource if there are no preceding location terms; otherwise it is the location specified by the preceding term (which might be relative to a location term before that).

Each relative location term consists of a keyword, followed by arguments that define one or more steps. These location terms provide facilities for navigating forward, backward, up, and down through the element tree. The arguments passed to the keyword determine which node types from that sequence are chosen.

Each keyword is summarized:

child
Identifies direct child nodes of the location source.
descendant
Identifies nodes appearing anywhere within the content of the location source.
ancestor
Identifies element nodes containing the location source.
preceding
Identifies nodes that appear before (preceding) the location source.
following
Identifies nodes that appear after (following) the location source.
psibling
Identifies sibling nodes (sharing their parent with the location source) that appear before (preceding) the location source.
fsibling
Identifies sibling nodes (sharing their parent with the location source) that appear after (following) the location source.

Each of the keywords accepts the following arguments:

  1. InstanceOrAll: For a positive instance number n, the nth of the candidate locations is identified. For a negative instance number, the candidate locations are counted from last to first (in a manner that is specific to each keyword). If the instance value all is given, then all the candidate locations are selected.
  2. NodeType: The node type may be specified by one of the following values:
  3. Attributes: Candidate elements can be selected based on their attribute names and values. Note that non-element node types have no attributes, and so can never satisfy selection criteria that include attribute name or value specifications. See RelTermAttribute for details.

Version:
Revision: 77 1.4 src/com/ibm/xml/xpointer/RelTerm.java, xml4jsrc, xml4j-jtcsv, xml4j_1_0_4
See Also:
XPointer, RelTermAttribute, StringTerm, OtherTerm

Constructor Summary
 RelTerm(int keywordType, boolean isAll, int instance, int nodeType, java.lang.String elementName, java.util.Vector attributes)
Constructor for specifying attributes and for full customization.
 RelTerm(int keywordType, int instance, int nodeType)
Constructor for keywordType(instance,nodeType).
 RelTerm(int keywordType, boolean isAll, int nodeType)
Constructor for keywordType(all,nodeType).
 RelTerm(int keywordType, int instance, java.lang.String elementName)
Constructor for keywordType(instance,elementName).
 RelTerm(int keywordType, java.lang.String elementName)
Constructor for keywordType(all,elementName).
 RelTerm(int keywordType, int instance)
Constructor for keywordType(instance).
 RelTerm(int keywordType)
Constructor for keywordType(all).
 

Method Summary
java.util.Vector  getAttributesVector()
Returns a Vector of attribute names and values to further qualify candidate elements.
java.lang.String  getElementName()
Returns the name of the element to be selected by this relative term.
int  getInstance()
Returns the nth of the candidate locations to be selected by this relative term.
int  getNodeType()
Returns the node type to be selected by this relative term.
int  getType()
Returns the integer representing the keyword type of this relative term.
java.lang.String  getTypeName()
Returns the string keyword type of this relative term.
boolean  isAll()
Returns whether all candidate locations are selected by this relative term.
boolean  match(Node child)
Returns whether the specified child matches this relative term.
void  setType(int keywordType)
Sets the integer representing the keyword type of this relative term.
java.lang.String  toString()
Returns this relative term in the form of either:
  • keywordType(all)
  • keywordType(instance)
  • keywordType(all,elementName)
  • keywordType(instance,elementName)
  • keywordType(all,nodeType)
  • keywordType(instance,nodeType)
  • keywordType(all,elementName,attributes)
  • keywordType(instance,elementName,attributes)
  • keywordType(all,nodeType,attributes)
  • keywordType(instance,nodeType,attributes)
 
Methods inherited from class java.lang.Object
 clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RelTerm

public RelTerm(int keywordType,
               boolean isAll,
               int instance,
               int nodeType,
               java.lang.String elementName,
               java.util.Vector attributes)
Constructor for specifying attributes and for full customization.
Parameters:
keywordType - Must be one of: XPointer.ST_NONE, ST_CHILD, ST_DESCENDANT, ST_ANCESTOR, ST_PRECEDING, ST_PSIBLING, ST_FOLLOWING, ST_FSIBLING.
isAll - means all the candidate locations are selected. If =false, instance should be specified.
instance - The nth of the candidate locations is selected. Only relevant if isAll=false.
nodeType - Must be one of: XPointer.NT_NAME, NT_ELEMENT, NT_PI, NT_COMMENT, NT_TEXT, NT_CDATA, or NT_ALL. If =NT_NAME, elementName should be specified.
elementName - Selects a particular XML element type to count as candidates. Only relevant if nodeType=NT_NAME.
attributes - A vector of attribute name and values to further qualify candidate elements.

RelTerm

public RelTerm(int keywordType,
               int instance,
               int nodeType)
Constructor for keywordType(instance,nodeType).
Parameters:
keywordType - Must be one of: XPointer.ST_NONE, ST_CHILD, ST_DESCENDANT, ST_ANCESTOR, ST_PRECEDING, ST_PSIBLING, ST_FOLLOWING, ST_FSIBLING.
instance - The nth of the candidate locations is selected.
nodeType - Must be one of: XPointer.NT_ELEMENT, NT_PI, NT_COMMENT, NT_TEXT, NT_CDATA, or NT_ALL.

RelTerm

public RelTerm(int keywordType,
               boolean isAll,
               int nodeType)
Constructor for keywordType(all,nodeType).
Parameters:
keywordType - Must be one of: XPointer.ST_NONE, ST_CHILD, ST_DESCENDANT, ST_ANCESTOR, ST_PRECEDING, ST_PSIBLING, ST_FOLLOWING, ST_FSIBLING.
isAll - Should be =true for this constructor.
nodeType - Must be one of: XPointer.NT_ELEMENT, NT_PI, NT_COMMENT, NT_TEXT, NT_CDATA, or NT_ALL.

RelTerm

public RelTerm(int keywordType,
               int instance,
               java.lang.String elementName)
Constructor for keywordType(instance,elementName).
Parameters:
keywordType - Must be one of: XPointer.ST_NONE, ST_CHILD, ST_DESCENDANT, ST_ANCESTOR, ST_PRECEDING, ST_PSIBLING, ST_FOLLOWING, ST_FSIBLING.
instance - The nth of the candidate locations is selected.
elementName - Selects a particular XML element type to count as candidates.

RelTerm

public RelTerm(int keywordType,
               java.lang.String elementName)
Constructor for keywordType(all,elementName).
Parameters:
keywordType - Must be one of: XPointer.ST_NONE, ST_CHILD, ST_DESCENDANT, ST_ANCESTOR, ST_PRECEDING, ST_PSIBLING, ST_FOLLOWING, ST_FSIBLING.
elementName - Selects a particular XML element type to count as candidates.

RelTerm

public RelTerm(int keywordType,
               int instance)
Constructor for keywordType(instance).
Parameters:
keywordType - Must be one of: XPointer.ST_NONE, ST_CHILD, ST_DESCENDANT, ST_ANCESTOR, ST_PRECEDING, ST_PSIBLING, ST_FOLLOWING, ST_FSIBLING.
instance - The nth of the candidate locations is selected.

RelTerm

public RelTerm(int keywordType)
Constructor for keywordType(all).
Parameters:
keywordType - Must be one of: XPointer.ST_NONE, ST_CHILD, ST_DESCENDANT, ST_ANCESTOR, ST_PRECEDING, ST_PSIBLING, ST_FOLLOWING, ST_FSIBLING.
Method Detail

getType

public int getType()
Returns the integer representing the keyword type of this relative term.
Returns:
One of: XPointer.ST_NONE, ST_CHILD, ST_DESCENDANT, ST_ANCESTOR, ST_PRECEDING, ST_PSIBLING, ST_FOLLOWING, ST_FSIBLING.
See Also:
getTypeName, setType

setType

public void setType(int keywordType)
Sets the integer representing the keyword type of this relative term.
Parameters:
keywordType - One of: XPointer.ST_NONE, ST_CHILD, ST_DESCENDANT, ST_ANCESTOR, ST_PRECEDING, ST_PSIBLING, ST_FOLLOWING, ST_FSIBLING.
See Also:
getType, setType

getTypeName

public java.lang.String getTypeName()
Returns the string keyword type of this relative term.
Returns:
One of: null, child, descendant, ancestor, preceding, psibling, following, fsibling.
See Also:
getType, setType

isAll

public boolean isAll()
Returns whether all candidate locations are selected by this relative term.
Returns:
=true means all the candidate locations are selected. If =false, instance is relevant.
See Also:
getInstance

getInstance

public int getInstance()
Returns the nth of the candidate locations to be selected by this relative term. Only relevant if isAll=false.
Returns:
The nth of the candidate locations to select.
See Also:
isAll

getNodeType

public int getNodeType()
Returns the node type to be selected by this relative term.
Returns:
One of: XPointer.NT_NONE, NT_NAME, NT_ELEMENT, NT_PI, NT_COMMENT, NT_TEXT, NT_CDATA, or NT_ALL. If =NT_NAME, elementName is relevant.
See Also:
getElementName

getElementName

public java.lang.String getElementName()
Returns the name of the element to be selected by this relative term. Only relevant if nodeType=NT_NAME.
Returns:
The particular XML element type to count as a candidate.
See Also:
getNodeType

getAttributesVector

public java.util.Vector getAttributesVector()
Returns a Vector of attribute names and values to further qualify candidate elements.
Returns:
A Vector of RelTermAttribute.
See Also:
RelTermAttribute

toString

public java.lang.String toString()
Returns this relative term in the form of either:
Returns:
A string represention of this relative term.
Overrides:
toString in class java.lang.Object

match

public boolean match(Node child)
Returns whether the specified child matches this relative term. A match is defined if this relative term's:
  • nodeType matches child's DOM node type, or elementName matches child's element tag name.
  • attributes element qualifiers are satisfied by child's Attribute Nodes.
Returns:
=true if all the above conditions are satisfied; otherwise, =false.
See Also:
Child

Contents | Package | Class | Tree | Deprecated | Index | Help
PREV | NEXT SHOW LISTS | HIDE LISTS