Class JsonRenderer
- java.lang.Object
-
- org.apache.sling.servlets.get.impl.helpers.JsonRenderer
-
-
Field Summary
Fields Modifier and Type Field Description static StringHARRAYSelector that causes hierarchy to be rendered as arrays instead of child objects - useful to preserve the order of those child objectsstatic intINDENT_SPACESHow much to indent in tidy modestatic StringINFINITYRecursion level selector that means "all levels"static StringTIDYSelector that means "pretty-print the output
-
Constructor Summary
Constructors Constructor Description JsonRenderer(long maximumResults, boolean ecmaSupport)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected intgetMaxRecursionLevel(org.apache.sling.api.SlingHttpServletRequest req)Get recursion level from selectors. as per SLING-167: the last selector, if present, gives the recursion level.protected booleanhasSelector(org.apache.sling.api.SlingHttpServletRequest req, String selectorToCheck)Checks if the provided request contains a certain selector.protected booleanisTidy(org.apache.sling.api.SlingHttpServletRequest req)True if our request wants the "tidy" pretty-printed formatvoidrender(org.apache.sling.api.SlingHttpServletRequest req, org.apache.sling.api.SlingHttpServletResponse resp)
-
-
-
Field Detail
-
INFINITY
public static final String INFINITY
Recursion level selector that means "all levels"- See Also:
- Constant Field Values
-
TIDY
public static final String TIDY
Selector that means "pretty-print the output- See Also:
- Constant Field Values
-
HARRAY
public static final String HARRAY
Selector that causes hierarchy to be rendered as arrays instead of child objects - useful to preserve the order of those child objects- See Also:
- Constant Field Values
-
INDENT_SPACES
public static final int INDENT_SPACES
How much to indent in tidy mode- See Also:
- Constant Field Values
-
-
Method Detail
-
render
public void render(org.apache.sling.api.SlingHttpServletRequest req, org.apache.sling.api.SlingHttpServletResponse resp) throws IOException- Specified by:
renderin interfaceRenderer- Throws:
IOException
-
getMaxRecursionLevel
protected int getMaxRecursionLevel(org.apache.sling.api.SlingHttpServletRequest req) throws IllegalArgumentExceptionGet recursion level from selectors. as per SLING-167: the last selector, if present, gives the recursion level.- Parameters:
req- the request- Returns:
- the recursion level
- Throws:
IllegalArgumentException- if the detected selector is not a number
-
hasSelector
protected boolean hasSelector(org.apache.sling.api.SlingHttpServletRequest req, String selectorToCheck)Checks if the provided request contains a certain selector.- Parameters:
req- the requestselectorToCheck- the selector- Returns:
trueif the selector is present,falseotherwise
-
isTidy
protected boolean isTidy(org.apache.sling.api.SlingHttpServletRequest req)
True if our request wants the "tidy" pretty-printed format- Parameters:
req- the request- Returns:
trueif the request contains theTIDYselector,falseotherwise
-
-