edu.isi.pegasus.planner.code.gridstart

## Class PegasusExitCodeEncode

- java.lang.Object
- - edu.isi.pegasus.planner.code.gridstart.PegasusExitCodeEncode

    public class PegasusExitCodeEncode
    extends java.lang.Object

This class tries to define a mechanism to encode arguments for pegasus-exitcode, as DAGMan does not handle whitespaces correctly for postscript arguments. The default rules are single space gets encoded to + + gets escaped to \+ non printing asci characters are flagged here are some examples of this encoding rule

     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

Version:
  $Revision$
Author:
  Karan Vahi

### Field Summary

Fields
`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 Summary

Constructors
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.

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`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)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### mEscape

    private char mEscape

Defines the character used to escape characters.

#### mEscapable

    private java.lang.String mEscapable

Defines the set of characters that require escaping.

#### mEncodeable

    private char mEncodeable

Defines the character that requires encoding

#### mEncode

    private char mEncode

The value to encode to

### Constructor Detail

#### PegasusExitCodeEncode

    public PegasusExitCodeEncode()

Defines the default encoding rules escape + with \+ encode single whitespace with +

#### PegasusExitCodeEncode

    public PegasusExitCodeEncode(java.lang.String escapable,
                                 char escape)

Constructs arbitrary escaping rules.

Parameters:
  `escapable` - is the set of characters that require escaping
  `escape` - is the escape character itself.

### Method Detail

#### encode

    public 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

     error message is encoded to error+message
     error +message is encoded to error+\+message
     <>

Parameters:
  `s` - is the string to encode.
Returns:
  the encoded string
See Also:
  `#unescape( String )`

#### decode

    public java.lang.String decode(java.lang.String s)

Transforms a given string by decoding all characters and unescaping where required.

Parameters:
  `s` - is the string to remove escapes from.
Returns:
  the decoded string

#### isAsciiPrintable

    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

Parameters:
  `ch` - the character to check
Returns:
  true if between 32 and 126 inclusive

#### test

    public void test(java.lang.String s)

#### main

    public static void main(java.lang.String[] args)

Test program.

Parameters:
  `args` - are command-line arguments