コード例 #1
0
 public static String computeTestName(
     final String toScan,
     final int dataType,
     final long precision,
     final int fractionalPrecision) {
   return "\""
       + toScan
       + "\", "
       + IntervalType.getIntervalType(dataType, precision, fractionalPrecision).getDefinition()
       + ", ("
       + precision
       + ","
       + fractionalPrecision
       + ")";
 }
コード例 #2
0
 @Override
 protected void runTest() throws Exception {
   IntervalType t = IntervalType.getIntervalType(m_dataType, m_precision, m_fractionalPrecision);
   Scanner scanner = new Scanner();
   Object i = scanner.convertToDatetimeInterval(null, m_toScan, t);
 }
コード例 #3
0
  IntervalType readIntervalType() {

    int precision = -1;
    int scale = -1;
    int startToken;
    int endToken;

    startToken = endToken = token.tokenType;

    read();

    if (token.tokenType == Tokens.OPENBRACKET) {
      read();

      precision = readInteger();

      if (precision <= 0) {
        throw Error.error(ErrorCode.X_42592);
      }

      if (token.tokenType == Tokens.COMMA) {
        if (startToken != Tokens.SECOND) {
          throw unexpectedToken();
        }

        read();

        scale = readInteger();

        if (scale < 0) {
          throw Error.error(ErrorCode.X_42592);
        }
      }

      readThis(Tokens.CLOSEBRACKET);
    }

    if (token.tokenType == Tokens.TO) {
      read();

      endToken = token.tokenType;

      read();
    }

    if (token.tokenType == Tokens.OPENBRACKET) {
      if (endToken != Tokens.SECOND || endToken == startToken) {
        throw unexpectedToken();
      }

      read();

      scale = readInteger();

      if (scale < 0) {
        throw Error.error(ErrorCode.X_42592);
      }

      readThis(Tokens.CLOSEBRACKET);
    }

    int startIndex = ArrayUtil.find(Tokens.SQL_INTERVAL_FIELD_CODES, startToken);
    int endIndex = ArrayUtil.find(Tokens.SQL_INTERVAL_FIELD_CODES, endToken);

    return IntervalType.getIntervalType(startIndex, endIndex, precision, scale);
  }