|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.sling.jcr.resource.JcrResourceUtil
public class JcrResourceUtil
The JcrResourceUtil
class provides helper methods used
throughout this bundle.
Constructor Summary | |
---|---|
JcrResourceUtil()
|
Method Summary | |
---|---|
static javax.jcr.Node |
createPath(javax.jcr.Node parentNode,
java.lang.String relativePath,
java.lang.String intermediateNodeType,
java.lang.String nodeType,
boolean autoSave)
Creates or gets the Node at the given Path. |
static javax.jcr.Node |
createPath(java.lang.String path,
java.lang.String intermediateNodeType,
java.lang.String nodeType,
javax.jcr.Session session,
boolean autoSave)
Creates or gets the Node at the given Path. |
static javax.jcr.Value |
createValue(java.lang.Object value,
javax.jcr.Session session)
Creates a JCR Value for the given object with
the given Session. |
static java.lang.String |
getResourceSuperType(Resource resource)
Returns the resource super type of the given resource. |
static java.lang.String |
getResourceSuperType(ResourceResolver resourceResolver,
java.lang.String resourceType)
Returns the super type of the given resource type. |
static javax.jcr.query.QueryResult |
query(javax.jcr.Session session,
java.lang.String query,
java.lang.String language)
Helper method to execute a JCR query |
static java.lang.String |
resourceTypeToPath(java.lang.String type)
Helper method, which returns the given resource type as returned from the Resource.getResourceType() as a
relative path. |
static void |
setProperty(javax.jcr.Node node,
java.lang.String propertyName,
java.lang.Object propertyValue)
Sets the value of the property. |
static java.lang.Object |
toJavaObject(javax.jcr.Property property)
Converts the value(s) of a JCR Property to a corresponding Java Object. |
static java.lang.Object |
toJavaObject(javax.jcr.Value value)
Converts a JCR Value to a corresponding Java Object |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public JcrResourceUtil()
Method Detail |
---|
public static javax.jcr.query.QueryResult query(javax.jcr.Session session, java.lang.String query, java.lang.String language) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
public static java.lang.Object toJavaObject(javax.jcr.Value value) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
public static java.lang.Object toJavaObject(javax.jcr.Property property) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
public static javax.jcr.Value createValue(java.lang.Object value, javax.jcr.Session session) throws javax.jcr.RepositoryException
JCR Value
for the given object with
the given Session.
Selects the the PropertyType
according
the instance of the object's Class
value
- objectsession
- to create value for
javax.jcr.RepositoryException
- in case of error, accessing the Repositorypublic static void setProperty(javax.jcr.Node node, java.lang.String propertyName, java.lang.Object propertyValue) throws javax.jcr.RepositoryException
PropertyType
according
to the instance of the object's class.
node
- The node where the property will be set on.propertyName
- The name of the property.propertyValue
- The value for the property.
javax.jcr.RepositoryException
public static java.lang.String resourceTypeToPath(java.lang.String type)
Resource.getResourceType()
as a
relative path.
type
- The resource type to be converted into a path
public static java.lang.String getResourceSuperType(ResourceResolver resourceResolver, java.lang.String resourceType)
JcrResourceConstants.SLING_RESOURCE_SUPER_TYPE_PROPERTY
of the
Resource
addressed by the resourceType
to a
string. If no such child resource exists or if the resource does not
adapt to a string, this method returns null
.
resourceResolver
- The ResourceResolver
used to
access the resource whose path (relative or absolute) is given
by the resourceType
parameter.resourceType
- The resource type whose super type is to be returned.
This type is turned into a path by calling the
resourceTypeToPath(String)
method before trying to
get the resource through the resourceResolver
.
resourceType
or
null
if the resource type does not have a child
resource
JcrResourceConstants.SLING_RESOURCE_SUPER_TYPE_PROPERTY
adapting to a string.public static java.lang.String getResourceSuperType(Resource resource)
JcrResourceConstants.SLING_RESOURCE_SUPER_TYPE_PROPERTY
if the
given resource
adapted to a string or the result of
calling the getResourceSuperType(ResourceResolver, String)
method on the resource type of the resource
.
This mechanism allows to specifically set the resource super type on a per-resource level overwriting any resource super type hierarchy pre-defined by the actual resource type of the resource.
resource
- The Resource
whose resource super type is
requested.
null
if the algorithm
described above does not yield a resource super type.public static javax.jcr.Node createPath(java.lang.String path, java.lang.String intermediateNodeType, java.lang.String nodeType, javax.jcr.Session session, boolean autoSave) throws javax.jcr.RepositoryException
Node
at the given Path.
In case it has to create the Node all non-existent intermediate path-elements
will be create with the given intermediate node type and the returned node
will be created with the given nodeType
path
- to createintermediateNodeType
- to use for creation of intermediate nodes (or null)nodeType
- to use for creation of the final node (or null)session
- to useautoSave
- Should save be called when a new node is created?
javax.jcr.RepositoryException
- in case of exception accessing the Repositorypublic static javax.jcr.Node createPath(javax.jcr.Node parentNode, java.lang.String relativePath, java.lang.String intermediateNodeType, java.lang.String nodeType, boolean autoSave) throws javax.jcr.RepositoryException
Node
at the given Path.
In case it has to create the Node all non-existent intermediate path-elements
will be create with the given intermediate node type and the returned node
will be created with the given nodeType
parentNode
- starting noderelativePath
- to createintermediateNodeType
- to use for creation of intermediate nodes (or null)nodeType
- to use for creation of the final node (or null)autoSave
- Should save be called when a new node is created?
javax.jcr.RepositoryException
- in case of exception accessing the Repository
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |