public final class TreeUtil
extends java.lang.Object
Tree
that are not provided
by the API.Modifier and Type | Method and Description |
---|---|
static Tree |
addChild(Tree tree,
java.lang.String childName,
java.lang.String primaryTypeName)
Adds a new child tree with the given name and primary type name.
|
static Tree |
addChild(Tree parent,
java.lang.String name,
java.lang.String typeName,
Tree typeRoot,
java.lang.String userID) |
static void |
addMixin(Tree tree,
java.lang.String mixinName,
Tree typeRoot,
java.lang.String userID) |
static void |
autoCreateItems(Tree tree,
Tree type,
Tree typeRoot,
java.lang.String userID) |
static PropertyState |
autoCreateProperty(java.lang.String name,
Tree definition,
java.lang.String userID) |
static java.lang.String |
findDefaultPrimaryType(Tree definitions,
boolean sns) |
static boolean |
getBoolean(Tree tree,
java.lang.String propertyName)
Returns the boolean representation of the property with the specified
propertyName . |
static java.lang.String |
getDefaultChildType(Tree typeRoot,
Tree parent,
java.lang.String childName)
Finds the default primary type for a new child node with the given name.
|
static java.util.List<Tree> |
getEffectiveType(Tree tree,
Tree typeRoot)
Returns the effective node types of the given node.
|
static long |
getLong(Tree tree,
java.lang.String name,
long defaultValue) |
static java.lang.String |
getName(Tree tree,
java.lang.String name) |
static java.lang.Iterable<java.lang.String> |
getNames(Tree tree,
java.lang.String name) |
static Tree |
getOrAddChild(Tree tree,
java.lang.String childName,
java.lang.String primaryTypeName)
Combination of
Tree.getChild(String) and adding a child including
its jcr:primaryType property (i.e. |
static java.lang.String |
getPrimaryTypeName(Tree tree) |
static java.lang.String |
getString(Tree tree,
java.lang.String propertyName) |
static java.lang.String |
getString(Tree tree,
java.lang.String name,
java.lang.String defaultValue) |
static java.lang.Iterable<java.lang.String> |
getStrings(Tree tree,
java.lang.String propertyName) |
static Tree |
getTree(Tree tree,
java.lang.String path)
Return the possibly non existing tree located at the passed
path from
the location of the start tree or null if path results
in a parent of the root. |
static boolean |
isNodeType(Tree tree,
java.lang.String typeName,
Tree typeRoot) |
static boolean |
isReadOnlyTree(Tree tree)
Returns
true if the specified tree is a read-only tree.. |
public static java.lang.String getPrimaryTypeName(Tree tree)
public static java.lang.Iterable<java.lang.String> getStrings(Tree tree, java.lang.String propertyName)
public static java.lang.String getString(Tree tree, java.lang.String propertyName)
public static java.lang.String getString(Tree tree, java.lang.String name, java.lang.String defaultValue)
public static boolean getBoolean(Tree tree, java.lang.String propertyName)
propertyName
. If the property does not exist or
is an array
this method returns false
.tree
- The target tree.propertyName
- The name of the property.false
if the property does not exist
or is an multivalued property.public static java.lang.String getName(Tree tree, java.lang.String name)
public static java.lang.Iterable<java.lang.String> getNames(Tree tree, java.lang.String name)
public static long getLong(Tree tree, java.lang.String name, long defaultValue)
public static Tree getTree(Tree tree, java.lang.String path)
path
from
the location of the start tree
or null
if path
results
in a parent of the root.tree
- start treepath
- path from the start treepath
from start
or null
public static Tree addChild(Tree parent, java.lang.String name, java.lang.String typeName, Tree typeRoot, java.lang.String userID) throws RepositoryException
RepositoryException
public static Tree addChild(Tree tree, java.lang.String childName, java.lang.String primaryTypeName) throws AccessDeniedException
Tree.addChild(String)
and
Tree.setProperty(String, Object, org.apache.jackrabbit.oak.api.Type)
where the property name is JcrConstants.JCR_PRIMARYTYPE
.
Note, that this method in addition verifies if the created tree exists
and is accessible in order to avoid IllegalStateException
upon
subsequent modification of the new child.childName
- The Oak name of the child item.primaryTypeName
- The Oak name of the primary node type.AccessDeniedException
- If the child does not exist after creation.public static Tree getOrAddChild(Tree tree, java.lang.String childName, java.lang.String primaryTypeName) throws AccessDeniedException
Tree.getChild(String)
and adding a child including
its jcr:primaryType property (i.e. Tree.addChild(String)
and
Tree.setProperty(PropertyState)
) in case no tree exists with the specified name.childName
- The Oak name of the child item.primaryTypeName
- The Oak name of the primary node type.AccessDeniedException
- If the child does not exist after creation.public static void addMixin(Tree tree, java.lang.String mixinName, Tree typeRoot, java.lang.String userID) throws RepositoryException
RepositoryException
public static void autoCreateItems(Tree tree, Tree type, Tree typeRoot, java.lang.String userID) throws RepositoryException
RepositoryException
public static PropertyState autoCreateProperty(java.lang.String name, Tree definition, java.lang.String userID)
public static java.lang.String getDefaultChildType(Tree typeRoot, Tree parent, java.lang.String childName)
typeRoot
- root of the /jcr:system/jcr:nodeTypes
treeparent
- parent nodechildName
- name of the new child nodenull
if not availablepublic static java.util.List<Tree> getEffectiveType(Tree tree, Tree typeRoot)
public static java.lang.String findDefaultPrimaryType(Tree definitions, boolean sns)
"Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"