edu.isi.pegasus.planner.code.generator.condor
public class CondorQuoteParser extends Object
The following Condor Quoting Rules are followed while quoting a String.
1) \' => '' e.g \'Test\' is converted to ''Test'' 2) \" => "" e.g \"Test\" is converted to ""Test"" 3) ' => ' if not enclosed in surrounding double quotes e.g 'Test' is converted to 'Test' 4) ' => '' if enclosed in surrounding double quotes e.g "'Test'" is converted to ''Test'' 5) " => ' if not enclosed in surrounding single quotes e.g Karan "Vahi" is converted to Karan 'Vahi' 6) " => "" if enclosed in surrounding single quotes. e.g 'Karan "Vahi"' is converted to 'Karan ""Vahi""'. 7) * => * if enclosed in single or double quotes, the enclosed characters are copied literally including \ (no escaping rules apply) 8) \\ => \ escaping rules apply if not enclosed in single or double quotes. e.g \\\\ becomes \\, and \\\ throws error.In order to pass \n etc in the arguments, either quote it or escape it. for e.g in the DAX the following are valid ways to pass Karan\nVahi to the as arguments
1) "Karan\nVahi" 2) 'Karan\nVahi' 3) Karan\\nVahiIn addition while writing out to the SubmitFile the whole argument String should be in enclosing ". for e.g arguments = "Test";
Modifier and Type | Field and Description |
---|---|
private static byte[][] |
cAction
There are five identified actions.
|
private static byte[][] |
cState
Table to contain the state transition diagram for the parser.
|
Constructor and Description |
---|
CondorQuoteParser() |
Modifier and Type | Method and Description |
---|---|
static void |
main(String[] args)
A Test program.
|
static String |
quote(String s)
Parses a string and condor quotes it.
|
static String |
quote(String s,
boolean enclose)
Parses a string and condor quotes it.
|
private static void |
test(String s)
Helper test method that tries and catches exception
|
private static final byte[][] cState
| EOS | \ | ' | " |other| | 0 | 1 | 2 | 3 | 4 | -----+-----+-----+-----+-----+-----+ 0 | -,F | -,1| A2,2| A2,3| A1,0| 1 | -,E1| A1,0| A3,0| A4,0| A1,0| 2 | -,E2| A1,2| A2,0| A4,2| A1,2| 3 | -,E3| A1,3| A3,3| A2,0| A1,3| -----+-----+-----+-----+-----+-----+ F | 4 | final state E1 | 5 | error1: unexpected end of input E2 | 6 | error2: unmatched single quotes E3 | 7 | error3: unmatched double quotesThe state variable collects the new state for a given state (rows) and input character set (column) identifier.
private static final byte[][] cAction
- | 0 | noop A1 | 1 | append input character to result A2 | 2 | append ' to result A3 | 3 | append '' to result A4 | 4 | append "" to resultThe action variable collects the action to take for a given state (rows) and input character set (column).
public static String quote(String s) throws CondorQuoteParserException
s
- is the input string to parse and quote.CondorQuoteParserException
- if the input cannot be recognized.public static String quote(String s, boolean enclose) throws CondorQuoteParserException
s
- is the input string to parse and quote.enclose
- boolean indicating whether to generate enclosing quotes or
not.CondorQuoteParserException
- if the input cannot be recognized.public static void main(String[] args)
private static void test(String s)
s
- the string to be parsed.