/** * Converts the contents of an sql quoted string literal into the * corresponding Java string representation (removing leading and trailing * quotes and unescaping internal doubled quotes). */ public static String parseString(String s) { int i = s.indexOf("'"); // start of body if (i > 0) { s = s.substring(i); } return strip(s, "'", "'", "''", Casing.UNCHANGED); }
/** * Converts the contents of an sql quoted string literal into the * corresponding Java string representation (removing leading and trailing * quotes and unescaping internal doubled quotes). */ public static String parseString(String s) { int i = s.indexOf("'"); // start of body if (i > 0) { s = s.substring(i); } return strip(s, "'"); }
String unquotedIdentifier() throws ParseException { return SqlParserUtil.strip(getToken(0).image, null, null, null, unquotedCasing); }
SqlIntervalLiteral parseIntervalLiteral(SqlParserPos pos, int sign, String s, SqlIntervalQualifier intervalQualifier) throws ParseException, ParseException { String intervalStr = SqlParserUtil.strip(s, "'"); if ("".equals(intervalStr)) { EigenbaseResource res = EigenbaseResource.instance(); String msg = res.IllegalIntervalLiteral.str( s + " " + intervalQualifier.toString(), pos.toString()); throw new ParseException(msg); } return SqlLiteral.createInterval(sign, intervalStr, intervalQualifier, pos); }
SqlDateLiteral parseDateLiteral(String s, SqlParserPos pos) throws ParseException { String dateStr = SqlParserUtil.strip(s, "'"); Calendar cal = DateTimeUtil.parseDateFormat( dateStr, DateTimeUtil.DateFormatStr, DateTimeUtil.gmtZone); if (null == cal) { EigenbaseResource res = EigenbaseResource.instance(); throw SqlUtil.newContextException( pos, res.IllegalLiteral.ex( "DATE", s, res.BadFormat.str(DateTimeUtil.DateFormatStr))); } return SqlLiteral.createDate(cal, pos); }
SqlTimeLiteral parseTimeLiteral(String s, SqlParserPos pos) throws ParseException { String dateStr = SqlParserUtil.strip(s, "'"); DateTimeUtil.PrecisionTime pt = DateTimeUtil.parsePrecisionDateTimeLiteral( dateStr, DateTimeUtil.TimeFormatStr, DateTimeUtil.gmtZone); if (null == pt) { EigenbaseResource res = EigenbaseResource.instance(); throw SqlUtil.newContextException( pos, res.IllegalLiteral.ex( "TIME", s, res.BadFormat.str(DateTimeUtil.TimeFormatStr))); } return SqlLiteral.createTime(pt.getCalendar(), pt.getPrecision(), pos); }
SqlTimestampLiteral parseTimestampLiteral(String s, SqlParserPos pos) throws ParseException { String dateStr = SqlParserUtil.strip(s, "'"); DateTimeUtil.PrecisionTime pt = DateTimeUtil.parsePrecisionDateTimeLiteral( dateStr, DateTimeUtil.TimestampFormatStr, DateTimeUtil.gmtZone); if (null == pt) { EigenbaseResource res = EigenbaseResource.instance(); throw SqlUtil.newContextException( pos, res.IllegalLiteral.ex( "TIMESTAMP", s, res.BadFormat.str(DateTimeUtil.TimestampFormatStr))); } return SqlLiteral.createTimestamp(pt.getCalendar(), pt.getPrecision(), pos); }
} else if (jj_2_267(2)) { jj_consume_token(QUOTED_IDENTIFIER); id = SqlParserUtil.strip(getToken(0).image, DQ, DQ, DQDQ, quotedCasing); } else if (jj_2_268(2)) { jj_consume_token(BACK_QUOTED_IDENTIFIER); id = SqlParserUtil.strip(getToken(0).image, "`", "`", "``", quotedCasing); } else if (jj_2_269(2)) { jj_consume_token(BRACKET_QUOTED_IDENTIFIER); id = SqlParserUtil.strip(getToken(0).image, "[", "]", "]]", quotedCasing); } else if (jj_2_270(2)) { id = getToken(0).image; id = id.substring(id.indexOf('"')); id = SqlParserUtil.strip(id, DQ, DQ, DQDQ, quotedCasing); if (jj_2_265(2)) { jj_consume_token(UESCAPE);
} else if (jj_2_258(2)) { jj_consume_token(QUOTED_IDENTIFIER); id = SqlParserUtil.strip(getToken(0).image, DOUBLE_QUOTE + ""); } else if (jj_2_259(2)) { jj_consume_token(UNICODE_QUOTED_IDENTIFIER); id = getToken(0).image; id = id.substring(id.indexOf(DOUBLE_QUOTE)); id = SqlParserUtil.strip(id, DOUBLE_QUOTE + ""); if (jj_2_256(2)) { jj_consume_token(UESCAPE);