public class NodeUtil extends Object
Constructor and Description |
---|
NodeUtil(Tree tree) |
NodeUtil(Tree tree,
NameMapper mapper) |
Modifier and Type | Method and Description |
---|---|
NodeUtil |
addChild(String name,
String primaryTypeName)
Adds a new child tree with the given name and primary type name.
|
NodeUtil |
getChild(String name) |
long |
getLong(String name,
long defaultValue) |
String |
getName() |
String |
getName(String name,
String defaultValue) |
NodeUtil |
getOrAddChild(String name,
String primaryTypeName)
Combination of
getChild(String) and addChild(String, String)
in case no tree exists with the specified name. |
NodeUtil |
getOrAddTree(String relativePath,
String primaryTypeName)
TODO: clean up.
|
NodeUtil |
getParent() |
String |
getString(String name,
String defaultValue) |
Tree |
getTree() |
boolean |
hasChild(String name) |
void |
removeProperty(String name) |
void |
setBoolean(String name,
boolean value) |
void |
setDate(String name,
long time) |
void |
setName(String propertyName,
String value) |
void |
setNames(String propertyName,
String... values) |
void |
setString(String name,
String value) |
void |
setStrings(String name,
String... values) |
void |
setValues(String name,
Value[] values) |
public NodeUtil(Tree tree, NameMapper mapper)
public NodeUtil(Tree tree)
public Tree getTree()
public String getName()
public NodeUtil getParent()
public boolean hasChild(String name)
public NodeUtil addChild(String name, 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.name
- The name of the child item.primaryTypeName
- The name of the primary node type.AccessDeniedException
- If the child does not exist after creation.public NodeUtil getOrAddChild(String name, String primaryTypeName) throws AccessDeniedException
getChild(String)
and addChild(String, String)
in case no tree exists with the specified name.name
- The name of the child item.primaryTypeName
- The name of the primary node type.AccessDeniedException
- If the child does not exist after creation.public NodeUtil getOrAddTree(String relativePath, String primaryTypeName) throws AccessDeniedException
primaryTypeName
. This
method treats ".." parent element and "." as current element and
resolves them accordingly; in case of a relative path containing parent
elements this may lead to tree creating outside the tree structure
defined by this NodeUtil
.relativePath
- A relative OAK path that may contain parent and
current elements.primaryTypeName
- A oak name of a primary node type that is used
to create the missing trees.relativePath
.AccessDeniedException
- If the any intermediate tree does not exist
and cannot be created.public void removeProperty(String name)
public void setBoolean(String name, boolean value)
public void setDate(String name, long time)
public long getLong(String name, long defaultValue)
public void setValues(String name, Value[] values)
"Copyright © 2006 - 2015 Adobe Systems Incorporated. All Rights Reserved"