Package org.opencms.xml.xml2json
Class CmsResourceDataJsonHelper
- java.lang.Object
-
- org.opencms.xml.xml2json.CmsResourceDataJsonHelper
-
public class CmsResourceDataJsonHelper extends java.lang.Object
Helper class for formatting resource data as JSON.
-
-
Constructor Summary
Constructors Constructor Description CmsResourceDataJsonHelper(CmsObject cms, CmsResource resource, java.util.function.Predicate<java.lang.String> propertyFilter)
Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addPathAndLink(JSONObject json)
Adds path and link fields for the resource to the given JSON object.void
addProperties(JSONObject result)
Adds property data to the result object.JSONObject
attributes()
Creates a JSON object with the attributes of the resource.JSONObject
properties(boolean inherited)
Creates a JSON object with the properties of the resource.
-
-
-
Constructor Detail
-
CmsResourceDataJsonHelper
public CmsResourceDataJsonHelper(CmsObject cms, CmsResource resource, java.util.function.Predicate<java.lang.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 Detail
-
addPathAndLink
public void addPathAndLink(JSONObject json) throws JSONException
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
public void addProperties(JSONObject result) throws CmsException, JSONException
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
public JSONObject attributes() throws JSONException
Creates a JSON object with the attributes of the resource.- Returns:
- the JSON for the attributes
- Throws:
JSONException
- if something goes wrong
-
properties
public JSONObject properties(boolean inherited) throws CmsException, JSONException
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
-
-