public void validate(EnumSet<Validation> validations) { final ResourceBundle bundle = bundle(); for (Validation validation : validations) { switch (validation) { case EVEN_QUOTES: String message = method.getAnnotation(BaseMessage.class).value(); if (countQuotesIn(message) % 2 == 1) { throw new AssertionError("resource '" + method.getName() + "' should have even number of quotes"); String raw = raw(); MessageFormat format = new MessageFormat(raw); final Format[] formats = format.getFormatsByArgumentIndex();
inst.validate(validations); } catch (IllegalAccessException e) { throw new RuntimeException("in " + method, e);
public void validate(EnumSet<Validation> validations) { final ResourceBundle bundle = bundle(); for (Validation validation : validations) { switch (validation) { case EVEN_QUOTES: String message = method.getAnnotation(BaseMessage.class).value(); if (countQuotesIn(message) % 2 == 1) { throw new AssertionError("resource '" + method.getName() + "' should have even number of quotes"); String raw = raw(); MessageFormat format = new MessageFormat(raw); final Format[] formats = format.getFormatsByArgumentIndex();
inst.validate(validations); } catch (IllegalAccessException e) { throw new RuntimeException("in " + method, e);
public static SqlTimestampLiteral parseTimestampLiteral(String s, SqlParserPos pos) { final String dateStr = parseString(s); final DateTimeUtils.PrecisionTime pt = DateTimeUtils.parsePrecisionDateTimeLiteral(dateStr, Format.PER_THREAD.get().timestamp, DateTimeUtils.UTC_ZONE, -1); if (pt == null) { throw SqlUtil.newContextException(pos, RESOURCE.illegalLiteral("TIMESTAMP", s, RESOURCE.badFormat(DateTimeUtils.TIMESTAMP_FORMAT_STRING).str())); } final TimestampString ts = TimestampString.fromCalendarFields(pt.getCalendar()) .withFraction(pt.getFraction()); return SqlLiteral.createTimestamp(ts, pt.getPrecision(), pos); }
public static SqlTimeLiteral parseTimeLiteral(String s, SqlParserPos pos) { final String dateStr = parseString(s); final DateTimeUtils.PrecisionTime pt = DateTimeUtils.parsePrecisionDateTimeLiteral(dateStr, Format.PER_THREAD.get().time, DateTimeUtils.UTC_ZONE, -1); if (pt == null) { throw SqlUtil.newContextException(pos, RESOURCE.illegalLiteral("TIME", s, RESOURCE.badFormat(DateTimeUtils.TIME_FORMAT_STRING).str())); } final TimeString t = TimeString.fromCalendarFields(pt.getCalendar()) .withFraction(pt.getFraction()); return SqlLiteral.createTime(t, pt.getPrecision(), pos); }
@Override public String toString() { return RESOURCE.parserContext(lineNumber, columnNumber).str(); }
public static SqlTimestampLiteral parseTimestampLiteral(String s, SqlParserPos pos) { final String dateStr = parseString(s); final DateTimeUtils.PrecisionTime pt = DateTimeUtils.parsePrecisionDateTimeLiteral(dateStr, Format.PER_THREAD.get().timestamp, DateTimeUtils.UTC_ZONE, -1); if (pt == null) { throw SqlUtil.newContextException(pos, RESOURCE.illegalLiteral("TIMESTAMP", s, RESOURCE.badFormat(DateTimeUtils.TIMESTAMP_FORMAT_STRING).str())); } final TimestampString ts = TimestampString.fromCalendarFields(pt.getCalendar()) .withFraction(pt.getFraction()); return SqlLiteral.createTimestamp(ts, pt.getPrecision(), pos); }
SqlTimestampLiteral parseTimestampLiteral(String s, SqlParserPos pos) throws ParseException { String dateStr = SqlParserUtil.parseString(s); DateTimeUtils.PrecisionTime pt = DateTimeUtils.parsePrecisionDateTimeLiteral( dateStr, DateTimeUtils.TIMESTAMP_FORMAT_STRING, DateTimeUtils.GMT_ZONE); if (null == pt) { throw SqlUtil.newContextException(pos, RESOURCE.illegalLiteral("TIMESTAMP", s, RESOURCE.badFormat(DateTimeUtils.TIMESTAMP_FORMAT_STRING).str())); } return SqlLiteral.createTimestamp(pt.getCalendar(), pt.getPrecision(), pos); }
SqlTimeLiteral parseTimeLiteral(String s, SqlParserPos pos) throws ParseException { String dateStr = SqlParserUtil.parseString(s); DateTimeUtils.PrecisionTime pt = DateTimeUtils.parsePrecisionDateTimeLiteral( dateStr, DateTimeUtils.TIME_FORMAT_STRING, DateTimeUtils.GMT_ZONE); if (null == pt) { throw SqlUtil.newContextException(pos, RESOURCE.illegalLiteral("TIME", s, RESOURCE.badFormat(DateTimeUtils.TIME_FORMAT_STRING).str())); } return SqlLiteral.createTime(pt.getCalendar(), pt.getPrecision(), pos); }
public static SqlTimeLiteral parseTimeLiteral(String s, SqlParserPos pos) { final String dateStr = parseString(s); final DateTimeUtils.PrecisionTime pt = DateTimeUtils.parsePrecisionDateTimeLiteral(dateStr, Format.PER_THREAD.get().time, DateTimeUtils.UTC_ZONE, -1); if (pt == null) { throw SqlUtil.newContextException(pos, RESOURCE.illegalLiteral("TIME", s, RESOURCE.badFormat(DateTimeUtils.TIME_FORMAT_STRING).str())); } final TimeString t = TimeString.fromCalendarFields(pt.getCalendar()) .withFraction(pt.getFraction()); return SqlLiteral.createTime(t, pt.getPrecision(), pos); }
SqlTimeLiteral parseTimeLiteral(String s, SqlParserPos pos) throws ParseException { String dateStr = SqlParserUtil.parseString(s); DateTimeUtils.PrecisionTime pt = DateTimeUtils.parsePrecisionDateTimeLiteral( dateStr, DateTimeUtils.TIME_FORMAT_STRING, DateTimeUtils.GMT_ZONE); if (null == pt) { throw SqlUtil.newContextException(pos, RESOURCE.illegalLiteral("TIME", s, RESOURCE.badFormat(DateTimeUtils.TIME_FORMAT_STRING).str())); } return SqlLiteral.createTime(pt.getCalendar(), pt.getPrecision(), pos); }
SqlTimeLiteral parseTimeLiteral(String s, SqlParserPos pos) throws ParseException { String dateStr = SqlParserUtil.parseString(s); DateTimeUtils.PrecisionTime pt = DateTimeUtils.parsePrecisionDateTimeLiteral( dateStr, DateTimeUtils.TIME_FORMAT_STRING, DateTimeUtils.GMT_ZONE); if (null == pt) { throw SqlUtil.newContextException(pos, RESOURCE.illegalLiteral("TIME", s, RESOURCE.badFormat(DateTimeUtils.TIME_FORMAT_STRING).str())); } return SqlLiteral.createTime(pt.getCalendar(), pt.getPrecision(), pos); }
public String raw() { try { return bundle().getString(key); } catch (MissingResourceException e) { // Resource is not in the bundle. (It is probably missing from the // .properties file.) Fall back to the base message. return method.getAnnotation(BaseMessage.class).value(); } }
@Override public void validate(EnumSet<Validation> validations) { super.validate(validations); if (validations.contains(Validation.CREATE_EXCEPTION)) { validateException( new Callable<Exception>() { public Exception call() throws Exception { return ex(new NullPointerException("test")); } }); } } }
public Inst localize(Locale locale) { return new Inst(base, locale, method, args); }
public String raw() { try { return bundle().getString(key); } catch (MissingResourceException e) { // Resource is not in the bundle. (It is probably missing from the // .properties file.) Fall back to the base message. return method.getAnnotation(BaseMessage.class).value(); } }
public Inst localize(Locale locale) { return new Inst(base, locale, method, args); }
public static SqlDateLiteral parseDateLiteral(String s, SqlParserPos pos) { final String dateStr = parseString(s); final Calendar cal = DateTimeUtils.parseDateFormat(dateStr, Format.PER_THREAD.get().date, DateTimeUtils.UTC_ZONE); if (cal == null) { throw SqlUtil.newContextException(pos, RESOURCE.illegalLiteral("DATE", s, RESOURCE.badFormat(DateTimeUtils.DATE_FORMAT_STRING).str())); } final DateString d = DateString.fromCalendarFields(cal); return SqlLiteral.createDate(d, pos); }
public static SqlDateLiteral parseDateLiteral(String s, SqlParserPos pos) { final String dateStr = parseString(s); final Calendar cal = DateTimeUtils.parseDateFormat(dateStr, Format.PER_THREAD.get().date, DateTimeUtils.UTC_ZONE); if (cal == null) { throw SqlUtil.newContextException(pos, RESOURCE.illegalLiteral("DATE", s, RESOURCE.badFormat(DateTimeUtils.DATE_FORMAT_STRING).str())); } final DateString d = DateString.fromCalendarFields(cal); return SqlLiteral.createDate(d, pos); }