OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ai.heavy.jdbc.HeavyAIEscapeParser.EscapeFunctions Enum Reference
+ Collaboration diagram for ai.heavy.jdbc.HeavyAIEscapeParser.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 HeavyAIEscapeParser.java.

Constructor & Destructor Documentation

ai.heavy.jdbc.HeavyAIEscapeParser.EscapeFunctions.EscapeFunctions ( String  escapePattern,
String  argPattern,
String  replacementKeyword 
)
inline

Definition at line 22 of file HeavyAIEscapeParser.java.

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

Member Function Documentation

String ai.heavy.jdbc.HeavyAIEscapeParser.EscapeFunctions.call_escape_fn ( String  all_arguments,
Method  method 
)
inlineprivate

Definition at line 32 of file HeavyAIEscapeParser.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 ai.heavy.jdbc.HeavyAIEscapeParser.EscapeFunctions.function ( String  arg)
inlinestatic

Definition at line 92 of file HeavyAIEscapeParser.java.

92  {
93  return arg;
94  }
String ai.heavy.jdbc.HeavyAIEscapeParser.EscapeFunctions.makeMatch ( String  sql)
inlineprivate

Definition at line 62 of file HeavyAIEscapeParser.java.

References ai.heavy.jdbc.HeavyAIEscapeParser.EscapeFunctions.ESC_DATE, ai.heavy.jdbc.HeavyAIEscapeParser.EscapeFunctions.ESC_FUNCTION, ai.heavy.jdbc.HeavyAIEscapeParser.EscapeFunctions.ESC_TIME, and ai.heavy.jdbc.HeavyAIEscapeParser.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 = HeavyAIEscapeFunctions.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 ai.heavy.jdbc.HeavyAIEscapeParser.EscapeFunctions.simple ( String  arg)
inlinestatic

Definition at line 88 of file HeavyAIEscapeParser.java.

88  {
89  return arg;
90  }

Member Data Documentation

final Pattern ai.heavy.jdbc.HeavyAIEscapeParser.EscapeFunctions.argPattern
private

Definition at line 29 of file HeavyAIEscapeParser.java.

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

Definition at line 28 of file HeavyAIEscapeParser.java.

final String ai.heavy.jdbc.HeavyAIEscapeParser.EscapeFunctions.replacementKeyword
private

Definition at line 30 of file HeavyAIEscapeParser.java.


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