Package dap4.core.util
Class Escape
- java.lang.Object
-
- dap4.core.util.Escape
-
public class Escape extends Object
Provide various methods for (un)escaping text
-
-
Field Summary
Fields Modifier and Type Field Description static String
BACKSLASHESCAPE
static String[][]
DEFAULTTRANSTABLE
static String
ENTITYESCAPES
static String
hexchars
-
Constructor Summary
Constructors Constructor Description Escape()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description 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.static List<String>
backslashsplit(String s, char sep)
Split a string with respect to a separator character and taking backslashes into consideration.static String
backslashUnescape(String s)
Remove backslashed characters in a stringstatic String
bytes2hex(byte[] bytes)
static String
cleanString(String s)
Clean up a string: currently means: 1.static boolean
entitychar(char c)
static String
entityEscape(String s, String wrt)
Escape selected characters in a string using XML entitiesstatic String
entityUnescape(String s)
static String
entityUnescape(String s, String[][] translations)
static int
fromHex(char c)
static boolean
isHexDigit(char c)
static String
toHex(int i)
static String
urlDecode(String s)
static String
urlEncodeQuery(String s)
-
-
-
Field Detail
-
DEFAULTTRANSTABLE
public static final String[][] DEFAULTTRANSTABLE
-
BACKSLASHESCAPE
public static final String BACKSLASHESCAPE
- See Also:
- Constant Field Values
-
ENTITYESCAPES
public static final String ENTITYESCAPES
- See Also:
- Constant Field Values
-
hexchars
public static final String hexchars
- See Also:
- Constant Field Values
-
-
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 escapewrt
- which chars to escape- Returns:
- escaped string
-
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 escapewrt
- 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 splitsep
- 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)
-
-