|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.sling.api.resource.ResourceUtil
public class ResourceUtil
The ResourceUtil
class provides helper methods dealing
with resources.
Constructor Summary | |
---|---|
ResourceUtil()
|
Method Summary | |
---|---|
static java.lang.String |
getName(Resource rsrc)
Utility method returns the parent resource of the resource. |
static java.lang.String |
getName(java.lang.String path)
Utility method returns the name of the given path , which
is normalized by normalize(String) before resolving the name. |
static Resource |
getParent(Resource rsrc)
Utility method returns the parent resource of the resource. |
static java.lang.String |
getParent(java.lang.String path)
Utility method returns the parent path of the given path ,
which is normalized by normalize(String) before resolving the
parent. |
static ValueMap |
getValueMap(Resource res)
Returns an ValueMap object for the given
Resource . |
static boolean |
isNonExistingResource(Resource res)
Returns true if the resource res is a
non-existing resource. |
static boolean |
isStarResource(Resource res)
Returns true if the resource res is a "star
resource". |
static boolean |
isSyntheticResource(Resource res)
Returns true if the resource res is a
synthetic resource. |
static java.util.Iterator<Resource> |
listChildren(Resource parent)
Returns an Iterator of Resource objects loaded
from the children of the given Resource . |
static java.lang.String |
normalize(java.lang.String path)
Resolves relative path segments '.' and '..' in the absolute path. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ResourceUtil()
Method Detail |
---|
public static java.lang.String normalize(java.lang.String path)
public static java.lang.String getParent(java.lang.String path)
path
,
which is normalized by normalize(String)
before resolving the
parent.
path
- The path whose parent is to be returned.
null
if path
is the root path (/
)
or if path
is a single name containing no slash (/
)
characters.
java.lang.IllegalArgumentException
- If the path cannot be normalized by the
normalize(String)
method.
java.lang.NullPointerException
- If path
is null
.public static Resource getParent(Resource rsrc)
java.lang.NullPointerException
- If rsrc
is null
.public static java.lang.String getName(Resource rsrc)
java.lang.NullPointerException
- If rsrc
is null
.public static java.lang.String getName(java.lang.String path)
path
, which
is normalized by normalize(String)
before resolving the name.
path
- The path whose name (the last path element) is to be
returned.
path
is the root path (/
)
or if path
is a single name containing no slash (/
)
characters.
java.lang.IllegalArgumentException
- If the path cannot be normalized by the
normalize(String)
method.
java.lang.NullPointerException
- If path
is null
.public static boolean isSyntheticResource(Resource res)
true
if the resource res
is a
synthetic resource.
This method checks whether the resource is an instance of the
org.apache.sling.resource.SyntheticResource
class.
res
- The Resource
to check whether it is a synthetic
resource.
true
if res
is a synthetic
resource. false
is returned if res
is null
or not an instance of the
org.apache.sling.resource.SyntheticResource
class.public static boolean isStarResource(Resource res)
true
if the resource res
is a "star
resource". A star resource is a resource returned from the
ResourceResolver.resolve(HttpServletRequest)
whose path
terminates in a /*
. Generally such resource result from
requests to something like /some/path/*
or
/some/path/*.html
which may be used web applications to
uniformly handle resources to be created.
This method checks whether the resource path ends with a /*
indicating such a star resource.
res
- The Resource
to check whether it is a star
resource.
true
if res
is to be considered a
star resource.
java.lang.NullPointerException
- if res
is null
.public static boolean isNonExistingResource(Resource res)
true
if the resource res
is a
non-existing resource.
This method checks the resource type of the resource to match the
well-known resource type sling:nonexisting
of the
NonExistingResource
class defined in the Sling API.
res
- The Resource
to check whether it is a
non-existing resource.
true
if res
is to be considered a
non-existing resource.
java.lang.NullPointerException
- if res
is null
.public static java.util.Iterator<Resource> listChildren(Resource parent)
Iterator
of Resource
objects loaded
from the children of the given Resource
.
This is a convenience method for ResourceResolver.listChildren(Resource)
.
parent
- The Resource
whose children are requested.
Iterator
of Resource
objects.
java.lang.NullPointerException
- If parent
is
null
.
SlingException
- If any error occurs acquiring
the child resource iterator.ResourceResolver.listChildren(Resource)
public static ValueMap getValueMap(Resource res)
ValueMap
object for the given
Resource
.
This method calls Adaptable.adaptTo(Class)
with the
ValueMap
class as an argument. If the adaptTo
method returns a map, this map is returned. If the resource is not
adaptable to a value map, next an adaption to Map
is tried
and if this is successful the map is wrapped as a value map.
If the adaptions are not successful an empty value map is returned.
If null
is provided as the resource an empty map is
returned as well.
res
- The Resource
to adapt to the value map.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |