OmniSciDB  95562058bd
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
com.omnisci.jdbc.OmniSciEscapeParser.EscapeFunctions Enum Reference
+ Collaboration diagram for com.omnisci.jdbc.OmniSciEscapeParser.EscapeFunctions:

Public Member Functions

 EscapeFunctions (String escapePattern, String argPattern, String replacementKeyword)
 

Static Public Member Functions

static String simple (String arg)
 
static String function (String arg)
 

Public Attributes

 ESC_FUNCTION =("\\s*fn\\s+([^ ]*?)\\s*\\(", "\\(\\s*(.*)\\s*\\)", null)
 
 ESC_DATE =("\\s*(d)\\s+", "('.*?')", "DATE ")
 
 ESC_TIME =("\\s*(t)\\s+", "('.*?')", "TIME ")
 
 ESC_TIMESTAMP =("\\s*(ts)\\s+", "('.*?')", "TIMESTAMP ")
 

Private Member Functions

String call_escape_fn (String all_arguments, Method method)
 
String makeMatch (String sql)
 

Private Attributes

final Pattern escapePattern
 
final Pattern argPattern
 
final String replacementKeyword
 

Detailed Description

Definition at line 16 of file OmniSciEscapeParser.java.

Constructor & Destructor Documentation

com.omnisci.jdbc.OmniSciEscapeParser.EscapeFunctions.EscapeFunctions ( String  escapePattern,
String  argPattern,
String  replacementKeyword 
)
inline

Definition at line 22 of file OmniSciEscapeParser.java.

22  {
23  this.escapePattern = Pattern.compile(escapePattern);
24  this.argPattern = Pattern.compile(argPattern);
25  this.replacementKeyword = replacementKeyword;
26  }

Member Function Documentation

String com.omnisci.jdbc.OmniSciEscapeParser.EscapeFunctions.call_escape_fn ( String  all_arguments,
Method  method 
)
inlineprivate

Definition at line 32 of file OmniSciEscapeParser.java.

32  {
33  try {
34  StringBuilder sb = new StringBuilder();
35  List<CharSequence> parseArgs = new ArrayList<CharSequence>(3);
36  int bracket_cnt = 0;
37  StringBuilder args_sb = new StringBuilder();
38  for (int index = 0; index < all_arguments.length(); ++index) {
39  if (all_arguments.charAt(index) == ',' && bracket_cnt == 0) {
40  parseArgs.add(args_sb.toString());
41  args_sb.delete(0, args_sb.length());
42  continue;
43  }
44  if (all_arguments.charAt(index) == '(') {
45  bracket_cnt++;
46  } else if (all_arguments.charAt(index) == ')') {
47  bracket_cnt--;
48  }
49  args_sb.append(all_arguments.charAt(index));
50  }
51  // add the last argument.
52  parseArgs.add(args_sb.toString());
53  method.invoke(null, sb, parseArgs);
54  return sb.toString();
55  } catch (InvocationTargetException e) {
56  throw new RuntimeException("Invocation fn argument parse error" + e.getMessage());
57  } catch (IllegalAccessException ilE) {
58  throw new RuntimeException("Access fn argument error" + ilE.getMessage());
59  }
60  }
static String com.omnisci.jdbc.OmniSciEscapeParser.EscapeFunctions.function ( String  arg)
inlinestatic

Definition at line 92 of file OmniSciEscapeParser.java.

92  {
93  return arg;
94  }
String com.omnisci.jdbc.OmniSciEscapeParser.EscapeFunctions.makeMatch ( String  sql)
inlineprivate

Definition at line 62 of file OmniSciEscapeParser.java.

References com.omnisci.jdbc.OmniSciEscapeParser.EscapeFunctions.ESC_DATE, com.omnisci.jdbc.OmniSciEscapeParser.EscapeFunctions.ESC_FUNCTION, com.omnisci.jdbc.OmniSciEscapeParser.EscapeFunctions.ESC_TIME, and com.omnisci.jdbc.OmniSciEscapeParser.EscapeFunctions.ESC_TIMESTAMP.

62  {
63  Matcher matcher = escapePattern.matcher(sql);
64  if (matcher.find()) {
65  if (this == EscapeFunctions.ESC_DATE || this == EscapeFunctions.ESC_TIME
66  || this == EscapeFunctions.ESC_TIMESTAMP) {
67  matcher = argPattern.matcher(sql);
68  if (matcher.find()) {
69  String new_sql = this.replacementKeyword + matcher.group(1);
70  return new_sql;
71  }
72  } else if (this == EscapeFunctions.ESC_FUNCTION) {
73  String fn_name = matcher.group(1);
74  Method method = OmniSciEscapeFunctions.getFunction(fn_name);
75  matcher = argPattern.matcher(sql);
76  if (matcher.find()) {
77  if (method == null) {
78  String new_sql = fn_name + '(' + matcher.group(1) + ')';
79  return new_sql;
80  } else {
81  return call_escape_fn(matcher.group(1), method);
82  }
83  }
84  }
85  }
86  return null;
87  }
String call_escape_fn(String all_arguments, Method method)
EscapeFunctions(String escapePattern, String argPattern, String replacementKeyword)
static String com.omnisci.jdbc.OmniSciEscapeParser.EscapeFunctions.simple ( String  arg)
inlinestatic

Definition at line 88 of file OmniSciEscapeParser.java.

88  {
89  return arg;
90  }

Member Data Documentation

final Pattern com.omnisci.jdbc.OmniSciEscapeParser.EscapeFunctions.argPattern
private

Definition at line 29 of file OmniSciEscapeParser.java.

com.omnisci.jdbc.OmniSciEscapeParser.EscapeFunctions.ESC_DATE =("\\s*(d)\\s+", "('.*?')", "DATE ")
com.omnisci.jdbc.OmniSciEscapeParser.EscapeFunctions.ESC_FUNCTION =("\\s*fn\\s+([^ ]*?)\\s*\\(", "\\(\\s*(.*)\\s*\\)", null)
com.omnisci.jdbc.OmniSciEscapeParser.EscapeFunctions.ESC_TIME =("\\s*(t)\\s+", "('.*?')", "TIME ")
com.omnisci.jdbc.OmniSciEscapeParser.EscapeFunctions.ESC_TIMESTAMP =("\\s*(ts)\\s+", "('.*?')", "TIMESTAMP ")
final Pattern com.omnisci.jdbc.OmniSciEscapeParser.EscapeFunctions.escapePattern
private

Definition at line 28 of file OmniSciEscapeParser.java.

final String com.omnisci.jdbc.OmniSciEscapeParser.EscapeFunctions.replacementKeyword
private

Definition at line 30 of file OmniSciEscapeParser.java.


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