The following are the level 1 methods of Node. They are used for getting the child nodes and properties of a node. The Node interface has other methods as well, though in a level 1-only implementation they will either do nothing or throw an exception.
javax.jcr. |
|
Node |
getNode(String relPath) Returns the node at relPath relative to this node. If relPath contains a path element that refers to a node with same-name sibling nodes without explicitly including an index using the array-style notation ([x]), then the index [1] is assumed (See 4.3 Same-Name Siblings ). Within the scope of a single Session object, if a node has been acquired with getNode, any subsequent call of getNode reacquiring the same node must return a Node object reflecting the same state as the earlier Node object. Whether this object is actually the same Node instance, or simply one wrapping the same state, is up to the implementation. See 7.1.3.1 Re-using Item Objects. If no node exists at relPath a PathNotFoundException is thrown. A RepositoryException is thrown if another error occurs. |
NodeIterator |
getNodes() Returns all child nodes of this node. Does not include properties of this node. The same reacquisition semantics apply as with getNode. If this node has no child nodes, then an empty iterator is returned. A RepositoryException is thrown if another error occurs. |
NodeIterator |
getNodes(String namePattern) Gets all child nodes of this node that match namePattern. The pattern may be a full name or a partial name with one or more wildcard characters ("*"), or a disjunction (using the “|” character to represent logical OR) of these. For example, N.getNodes("jcr:* | myapp:report | my doc") would return a NodeIterator holding all child nodes of N that are either called 'myapp:report', begin with the prefix 'jcr:' or are called 'my doc'. Note that leading and trailing whitespace around a | character is ignored, but whitespace within a disjunct forms part of the pattern to be matched. The EBNF for namePattern is:
namePattern ::= disjunct {'|' disjunct} The pattern is matched against the names (not the paths) of the immediate child nodes of this node. If this node has no matching child nodes, then an empty iterator is returned. The same reacquisition semantics apply as with getNode. A RepositoryException is thrown if an error occurs. |
Property |
getProperty(String relPath) Get the property at relPath relative to this node. The same reacquisition semantics apply as with getNode. If no property exists at relPath a PathNotFoundException is thrown. A RepositoryException is thrown if another error occurs. |
PropertyIterator |
getProperties() Gets all properties of this node. Does not include child nodes of this node. The same reacquisition semantics apply as with getNode. If this node has no properties, then an empty iterator is returned. A RepositoryException is thrown if an error occurs. |
PropertyIterator |
getProperties(String namePattern) Gets all properties of this node that match namePattern. The pattern may be a full name or a partial name with one or more wildcard characters ("*"), or a disjunction (using the “|” character to represent logical OR) of these. For example, N.getProperties("jcr:* | myapp:name | my doc") would return a PropertyIterator holding all properties of N that are either called 'myapp:name', begin with the prefix 'jcr:' or are called 'my doc'. Note that leading and trailing whitespace around a disjunct is ignored, but whitespace within a disjunct forms part of the pattern to be matched. The EBNF for namePattern is:
namePattern ::= disjunct {'|' disjunct} The pattern is matched against the names (not the paths) of the immediate child properties of this node. If this node has no matching properties, then an empty iterator is returned. The same reacquisition semantics apply as with getNode. A RepositoryException is thrown if an error occurs. |
Item |
getPrimaryItem() The primary node type (see 6.7 Node Types) of this node may specify one child item (child node or property) of this node as the primary child item. This method returns that item. The same reacquisition semantics apply as with getNode. If this node has no primary child item, either because none is declared in the node type or because a declared primary item is not present on this node instance, then this method throws an ItemNotFoundException. A RepositoryException is thrown if another error occurs. |
String |
getUUID() Returns the UUID of this node as recorded in the node's jcr:uuid property. This method only works on nodes of mixin node type mix:referenceable. On nonreferenceable nodes, this method throws an UnsupportedRepositoryOperationException. To avoid throwing an exception to determine whether a node has a UUID, a call to isNodeType("mix:referenceable") can be made. A RepositoryException is thrown if another error occurs. |
int |
getIndex() This method returns the index of this node within the ordered set of its same-name sibling nodes. This index is the one used to address same-name siblings using the square-bracket notation, e.g., /a[3]/b[4]. Note that the index always starts at 1 (not 0), for compatibility with XPath. As a result, for nodes that do not have same-name-siblings, this method will always return 1. |
PropertyIterator |
getReferences() Returns all REFERENCE properties that refer to this node. Some level 2 implementations may only return properties that have been saved (in a transactional setting this includes both those properties that have been saved but not yet committed, as well as properties that have been committed). Other level 2 implementations may additionally return properties that have been added within the current Session but are not yet saved. In implementations that support versioning, this method does not return REFERENCE properties that are part of the frozen state of a version in version storage. If this node has no references, an empty iterator is returned. A RepositoryException is thrown if an error occurs. |
boolean |
hasNode(String relPath) Returns true if a node exists at relPath and false otherwise. |
boolean |
hasNodes() Returns true if this node has one or more child nodes. Returns false otherwise. |
boolean |
hasProperty(String relPath) Returns true if a property exists at relPath and false otherwise. |
boolean |
hasProperties() Returns true if this node has one or more properties. Returns false otherwise. |