OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HeavySqlSanitizedString.java
Go to the documentation of this file.
1 package com.mapd.parser.extension.ddl.heavysql;
2 
3 import org.apache.calcite.sql.SqlNode;
4 
5 public class HeavySqlSanitizedString {
6  private String string;
7 
8  public HeavySqlSanitizedString(final String s) {
9  this.string = sanitizeString(s);
10  }
11 
12  public HeavySqlSanitizedString(final SqlNode node) {
13  this.string = sanitizeString(node.toString());
14  }
15 
16  private String sanitizeString(final String s) {
17  String sanitized_s = s;
18  if (s.startsWith("'") && s.endsWith("'")) {
19  sanitized_s = s.substring(1, s.length() - 1);
20  } else if (s.startsWith("\"") && s.endsWith("\"")) {
21  sanitized_s = s.substring(1, s.length() - 1);
22  }
23  sanitized_s = sanitized_s.replace("''", "'");
24  return sanitized_s;
25  }
26 
27  @Override
28  public String toString() {
29  return string;
30  }
31 }