public interface Resource extends Serializable
Modifier and Type | Method and Description |
---|---|
default void |
dump(OutputStream output)
Specific implementation may support this operation to dump (write) the internal data representation into the
output
for debugging purpose. |
long |
getChildCount()
Returns child resource count of this resource representation.
|
ResourceCollection |
getChildren()
Return a
ResourceCollection of child resource representations. |
ResourceCollection |
getChildren(long offset,
long limit)
Return a
ResourceCollection of child resource representations from offset index with limit
count at max. |
Object |
getDefaultValue()
Resolves the default property value of this resource if available, or null if unavailable.
|
<T> T |
getDefaultValue(Class<T> type)
Resolves the default property value of this resource if available and converts it into the given type, or
null if unavailable.
|
ValueMap |
getMetadata()
Returns metadata
ValueMap of this resource representation if there's any, or an empty value map if no metadata available. |
String |
getName()
Returns the name of this resource representation if there's any.
|
Object |
getNodeData()
Return the underlying, internal node data that this
Resource represents. |
Resource |
getParent()
Returns parent resource representation if there's any.
|
String |
getPath()
Returns the path of this resource representation if there's any.
|
String |
getResourceType()
Returns the resource type name of this resource representation if there's any.
|
Object |
getValue(String relPath)
Resolves a property value of this resource by the given
relPath . |
<T> T |
getValue(String relPath,
Class<T> type)
Resolves a property value of this resource by the given
relPath and converts it into the given type. |
ValueMap |
getValueMap()
Returns value map (type of
ValueMap ) of this resource representation if there's any, or an empty value map if no values available. |
boolean |
isAnyChildContained()
Returns true if this resource representation contains any child resource representation.
|
boolean |
isArray()
Returns true if this resource representation is purely for an array (e.g, JSON Array if underlying data is based on JSON).
|
boolean |
isResourceType(String resourceType)
Returns true if this resource representation is typed and of the specific
resourceType name. |
String getResourceType()
javax.jcr.Node#getPrimaryNodeType().getName()
.boolean isResourceType(String resourceType)
resourceType
name.resourceType
- resource type nameresourceType
nameString getName()
javax.jcr.Item#getName()
.String getPath()
javax.jcr.Item#getPath()
.ValueMap getMetadata()
ValueMap
of this resource representation if there's any, or an empty value map if no metadata available.ValueMap
of this resource representation if there's any, or an empty value map if no metadata availableValueMap getValueMap()
ValueMap
) of this resource representation if there's any, or an empty value map if no values available.
For example, a JSON data based implementation may construct a value map if the underlying JSON data is an object from its properties.ValueMap
) of this resource representation if there's any, or an empty value map if no values availableObject getValue(String relPath)
relPath
. Or null if not resolved by the relPath
.
If relPath
is a relative value path, like "content/title"
, then the return should
be equivalent to the result of the call, ((Resource) getValueMap().get("content")).getValueMap().get("title")
if existing.
In addition, a path segment may contain an array index notation like "content/images[1]/title"
.
In this case, the value at content/images
must be an array type Resource
object which
returns true on Resource.isArray()
.
relPath
- property or child resource relative pathrelPath
. Or null if not resolved by the relPath
<T> T getValue(String relPath, Class<T> type)
relPath
and converts it into the given type.
Or null if not resolved by the relPath
.
If relPath
is a relative value path, like "content/title"
, then the return should
be equivalent to the result of the call, ((Resource) getValueMap().get("content")).getValueMap().get("title")
if existing.
In addition, a path segment may contain an array index notation like "content/images[1]/title"
.
In this case, the value at content/images
must be an array type Resource
object which
returns true on Resource.isArray()
.
relPath
- property or child resource relative pathrelPath
. Or null if not resolved by the relPath
Object getDefaultValue()
<T> T getDefaultValue(Class<T> type)
Resource getParent()
boolean isAnyChildContained()
boolean isArray()
long getChildCount()
ResourceCollection getChildren()
ResourceCollection
of child resource representations.ResourceCollection
of child resource representationsResourceCollection getChildren(long offset, long limit)
ResourceCollection
of child resource representations from offset
index with limit
count at max.offset
- offset index to start iterationlimit
- limit count of iterationResourceCollection
of child resource representationsObject getNodeData()
Resource
represents.
WARNING: This method is for experts only who understands the risk of accessing the underlying internal, node data, and who is willing to change and upgrade their applications if the type of the underlying, internal data changes at any time in the future. The return object and its type of the underlying, internal data is not guaranteed in the future versions because this method is really implementation specific.
NOTE: The return of this method is really implementation specific. If a underlying ResourceResolver
maintains a Jackson node object for a Resource
object, then it might support this method by
returning the Jackson node or just return null
when it doesn't support this method.
ResourceResolver
or null
otherwise.default void dump(OutputStream output) throws IOException
output
for debugging purpose.
WARNING: This method might not be supported by the specific ResourceResolver
provider.
Therefore, this operation throws an UnsupportedOperationException
by default unless the specific
ResourceResolver
provides a concrete implementation.
output
- the output stream to which the internal data representation is to be written.IOException
- if IO error occursCopyright © 2017–2020 Hippo B.V. (http://www.onehippo.com). All rights reserved.