public class ChildrenAsPropertyResource
extends org.apache.sling.api.resource.ResourceWrapper
| Modifier and Type | Field and Description |
|---|---|
static Comparator<org.apache.sling.api.resource.Resource> |
RESOURCE_NAME_COMPARATOR |
| Constructor and Description |
|---|
ChildrenAsPropertyResource(org.apache.sling.api.resource.Resource resource)
ResourceWrapper that allows resource children to be modeled in data stored into a property using the default
property name of "children".
|
ChildrenAsPropertyResource(org.apache.sling.api.resource.Resource resource,
String propertyName)
ResourceWrapper that allows resource children to be modeled in data stored into a property.
|
ChildrenAsPropertyResource(org.apache.sling.api.resource.Resource resource,
String propertyName,
Comparator<org.apache.sling.api.resource.Resource> comparator)
ResourceWrapper that allows resource children to be modeled in data stored into a property.
|
| Modifier and Type | Method and Description |
|---|---|
org.apache.sling.api.resource.Resource |
create(String name,
String primaryType) |
org.apache.sling.api.resource.Resource |
create(String name,
String primaryType,
Map<String,Object> data) |
void |
delete(String name)
Deletes the named child.
|
void |
deleteAll()
Delete all children.
|
protected List<SyntheticChildAsPropertyResource> |
deserializeToSyntheticChildResources(com.google.gson.JsonObject jsonObject)
Converts a JSONObject to the list of SyntheticChildAsPropertyResources.
|
org.apache.sling.api.resource.Resource |
getChild(String name) |
Iterable<org.apache.sling.api.resource.Resource> |
getChildren() |
org.apache.sling.api.resource.Resource |
getParent() |
Iterator<org.apache.sling.api.resource.Resource> |
listChildren() |
void |
persist()
Persist changes to the underlying valuemap so they are available for persisting to the JCR.
|
protected com.google.gson.JsonObject |
serializeToJSON(org.apache.sling.api.resource.Resource resourceToSerialize)
Converts a list of SyntheticChildAsPropertyResource to their JSON representation, keeping the provided order.
|
public static final Comparator<org.apache.sling.api.resource.Resource> RESOURCE_NAME_COMPARATOR
public ChildrenAsPropertyResource(org.apache.sling.api.resource.Resource resource)
throws InvalidDataFormatException
resource - the resource to store the children as properties onInvalidDataFormatExceptionpublic ChildrenAsPropertyResource(org.apache.sling.api.resource.Resource resource,
String propertyName)
throws InvalidDataFormatException
resource - the resource to store the children as properties onpropertyName - the property name to store the children as properties inInvalidDataFormatExceptionpublic ChildrenAsPropertyResource(org.apache.sling.api.resource.Resource resource,
String propertyName,
Comparator<org.apache.sling.api.resource.Resource> comparator)
throws InvalidDataFormatException
resource - the resource to store the children as properties onpropertyName - the property name to store the children as properties incomparator - the comparator used to order the serialized childrenInvalidDataFormatExceptionpublic final Iterator<org.apache.sling.api.resource.Resource> listChildren()
listChildren in interface org.apache.sling.api.resource.ResourcelistChildren in class org.apache.sling.api.resource.ResourceWrapperpublic final Iterable<org.apache.sling.api.resource.Resource> getChildren()
getChildren in interface org.apache.sling.api.resource.ResourcegetChildren in class org.apache.sling.api.resource.ResourceWrapperpublic final org.apache.sling.api.resource.Resource getChild(String name)
getChild in interface org.apache.sling.api.resource.ResourcegetChild in class org.apache.sling.api.resource.ResourceWrapperpublic final org.apache.sling.api.resource.Resource getParent()
getParent in interface org.apache.sling.api.resource.ResourcegetParent in class org.apache.sling.api.resource.ResourceWrapperpublic final org.apache.sling.api.resource.Resource create(String name, String primaryType) throws javax.jcr.RepositoryException
javax.jcr.RepositoryExceptionpublic final org.apache.sling.api.resource.Resource create(String name, String primaryType, Map<String,Object> data) throws javax.jcr.RepositoryException
javax.jcr.RepositoryExceptionpublic final void delete(String name) throws javax.jcr.RepositoryException
name - the child node name to deletejavax.jcr.RepositoryExceptionpublic final void deleteAll()
throws InvalidDataFormatException
InvalidDataFormatExceptionpublic final void persist()
throws javax.jcr.RepositoryException
javax.jcr.RepositoryExceptionprotected final com.google.gson.JsonObject serializeToJSON(org.apache.sling.api.resource.Resource resourceToSerialize)
throws IllegalAccessException,
NoSuchMethodException,
InvocationTargetException
resourceToSerialize - the resource to serialize to JSON.IllegalAccessExceptionNoSuchMethodExceptionInvocationTargetExceptionprotected final List<SyntheticChildAsPropertyResource> deserializeToSyntheticChildResources(com.google.gson.JsonObject jsonObject)
jsonObject - the JSONObject to deserialize.Copyright © 2013–2020 Adobe. All rights reserved.