public class NodeUtils extends Object
Constructor and Description |
---|
NodeUtils() |
Modifier and Type | Method and Description |
---|---|
static javax.jcr.Node |
getCanonicalNode(javax.jcr.Node node)
Returns the canonical version of this node, and
null when there is no canonical node |
static javax.jcr.Node |
getDeref(javax.jcr.Node mirrorNode)
Returns the canonical
Node this mirrorNode is pointing to and returns null when
the mirrorNode is not a node of (sub)type hippo:mirror or hippo:facetselect |
static boolean |
isDereferenceable(javax.jcr.Node node)
Checks if the
node is dereferenceable. |
static boolean |
isNodeType(javax.jcr.Node node,
String... nodeTypeNames)
Checks if the
node is type of any of the nodeTypeNames . |
static boolean |
isNodeType(javax.jcr.Node node,
String nodeTypeName)
Checks if the
node is type of the nodeTypeName . |
static boolean |
isPrimaryNodeType(javax.jcr.Node node,
String... primaryNodeTypeNames)
Checks if the primary nodetype of
node is equal to one of the supplied primaryNodeTypeNames . |
public static javax.jcr.Node getCanonicalNode(javax.jcr.Node node)
null
when there is no canonical nodenode
- null
when there is no canonical node.RuntimeException
- when the repository throws a general repository exceptionpublic static boolean isDereferenceable(javax.jcr.Node node) throws javax.jcr.RepositoryException
node
is dereferenceable.
When the node
is type of either "hippo:facetselect" or "hippo:mirror" (or subtype of one of these),
the node is regarded as dereferenceable and the dereferenced node can be retrieved
by using getDeref(Node)
method.node
- true
when the node is dereferenceablejavax.jcr.RepositoryException
public static javax.jcr.Node getDeref(javax.jcr.Node mirrorNode)
Node
this mirrorNode
is pointing to and returns null
when
the mirrorNode
is not a node of (sub)type hippo:mirror or hippo:facetselectmirrorNode
- null
when the mirrorNode is not a dereferenceable type or when no dereferenced node can be foundpublic static boolean isNodeType(javax.jcr.Node node, String nodeTypeName) throws javax.jcr.RepositoryException
node
is type of the nodeTypeName
.
Returns true
if this node is of the specified primary node
type or mixin type, or a subtype thereof of the nodeTypeName
. Returns false
otherwise. Also see Node.isNodeType(String)
node
- nodeTypeName
- true
when node
is of the specified primary node type or mixin type,
or a subtype thereof of any of the nodeTypeName
javax.jcr.RepositoryException
public static boolean isNodeType(javax.jcr.Node node, String... nodeTypeNames) throws javax.jcr.RepositoryException
node
is type of any of the nodeTypeNames
.
Returns true
if this node is of the specified primary node
type or mixin type, or a subtype thereof of any of the nodeTypeNames
. Returns false
otherwise. Also see Node.isNodeType(String)
node
- the jcr nodenodeTypeNames
- the list of nodeTypeNames
to check.true
when node
is of the specified primary node type or mixin type,
or a subtype thereof of any of the nodeTypeNames
. If the node
is null
then
false
is returnedjavax.jcr.RepositoryException
public static boolean isPrimaryNodeType(javax.jcr.Node node, String... primaryNodeTypeNames) throws javax.jcr.RepositoryException
node
is equal to one of the supplied primaryNodeTypeNames
.
It returns true if node.getPrimaryNodeType().getName().equals(primaryNodeTypeName) returns true
for any of the
primaryNodeTypeNames
node
- primaryNodeTypeNames
- true
if node.getPrimaryNodeType().getName().equals(primaryNodeTypeName)
returns true
for any of the primaryNodeTypeNames
javax.jcr.RepositoryException
Copyright © 2008–2016 Hippo B.V. (http://www.onehippo.com). All rights reserved.