Package org.opencms.xml.xml2json
Class CmsResourceDataJsonHelper
java.lang.Object
org.opencms.xml.xml2json.CmsResourceDataJsonHelper
Helper class for formatting resource data as JSON.
-
Constructor Summary
ConstructorsConstructorDescriptionCmsResourceDataJsonHelper(CmsObject cms, CmsResource resource, Predicate<String> propertyFilter) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPathAndLink(JSONObject json) Adds path and link fields for the resource to the given JSON object.voidaddProperties(JSONObject result) Adds property data to the result object.Creates a JSON object with the attributes of the resource.properties(boolean inherited) Creates a JSON object with the properties of the resource.
-
Constructor Details
-
CmsResourceDataJsonHelper
public CmsResourceDataJsonHelper(CmsObject cms, CmsResource resource, Predicate<String> propertyFilter) Creates a new instance.- Parameters:
cms- the CMS contextresource- the resourcepropertyFilter- the property filter, which decides whether properties should be written to JSON or not
-
-
Method Details
-
addPathAndLink
Adds path and link fields for the resource to the given JSON object.- Parameters:
json- the JSON object to add the fields to- Throws:
JSONException- if something goes wrong
-
addProperties
Adds property data to the result object.- Parameters:
result- the result object- Throws:
CmsException- if something goes wrongJSONException- if something goes wrong with the JSON
-
attributes
Creates a JSON object with the attributes of the resource.- Returns:
- the JSON for the attributes
- Throws:
JSONException- if something goes wrong
-
properties
Creates a JSON object with the properties of the resource.- Parameters:
inherited- true if inherited properties should be loaded- Returns:
- the JSON object
- Throws:
CmsException- if something goes wrongJSONException- if something goes wrong
-