public class PegasusExitCodeEncode extends Object
Error Message is encoded to Error+Message Error Message is encoded to Error+++Message Error + Message is encoded to Error+\++Message Error + \Message is encoded to Error+\++\Message Error + Message\ is encoded to Error+\++Message\ Error + \\ Message is encoded to Error+\++\\+Message
Modifier and Type | Field and Description |
---|---|
private char |
mEncode
The value to encode to
|
private char |
mEncodeable
Defines the character that requires encoding
|
private String |
mEscapable
Defines the set of characters that require escaping.
|
private char |
mEscape
Defines the character used to escape characters.
|
Constructor and Description |
---|
PegasusExitCodeEncode()
Defines the default encoding rules
escape + with \+
encode single whitespace with +
|
PegasusExitCodeEncode(String escapable,
char escape)
Constructs arbitrary escaping rules.
|
Modifier and Type | Method and Description |
---|---|
String |
decode(String s)
Transforms a given string by decoding all characters and unescaping where
required.
|
String |
encode(String s)
Transforms a given string by encoding single whitespace with the escape
character set ( defaults to + ), and escapes the escape itself
|
boolean |
isAsciiPrintable(char ch)
Checks whether the character is ASCII 7 bit printable.
|
static void |
main(String[] args)
Test program.
|
void |
test(String s) |
private char mEscape
private String mEscapable
private char mEncodeable
private char mEncode
public PegasusExitCodeEncode()
public PegasusExitCodeEncode(String escapable, char escape)
escapable
- is the set of characters that require escapingescape
- is the escape character itself.public String encode(String s)
error message is encoded to error+message error +message is encoded to error+\+message <>
s
- is the string to encode.#unescape( String )
public String decode(String s)
s
- is the string to remove escapes from.public boolean isAsciiPrintable(char ch)
Checks whether the character is ASCII 7 bit printable.
CharUtils.isAsciiPrintable('a') = true CharUtils.isAsciiPrintable('A') = true CharUtils.isAsciiPrintable('3') = true CharUtils.isAsciiPrintable('-') = true CharUtils.isAsciiPrintable('\n') = false CharUtils.isAsciiPrintable('©') = false
ch
- the character to checkpublic void test(String s)
public static void main(String[] args)
args
- are command-line arguments