Class Escape


  • public class Escape
    extends Object
    Provide various methods for (un)escaping text
    • Constructor Detail

      • Escape

        public Escape()
    • Method Detail

      • entitychar

        public static boolean entitychar​(char c)
      • entityEscape

        public static String entityEscape​(String s,
                                          String wrt)
        Escape selected characters in a string using XML entities
        Parameters:
        s - string to escape
        wrt - which chars to escape
        Returns:
        escaped string
      • entityUnescape

        public static String entityUnescape​(String s)
      • entityUnescape

        public static String entityUnescape​(String s,
                                            String[][] translations)
      • backslashEscape

        public static String backslashEscape​(String s,
                                             String wrt)
        Escape control chars plus selected other characters in a string using backslash The definitive list is in netcdf-c/ncgen/ncgen.l.
        Parameters:
        s - the string to escape
        wrt - what printable characters to escape; control characters and '\\' are always escaped.
        Returns:
        escaped string
      • backslashUnescape

        public static String backslashUnescape​(String s)
        Remove backslashed characters in a string
      • backslashsplit

        public static List<String> backslashsplit​(String s,
                                                  char sep)
        Split a string with respect to a separator character and taking backslashes into consideration.
        Parameters:
        s - The string to split
        sep - The character on which to split
        Returns:
        a List of strings (all with escaping still intact) representing s split at unescaped instances of sep.
      • toHex

        public static String toHex​(int i)
      • fromHex

        public static int fromHex​(char c)
      • isHexDigit

        public static boolean isHexDigit​(char c)
      • bytes2hex

        public static String bytes2hex​(byte[] bytes)
      • urlEncodeQuery

        public static String urlEncodeQuery​(String s)
      • cleanString

        public static String cleanString​(String s)
        Clean up a string: currently means: 1. strip off everything after the first nul character
        Parameters:
        s - string to clean
        Returns:
        cleaned string