Class WebUtils


  • public class WebUtils
    extends java.lang.Object
    Provides useful methods for working with JSON and web.
    • Constructor Detail

      • WebUtils

        private WebUtils()
    • Method Detail

      • getWebHijackPreventionStrategy

        public static WebHijackPreventionStrategy getWebHijackPreventionStrategy()
        Returns the configured WebHijackPreventionStrategy.
      • setWebHijackPreventionStrategy

        public static void setWebHijackPreventionStrategy​(WebHijackPreventionStrategy strategy)
        Sets a WebHijackPreventionStrategy.
        Will use default value (WebHijackPreventionStrategy.INFINITE_LOOP) if null.
      • protect

        public static java.lang.String protect​(JSON json)
        Transforms the input Json string using the configured WebHijackPreventionStrategy.
        Parameters:
        json - the input string
        Returns:
        String a transformed json string
      • protect

        public static java.lang.String protect​(JSON json,
                                               boolean shrink)
        Transforms the input Json string using the configured WebHijackPreventionStrategy.
        Parameters:
        json - the input string
        shrink - if redundant key quotes may be eliminated.
        Returns:
        String a transformed json string
      • toString

        public static java.lang.String toString​(JSON json)
        Returns a string represenation of a JSON value.
        When an object property name does not contain a space (' ') or a colon (':'), the quotes are omitted. This is done to reduce the amount of bytes sent to a web browser.
        USE WITH CAUTION.
      • join

        private static java.lang.String join​(JSONArray jsonArray)
      • quote

        private static java.lang.String quote​(java.lang.String str)
      • toString

        private static java.lang.String toString​(JSONArray jsonArray)
      • toString

        private static java.lang.String toString​(JSONNull jsonNull)
      • toString

        private static java.lang.String toString​(JSONObject jsonObject)
      • toString

        private static java.lang.String toString​(java.lang.Object object)