Interface Resource
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
AbstractResource
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
dump
(OutputStream output) Specific implementation may support this operation to dump (write) the internal data representation into theoutput
for debugging purpose.long
Returns child resource count of this resource representation.Return aResourceCollection
of child resource representations.getChildren
(long offset, long limit) Return aResourceCollection
of child resource representations fromoffset
index withlimit
count at max.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.Returns metadataValueMap
of this resource representation if there's any, or an empty value map if no metadata available.getName()
Returns the name of this resource representation if there's any.Return the underlying, internal node data that thisResource
represents.Returns parent resource representation if there's any.getPath()
Returns the path of this resource representation if there's any.Returns the resource type name of this resource representation if there's any.Resolves a property value of this resource by the givenrelPath
.<T> T
Resolves a property value of this resource by the givenrelPath
and converts it into the given type.Returns value map (type ofValueMap
) of this resource representation if there's any, or an empty value map if no values available.boolean
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 specificresourceType
name.
-
Method Details
-
getResourceType
String getResourceType()Returns the resource type name of this resource representation if there's any. For example, a JSON data based implementation may return '@type' property based on its domain rules, or a JCR based implementation may simply returnjavax.jcr.Node#getPrimaryNodeType().getName()
.- Returns:
- the resource type name of this resource representation if there's any
-
isResourceType
Returns true if this resource representation is typed and of the specificresourceType
name.- Parameters:
resourceType
- resource type name- Returns:
- true if this resource representation is typed and of the specific
resourceType
name
-
getName
String getName()Returns the name of this resource representation if there's any. For example, a JSON data based implementation may return '@name' property based on its domain rules, or a JCR based implementation may simply returnjavax.jcr.Item#getName()
.- Returns:
- the name of this resource representation if there's any
-
getPath
String getPath()Returns the path of this resource representation if there's any. For example, a JSON data based implementation may construct an XPath-like path based on object hierarchy, or a JCR based implementation may simply returnjavax.jcr.Item#getPath()
.- Returns:
- the path of this resource representation if there's any
-
getMetadata
ValueMap getMetadata()Returns metadataValueMap
of this resource representation if there's any, or an empty value map if no metadata available.- Returns:
- metadata
ValueMap
of this resource representation if there's any, or an empty value map if no metadata available
-
getValueMap
ValueMap getValueMap()Returns value map (type ofValueMap
) 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.- Returns:
- value map (type of
ValueMap
) of this resource representation if there's any, or an empty value map if no values available
-
getValue
Resolves a property value of this resource by the givenrelPath
. Or null if not resolved by therelPath
.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 atcontent/images
must be an array typeResource
object which returns true onResource.isArray()
.- Parameters:
relPath
- property or child resource relative path- Returns:
- a resolved property value of this resource by the given
relPath
. Or null if not resolved by therelPath
-
getValue
Resolves a property value of this resource by the givenrelPath
and converts it into the given type. Or null if not resolved by therelPath
.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 atcontent/images
must be an array typeResource
object which returns true onResource.isArray()
.- Parameters:
relPath
- property or child resource relative path- Returns:
- a resolved property value of this resource by the given
relPath
. Or null if not resolved by therelPath
-
getDefaultValue
Object getDefaultValue()Resolves the default property value of this resource if available, or null if unavailable. The default value resolution totally depends on the implementations. For example, an XML element based implementation may choose to return the text content of the underlying element.- Returns:
- the default property value of this resource if available, or null if unavailable
-
getDefaultValue
Resolves the default property value of this resource if available and converts it into the given type, or null if unavailable. The default value resolution totally depends on the implementations. For example, an XML element based implementation may choose to return the text content of the underlying element.- Returns:
- the default property value of this resource if available, or null if unavailable
-
getParent
Resource getParent()Returns parent resource representation if there's any.- Returns:
- parent resource representation if there's any
-
isAnyChildContained
boolean isAnyChildContained()Returns true if this resource representation contains any child resource representation.- Returns:
- true if this resource representation contains any child resource representation
-
isArray
boolean isArray()Returns true if this resource representation is purely for an array (e.g, JSON Array if underlying data is based on JSON).- Returns:
- true if this resource representation is purely for an array (e.g, JSON Array if underlying data is based on JSON)
-
getChildCount
long getChildCount()Returns child resource count of this resource representation.- Returns:
- child resource count of this resource representation
-
getChildren
ResourceCollection getChildren()Return aResourceCollection
of child resource representations.- Returns:
- a
ResourceCollection
of child resource representations
-
getChildren
Return aResourceCollection
of child resource representations fromoffset
index withlimit
count at max.- Parameters:
offset
- offset index to start iterationlimit
- limit count of iteration- Returns:
- a
ResourceCollection
of child resource representations
-
getNodeData
Object getNodeData()Return the underlying, internal node data that thisResource
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 aResource
object, then it might support this method by returning the Jackson node or just returnnull
when it doesn't support this method.- Returns:
- the underlying node data if supported by the underlying
ResourceResolver
ornull
otherwise.
-
dump
Specific implementation may support this operation to dump (write) the internal data representation into theoutput
for debugging purpose.WARNING: This method might not be supported by the specific
ResourceResolver
provider. Therefore, this operation throws anUnsupportedOperationException
by default unless the specificResourceResolver
provides a concrete implementation.- Parameters:
output
- the output stream to which the internal data representation is to be written.- Throws:
IOException
- if IO error occurs
-