OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ai.heavy.jdbc.HeavyAIEscapeParser Class Reference

Classes

enum  EscapeFunctions
 
class  Pair
 
class  Parser_return
 

Static Public Member Functions

static String parse (String sql)
 

Static Private Member Functions

static String process_sql (String sql, Pair index)
 
static Parser_return parse (String sql, int bracket_cnt)
 

Static Private Attributes

static final char[] QUOTE_OR_ALPHABETIC_MARKER = {'\"', '0'}
 
static final char[] SINGLE_QUOTE = {'\''}
 

Detailed Description

Definition at line 10 of file HeavyAIEscapeParser.java.

Member Function Documentation

static String ai.heavy.jdbc.HeavyAIEscapeParser.parse ( String  sql)
inlinestatic

Definition at line 127 of file HeavyAIEscapeParser.java.

References ai.heavy.jdbc.HeavyAIEscapeParser.Parser_return.bracket_cnt.

Referenced by ai.heavy.jdbc.HeavyAIEscapeParser.parse().

127  {
128  Parser_return pR = parse(sql, 0);
129  if (pR.bracket_cnt != 0) {
130  throw new RuntimeException("Invalid java escape syntax - badly matched '}'");
131  }
132  return pR.sql_value;
133  }

+ Here is the caller graph for this function:

static Parser_return ai.heavy.jdbc.HeavyAIEscapeParser.parse ( String  sql,
int  bracket_cnt 
)
inlinestaticprivate

Definition at line 139 of file HeavyAIEscapeParser.java.

References ai.heavy.jdbc.HeavyAIEscapeParser.parse(), and ai.heavy.jdbc.HeavyAIEscapeParser.process_sql().

139  {
140  int index = 0;
141  boolean in_quote = false;
142 
143  do {
144  if (sql.charAt(index) == '\'') {
145  in_quote = !in_quote;
146  } else if (sql.charAt(index) == '{' && !in_quote) {
147  if (index + 1 == sql.length()) {
148  // What ever string we get should have had limit nnn
149  // added to the end and this test is veru unlikely
150  throw new RuntimeException("Invalid java escape syntax - badly matched '{'");
151  }
152  Parser_return pR = parse(sql.substring(index + 1), ++bracket_cnt);
153  bracket_cnt = pR.bracket_cnt;
154  String sql_snippet = pR.sql_value;
155  sql = sql.substring(0, index) + " " + sql_snippet;
156  index += pR.end_idx;
157  } else if (sql.charAt(index) == '}' && !in_quote) {
158  Pair ptr = new Pair(0);
159  ptr.end = index;
160  Parser_return pR = new Parser_return();
161  pR.sql_value = process_sql(sql, ptr);
162  pR.bracket_cnt = --bracket_cnt;
163  pR.end_idx = ptr.end + 1;
164  return pR;
165  }
166  index++;
167  } while (index < sql.length());
168  if (in_quote) {
169  throw new RuntimeException("Invalid java escape syntax - badly matched '''");
170  }
171 
172  Parser_return pR = new Parser_return();
173  pR.sql_value = sql;
174  pR.bracket_cnt = bracket_cnt;
175  pR.end_idx = sql.length();
176  return pR;
177  }
static String process_sql(String sql, Pair index)

+ Here is the call graph for this function:

static String ai.heavy.jdbc.HeavyAIEscapeParser.process_sql ( String  sql,
Pair  index 
)
inlinestaticprivate

Definition at line 105 of file HeavyAIEscapeParser.java.

References ai.heavy.jdbc.HeavyAIEscapeParser.Pair.end, and ai.heavy.jdbc.HeavyAIEscapeParser.Pair.start.

Referenced by ai.heavy.jdbc.HeavyAIEscapeParser.parse().

105  {
106  String value = sql.substring(index.start, index.end);
107 
108  boolean found_match = false;
109  for (EscapeFunctions xx : EscapeFunctions.values()) {
110  String newsql = xx.makeMatch(value);
111  if (newsql != null) {
112  sql = sql.substring(0, index.start) + newsql + " "
113  + sql.substring(index.end + 1, sql.length());
114  int x = newsql.length();
115  index.end = index.start + newsql.length();
116  found_match = true;
117  break;
118  }
119  }
120  if (!found_match) {
121  // it's an array. Prepend '{' here, because parser will remove the original brace.
122  sql = sql.substring(0, index.start) + "{" + sql.substring(index.start);
123  index.end += 1;
124  }
125  return sql;
126  }

+ Here is the caller graph for this function:

Member Data Documentation

final char [] ai.heavy.jdbc.HeavyAIEscapeParser.QUOTE_OR_ALPHABETIC_MARKER = {'\"', '0'}
staticprivate

Definition at line 11 of file HeavyAIEscapeParser.java.

final char [] ai.heavy.jdbc.HeavyAIEscapeParser.SINGLE_QUOTE = {'\''}
staticprivate

Definition at line 14 of file HeavyAIEscapeParser.java.


The documentation for this class was generated from the following file: