public class PegasusExitCodeEncode
extends java.lang.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 java.lang.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(java.lang.String escapable,
char escape)
Constructs arbitrary escaping rules.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
decode(java.lang.String s)
Transforms a given string by decoding all characters and unescaping where
required.
|
java.lang.String |
encode(java.lang.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(java.lang.String[] args)
Test program.
|
void |
test(java.lang.String s) |
private char mEscape
private java.lang.String mEscapable
private char mEncodeable
private char mEncode
public PegasusExitCodeEncode()
public PegasusExitCodeEncode(java.lang.String escapable,
char escape)
escapable - is the set of characters that require escapingescape - is the escape character itself.public java.lang.String encode(java.lang.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 java.lang.String decode(java.lang.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(java.lang.String s)
public static void main(java.lang.String[] args)
args - are command-line arguments