Package org.opencms.xml.xml2json.handler
Class CmsJsonHandlerXmlContent
- java.lang.Object
-
- org.opencms.xml.xml2json.handler.CmsJsonHandlerXmlContent
-
- All Implemented Interfaces:
I_CmsJsonHandler
- Direct Known Subclasses:
CmsJsonHandlerList
public class CmsJsonHandlerXmlContent extends java.lang.Object implements I_CmsJsonHandler
Sub-handler for converting XML contents to JSON, either as a whole or just specific locales or paths.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CmsJsonHandlerXmlContent.PathNotFoundException
Exception thrown when path lookup fails.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
PARAM_LOCALE
Request parameter name.static java.lang.String
PARAM_PATH
Request parameter name.
-
Constructor Summary
Constructors Constructor Description CmsJsonHandlerXmlContent()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static JSONObject
empty()
Creates an empty JSON object.double
getOrder()
Gets the sort order for this handler.boolean
matches(CmsJsonHandlerContext context)
Returns true if the handler matches the given context.CmsJsonResult
renderJson(CmsJsonHandlerContext context)
Renders the JSON.CmsJsonResult
renderJson(CmsJsonHandlerContext context, boolean throwError)
Renders a JSON representation of an XML content.
-
-
-
Field Detail
-
PARAM_LOCALE
public static final java.lang.String PARAM_LOCALE
Request parameter name.- See Also:
- Constant Field Values
-
PARAM_PATH
public static final java.lang.String PARAM_PATH
Request parameter name.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CmsJsonHandlerXmlContent
public CmsJsonHandlerXmlContent()
-
-
Method Detail
-
empty
public static JSONObject empty()
Creates an empty JSON object.- Returns:
- the empty JSON object
-
getOrder
public double getOrder()
Description copied from interface:I_CmsJsonHandler
Gets the sort order for this handler.Handlers are sorted by ascending order, and the first matching handler is selected.
- Specified by:
getOrder
in interfaceI_CmsJsonHandler
- Returns:
- the sort order
- See Also:
I_CmsJsonHandler.getOrder()
-
matches
public boolean matches(CmsJsonHandlerContext context)
Description copied from interface:I_CmsJsonHandler
Returns true if the handler matches the given context.- Specified by:
matches
in interfaceI_CmsJsonHandler
- Parameters:
context
- the context- Returns:
- true if the handler matches
- See Also:
I_CmsJsonHandler.matches(org.opencms.xml.xml2json.handler.CmsJsonHandlerContext)
-
renderJson
public CmsJsonResult renderJson(CmsJsonHandlerContext context)
Description copied from interface:I_CmsJsonHandler
Renders the JSON.- Specified by:
renderJson
in interfaceI_CmsJsonHandler
- Parameters:
context
- the context (provides information about the path and resource)- Returns:
- the JSON result
- See Also:
I_CmsJsonHandler.renderJson(org.opencms.xml.xml2json.handler.CmsJsonHandlerContext)
-
renderJson
public CmsJsonResult renderJson(CmsJsonHandlerContext context, boolean throwError)
Renders a JSON representation of an XML content.- Parameters:
context
- the handler contextthrowError
- whether to throw an error if a locale or path selection fails- Returns:
- the XML content as JSON
-
-