OmniSciDB  2e3a973ef4
com.omnisci.jdbc.OmniSciEscapeParser 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 OmniSciEscapeParser.java.

Member Function Documentation

◆ parse() [1/2]

static String com.omnisci.jdbc.OmniSciEscapeParser.parse ( String  sql)
inlinestatic

Definition at line 127 of file OmniSciEscapeParser.java.

References com.omnisci.jdbc.OmniSciEscapeParser.Parser_return.bracket_cnt, and com.omnisci.jdbc.OmniSciEscapeParser.Parser_return.sql_value.

Referenced by com.omnisci.jdbc.OmniSciStatement.executeQuery(), and com.omnisci.jdbc.OmniSciEscapeParser.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:

◆ parse() [2/2]

static Parser_return com.omnisci.jdbc.OmniSciEscapeParser.parse ( String  sql,
int  bracket_cnt 
)
inlinestaticprivate

Definition at line 139 of file OmniSciEscapeParser.java.

References com.omnisci.jdbc.OmniSciEscapeParser.Parser_return.bracket_cnt, com.omnisci.jdbc.OmniSciEscapeParser.Pair.end, com.omnisci.jdbc.OmniSciEscapeParser.Parser_return.end_idx, com.omnisci.jdbc.OmniSciEscapeParser.Pair.Pair(), com.omnisci.jdbc.OmniSciEscapeParser.parse(), com.omnisci.jdbc.OmniSciEscapeParser.process_sql(), and com.omnisci.jdbc.OmniSciEscapeParser.Parser_return.sql_value.

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:

◆ process_sql()

static String com.omnisci.jdbc.OmniSciEscapeParser.process_sql ( String  sql,
Pair  index 
)
inlinestaticprivate

Definition at line 105 of file OmniSciEscapeParser.java.

References com.omnisci.jdbc.OmniSciEscapeParser.Pair.end, and com.omnisci.jdbc.OmniSciEscapeParser.Pair.start.

Referenced by com.omnisci.jdbc.OmniSciEscapeParser.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

◆ QUOTE_OR_ALPHABETIC_MARKER

final char [] com.omnisci.jdbc.OmniSciEscapeParser.QUOTE_OR_ALPHABETIC_MARKER = {'\"', '0'}
staticprivate

Definition at line 11 of file OmniSciEscapeParser.java.

◆ SINGLE_QUOTE

final char [] com.omnisci.jdbc.OmniSciEscapeParser.SINGLE_QUOTE = {'\''}
staticprivate

Definition at line 14 of file OmniSciEscapeParser.java.


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