当前位置: 首页>>代码示例>>Java>>正文


Java DTIType类代码示例

本文整理汇总了Java中org.hsqldb.types.DTIType的典型用法代码示例。如果您正苦于以下问题:Java DTIType类的具体用法?Java DTIType怎么用?Java DTIType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DTIType类属于org.hsqldb.types包,在下文中一共展示了DTIType类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTruncatedPart

import org.hsqldb.types.DTIType; //导入依赖的package包/类
/**
 * truncates millisecond date object
 */
public static long getTruncatedPart(long m, int part) {

    synchronized (tempCalGMT) {
        tempCalGMT.setTimeInMillis(m);

        switch (part) {

            case DTIType.WEEK_OF_YEAR : {
                int dayWeek = tempCalGMT.get(Calendar.DAY_OF_WEEK);

                tempCalGMT.add(Calendar.DAY_OF_YEAR, 1 - dayWeek);
                resetToDate(tempCalGMT);

                break;
            }
            default : {
                zeroFromPart(tempCalGMT, part);

                break;
            }
        }

        return tempCalGMT.getTimeInMillis();
    }
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:29,代码来源:HsqlDateTime.java

示例2: newInterval

import org.hsqldb.types.DTIType; //导入依赖的package包/类
public Object newInterval(String s, IntervalType type) {

        intervalPosition  = 0;
        fractionPrecision = 0;
        intervalString    = s;

        boolean negate   = scanIntervalSign();
        long    units    = scanIntervalValue(type);
        int     fraction = 0;

        if (type.endIntervalType == Types.SQL_INTERVAL_SECOND) {
            fraction = scanIntervalFraction(type.scale);
        }

        if (intervalPosition != s.length()) {
            throw Error.error(ErrorCode.X_22006);
        }

        if (negate) {
            units    = -units;
            fraction = -fraction;
        }

        dateTimeType = type;

        if (type.defaultPrecision) {
            dateTimeType = IntervalType.getIntervalType(type.typeCode,
                    type.startIntervalType, type.endIntervalType,
                    intervalPrecision, fractionPrecision, false);
        }

        if (type.endPartIndex <= DTIType.INTERVAL_MONTH_INDEX) {
            return new IntervalMonthData(units);
        } else {
            return new IntervalSecondData(units, fraction);
        }
    }
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:38,代码来源:Scanner.java

示例3: newInterval

import org.hsqldb.types.DTIType; //导入依赖的package包/类
public Object newInterval(String s, IntervalType type) {

        intervalPosition = 0;
        intervalString   = s;

        boolean negate   = scanIntervalSign();
        long    units    = scanIntervalValue(type);
        int     fraction = 0;

        if (type.endIntervalType == Types.SQL_INTERVAL_SECOND) {
            fraction = scanIntervalFraction(type.scale);
        }

        if (intervalPosition != s.length()) {
            throw Error.error(ErrorCode.X_22006);
        }

        if (negate) {
            units    = -units;
            fraction = -fraction;
        }

        dateTimeType = type;

        if (type.defaultPrecision) {
            dateTimeType = IntervalType.getIntervalType(type.typeCode,
                    type.startIntervalType, type.endIntervalType,
                    intervalPrecision, fractionPrecision, false);
        }

        if (type.endPartIndex <= DTIType.INTERVAL_MONTH_INDEX) {
            return new IntervalMonthData(units);
        } else {
            return new IntervalSecondData(units, fraction);
        }
    }
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:37,代码来源:Scanner.java

示例4: getTruncatedPart

import org.hsqldb.types.DTIType; //导入依赖的package包/类
/**
 * truncates millisecond date object
 */
public static long getTruncatedPart(long m, int part) {

    synchronized (tempCalGMT) {
        tempCalGMT.setTimeInMillis(m);

        switch (part) {

            case DTIType.WEEK_OF_YEAR : {
                int year = tempCalGMT.get(Calendar.YEAR);
                int week = tempCalGMT.get(Calendar.WEEK_OF_YEAR);

                tempCalGMT.clear();
                tempCalGMT.set(Calendar.YEAR, year);
                tempCalGMT.set(Calendar.WEEK_OF_YEAR, week);

                break;
            }
            default : {
                zeroFromPart(tempCalGMT, part);

                break;
            }
        }

        return tempCalGMT.getTimeInMillis();
    }
}
 
开发者ID:RabadanLab,项目名称:Pegasus,代码行数:31,代码来源:HsqlDateTime.java

示例5: resolveTypesForPeriodPredicates

import org.hsqldb.types.DTIType; //导入依赖的package包/类
void resolveTypesForPeriodPredicates(Session session) {

        // convert CONTAINS right part if necessary
        if (nodes[RIGHT].nodes.length == 0) {
            Expression[] newNodes = new Expression[] {
                nodes[RIGHT], new ExpressionValue(null, nodes[RIGHT].dataType)
            };

            nodes[RIGHT] = new Expression(OpTypes.ROW, newNodes);

            nodes[RIGHT].resolveTypes(session, null);
        }

        // end convert
        if (nodes[LEFT].nodes[0].isUnresolvedParam()) {
            nodes[LEFT].nodes[0].dataType = nodes[RIGHT].nodes[0].dataType;
        }

        if (nodes[RIGHT].nodes[0].isUnresolvedParam()) {
            nodes[RIGHT].nodes[0].dataType = nodes[LEFT].nodes[0].dataType;
        }

        if (nodes[LEFT].nodes[0].dataType == null) {
            nodes[LEFT].nodes[0].dataType  = Type.SQL_TIMESTAMP;
            nodes[RIGHT].nodes[0].dataType = Type.SQL_TIMESTAMP;
        }

        if (nodes[LEFT].nodes[1].isUnresolvedParam()) {
            nodes[LEFT].nodes[1].dataType = nodes[RIGHT].nodes[0].dataType;
        }

        if (nodes[RIGHT].nodes[1].isUnresolvedParam()) {
            nodes[RIGHT].nodes[1].dataType = nodes[LEFT].nodes[0].dataType;
        }

        if (!DTIType.isValidDatetimeRange(nodes[LEFT].nodes[0].dataType,
                                          nodes[LEFT].nodes[1].dataType)) {
            throw Error.error(ErrorCode.X_42563);
        }

        if (!DTIType.isValidDatetimeRange(nodes[RIGHT].nodes[0].dataType,
                                          nodes[RIGHT].nodes[1].dataType)) {
            throw Error.error(ErrorCode.X_42563);
        }

        nodes[LEFT].nodeDataTypes[0]  = nodes[LEFT].nodes[0].dataType;
        nodes[LEFT].nodeDataTypes[1]  = nodes[LEFT].nodes[1].dataType;
        nodes[RIGHT].nodeDataTypes[0] = nodes[RIGHT].nodes[0].dataType;
        nodes[RIGHT].nodeDataTypes[1] = nodes[RIGHT].nodes[1].dataType;
    }
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:51,代码来源:ExpressionLogical.java

示例6: newTimestamp

import org.hsqldb.types.DTIType; //导入依赖的package包/类
/**
 * @todo 1.9.0 - review the following
 *      - misses nano fractions
 *      - misses displacement
 *      - doesn't allow single digit components
 */
public TimestampData newTimestamp(String s) {

    long    zoneSeconds = 0;
    long    seconds;
    int     fraction = 0;
    int     endIndex = s.length();
    boolean negate;
    boolean hasZone = false;

    intervalPosition  = 0;
    fractionPrecision = 0;
    dateTimeType      = null;
    intervalString    = s;

    scanDateParts(5);

    try {
        seconds = HsqlDateTime.getTimestampSeconds(s.substring(0,
                intervalPosition));
    } catch (Throwable e) {
        throw Error.error(ErrorCode.X_22007);
    }

    int position;

    fraction = scanIntervalFraction(DTIType.maxFractionPrecision);
    position = intervalPosition;
    negate   = scanIntervalSign();

    if (negate || position != intervalPosition) {
        zoneSeconds = scanIntervalValue(Type.SQL_INTERVAL_HOUR_TO_MINUTE);
        hasZone     = true;

        if (negate) {
            zoneSeconds = -zoneSeconds;
        }
    }

    if (zoneSeconds >= DTIType.yearToSecondFactors[2]
            || zoneSeconds > DTIType.timezoneSecondsLimit
            || -zoneSeconds > DTIType.timezoneSecondsLimit) {
        throw Error.error(ErrorCode.X_22009);
    }

    if (intervalPosition != endIndex) {
        throw Error.error(ErrorCode.X_22007);
    }

    int type = hasZone ? Types.SQL_TIMESTAMP_WITH_TIME_ZONE
                       : Types.SQL_TIMESTAMP;

    dateTimeType = DateTimeType.getDateTimeType(type, fractionPrecision);

    if (hasZone) {
        seconds -= zoneSeconds;
    }

    return new TimestampData(seconds, fraction, (int) zoneSeconds);
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:66,代码来源:Scanner.java

示例7: scanDateParts

import org.hsqldb.types.DTIType; //导入依赖的package包/类
void scanDateParts(int lastPart) {

        byte[]    separators    = DTIType.yearToSecondSeparators;
        int       i             = intervalPosition;
        final int firstPart     = 0;
        int       currentPart   = firstPart;
        int       currentDigits = 0;

        for (; currentPart <= lastPart; ) {
            boolean endOfPart = false;

            if (i == intervalString.length()) {
                if (currentPart == lastPart) {
                    endOfPart = true;
                } else {

                    // parts missing
                    throw Error.error(ErrorCode.X_22007);
                }
            } else {
                int character = intervalString.charAt(i);

                if (character >= '0' && character <= '9') {
                    currentDigits++;
                    i++;
                } else if (character == separators[currentPart]) {
                    endOfPart = true;

                    if (currentPart != lastPart) {
                        i++;
                    }
                } else if (currentPart == lastPart) {
                    endOfPart = true;
                } else {
                    throw Error.error(ErrorCode.X_22007);
                }
            }

            if (endOfPart) {
                if (currentPart == firstPart) {
                    if (currentDigits != 4) {
                        throw Error.error(ErrorCode.X_22007);
                    }
                } else {
                    if (currentDigits == 0 || currentDigits > 2) {
                        throw Error.error(ErrorCode.X_22007);
                    }
                }

                currentPart++;

                currentDigits = 0;

                if (i == intervalString.length()) {
                    break;
                }
            }
        }

        intervalPosition = i;
    }
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:62,代码来源:Scanner.java

示例8: newTime

import org.hsqldb.types.DTIType; //导入依赖的package包/类
public TimeData newTime(String s) {

        intervalPosition  = 0;
        fractionPrecision = 0;
        dateTimeType      = null;
        intervalString    = s;

        long    seconds = scanIntervalValue(Type.SQL_INTERVAL_HOUR_TO_SECOND);
        int     fraction = scanIntervalFraction(DTIType.maxFractionPrecision);
        long    zoneSeconds = 0;
        int     position    = intervalPosition;
        boolean hasZone     = false;
        boolean negate      = scanIntervalSign();

        if (position != intervalPosition) {
            zoneSeconds = scanIntervalValue(Type.SQL_INTERVAL_HOUR_TO_MINUTE);
            hasZone     = true;
        }

        if (intervalPosition != s.length()) {
            throw Error.error(ErrorCode.X_22009);
        }

        if (seconds >= DTIType.yearToSecondFactors[2]) {
            throw Error.error(ErrorCode.X_22008);
        }

        if (zoneSeconds > DTIType.timezoneSecondsLimit) {
            throw Error.error(ErrorCode.X_22009);
        }

        if (negate) {
            zoneSeconds = -zoneSeconds;
        }

        int type = hasZone ? Types.SQL_TIME_WITH_TIME_ZONE
                           : Types.SQL_TIME;

        dateTimeType = DateTimeType.getDateTimeType(type, fractionPrecision);

        if (hasZone) {
            seconds -= zoneSeconds;
        }

        return new TimeData((int) seconds, fraction, (int) zoneSeconds);
    }
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:47,代码来源:Scanner.java

示例9: scanIntervalFraction

import org.hsqldb.types.DTIType; //导入依赖的package包/类
int scanIntervalFraction(int decimalPrecision) {

        if (intervalPosition == intervalString.length()) {
            return 0;
        }

        if (intervalString.charAt(intervalPosition) != '.') {
            return 0;
        }

        intervalPosition++;

        int currentValue  = 0;
        int currentDigits = 0;

        for (; intervalPosition < intervalString.length(); ) {
            int character = intervalString.charAt(intervalPosition);

            if (character >= '0' && character <= '9') {
                int digit = character - '0';

                currentValue *= 10;
                currentValue += digit;

                intervalPosition++;
                currentDigits++;

                if (currentDigits == DTIType.maxFractionPrecision) {
                    break;
                }
            } else {
                break;
            }
        }

        fractionPrecision = currentDigits;
        currentValue      *= DTIType.nanoScaleFactors[currentDigits];
        currentValue = DTIType.normaliseFraction(currentValue,
                decimalPrecision);

        return currentValue;
    }
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:43,代码来源:Scanner.java

示例10: resolveTypesForOverlaps

import org.hsqldb.types.DTIType; //导入依赖的package包/类
void resolveTypesForOverlaps() {

        if (nodes[LEFT].nodes[0].isParam) {
            nodes[LEFT].nodes[0].dataType = nodes[RIGHT].nodes[0].dataType;
        }

        if (nodes[RIGHT].nodes[0].isParam) {
            nodes[RIGHT].nodes[0].dataType = nodes[LEFT].nodes[0].dataType;
        }

        if (nodes[LEFT].nodes[0].dataType == null) {
            nodes[LEFT].nodes[0].dataType = nodes[RIGHT].nodes[0].dataType =
                Type.SQL_TIMESTAMP;
        }

        if (nodes[LEFT].nodes[1].isParam) {
            nodes[LEFT].nodes[1].dataType = nodes[RIGHT].nodes[0].dataType;
        }

        if (nodes[RIGHT].nodes[1].isParam) {
            nodes[RIGHT].nodes[1].dataType = nodes[LEFT].nodes[0].dataType;
        }

        if (!DTIType
                .isValidDatetimeRange(nodes[LEFT].nodes[0]
                    .dataType, nodes[LEFT].nodes[1].dataType) || !DTIType
                        .isValidDatetimeRange(nodes[RIGHT].nodes[0]
                            .dataType, nodes[RIGHT].nodes[1].dataType)) {
            throw Error.error(ErrorCode.X_42565);
        }

        if (!DTIType.isValidDatetimeRange(nodes[LEFT].nodes[0].dataType,
                                          nodes[LEFT].nodes[1].dataType)) {
            throw Error.error(ErrorCode.X_42563);
        }

        nodes[LEFT].nodeDataTypes[0]  = nodes[LEFT].nodes[0].dataType;
        nodes[LEFT].nodeDataTypes[1]  = nodes[LEFT].nodes[1].dataType;
        nodes[RIGHT].nodeDataTypes[0] = nodes[RIGHT].nodes[0].dataType;
        nodes[RIGHT].nodeDataTypes[1] = nodes[RIGHT].nodes[1].dataType;
    }
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:42,代码来源:ExpressionLogical.java

示例11: scanDateParts

import org.hsqldb.types.DTIType; //导入依赖的package包/类
void scanDateParts(int lastPart) {

        byte[]    separators    = DTIType.yearToSecondSeparators;
        int       i             = intervalPosition;
        final int firstPart     = 0;
        int       currentPart   = firstPart;
        int       currentDigits = 0;

        for (; currentPart <= lastPart; ) {
            boolean endOfPart = false;

            if (i == intervalString.length()) {
                if (currentPart == lastPart) {
                    endOfPart = true;
                } else {

                    // parts missing
                    throw Error.error(ErrorCode.X_22007);
                }
            } else {
                int character = intervalString.charAt(i);

                if (character >= '0' && character <= '9') {
                    currentDigits++;
                    i++;
                } else if (character == separators[currentPart]) {
                    endOfPart = true;

                    if (currentPart != lastPart) {
                        i++;
                    }
                } else if (currentPart == lastPart) {
                    endOfPart = true;
                } else {
                    throw Error.error(ErrorCode.X_22007);
                }
            }

            if (endOfPart) {
                if (currentPart == firstPart) {
                    if (currentDigits != 4) {
                        throw Error.error(ErrorCode.X_22007);
                    }
                } else {
                    if (currentDigits != 2) {
                        throw Error.error(ErrorCode.X_22007);
                    }
                }

                currentPart++;

                currentDigits = 0;

                if (i == intervalString.length()) {
                    break;
                }
            }
        }

        intervalPosition = i;
    }
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:62,代码来源:Scanner.java

示例12: resolveTypesForOverlaps

import org.hsqldb.types.DTIType; //导入依赖的package包/类
void resolveTypesForOverlaps() {

        if (nodes[LEFT].nodes[0].isUnresolvedParam()) {
            nodes[LEFT].nodes[0].dataType = nodes[RIGHT].nodes[0].dataType;
        }

        if (nodes[RIGHT].nodes[0].isUnresolvedParam()) {
            nodes[RIGHT].nodes[0].dataType = nodes[LEFT].nodes[0].dataType;
        }

        if (nodes[LEFT].nodes[0].dataType == null) {
            nodes[LEFT].nodes[0].dataType  = Type.SQL_TIMESTAMP;
            nodes[RIGHT].nodes[0].dataType = Type.SQL_TIMESTAMP;
        }

        if (nodes[LEFT].nodes[1].isUnresolvedParam()) {
            nodes[LEFT].nodes[1].dataType = nodes[RIGHT].nodes[0].dataType;
        }

        if (nodes[RIGHT].nodes[1].isUnresolvedParam()) {
            nodes[RIGHT].nodes[1].dataType = nodes[LEFT].nodes[0].dataType;
        }

        if (!DTIType
                .isValidDatetimeRange(nodes[LEFT].nodes[0]
                    .dataType, nodes[LEFT].nodes[1].dataType) || !DTIType
                        .isValidDatetimeRange(nodes[RIGHT].nodes[0]
                            .dataType, nodes[RIGHT].nodes[1].dataType)) {
            throw Error.error(ErrorCode.X_42563);
        }

        if (!DTIType.isValidDatetimeRange(nodes[LEFT].nodes[0].dataType,
                                          nodes[LEFT].nodes[1].dataType)) {
            throw Error.error(ErrorCode.X_42563);
        }

        nodes[LEFT].nodeDataTypes[0]  = nodes[LEFT].nodes[0].dataType;
        nodes[LEFT].nodeDataTypes[1]  = nodes[LEFT].nodes[1].dataType;
        nodes[RIGHT].nodeDataTypes[0] = nodes[RIGHT].nodes[0].dataType;
        nodes[RIGHT].nodeDataTypes[1] = nodes[RIGHT].nodes[1].dataType;
    }
 
开发者ID:Julien35,项目名称:dev-courses,代码行数:42,代码来源:ExpressionLogical.java

示例13: resolveTypesForOverlaps

import org.hsqldb.types.DTIType; //导入依赖的package包/类
void resolveTypesForOverlaps() {

        if (nodes[LEFT].nodes[0].isUnresolvedParam()) {
            nodes[LEFT].nodes[0].dataType = nodes[RIGHT].nodes[0].dataType;
        }

        if (nodes[RIGHT].nodes[0].isUnresolvedParam()) {
            nodes[RIGHT].nodes[0].dataType = nodes[LEFT].nodes[0].dataType;
        }

        if (nodes[LEFT].nodes[0].dataType == null) {
            nodes[LEFT].nodes[0].dataType = nodes[RIGHT].nodes[0].dataType =
                Type.SQL_TIMESTAMP;
        }

        if (nodes[LEFT].nodes[1].isUnresolvedParam()) {
            nodes[LEFT].nodes[1].dataType = nodes[RIGHT].nodes[0].dataType;
        }

        if (nodes[RIGHT].nodes[1].isUnresolvedParam()) {
            nodes[RIGHT].nodes[1].dataType = nodes[LEFT].nodes[0].dataType;
        }

        if (!DTIType
                .isValidDatetimeRange(nodes[LEFT].nodes[0]
                    .dataType, nodes[LEFT].nodes[1].dataType) || !DTIType
                        .isValidDatetimeRange(nodes[RIGHT].nodes[0]
                            .dataType, nodes[RIGHT].nodes[1].dataType)) {
            throw Error.error(ErrorCode.X_42563);
        }

        if (!DTIType.isValidDatetimeRange(nodes[LEFT].nodes[0].dataType,
                                          nodes[LEFT].nodes[1].dataType)) {
            throw Error.error(ErrorCode.X_42563);
        }

        nodes[LEFT].nodeDataTypes[0]  = nodes[LEFT].nodes[0].dataType;
        nodes[LEFT].nodeDataTypes[1]  = nodes[LEFT].nodes[1].dataType;
        nodes[RIGHT].nodeDataTypes[0] = nodes[RIGHT].nodes[0].dataType;
        nodes[RIGHT].nodeDataTypes[1] = nodes[RIGHT].nodes[1].dataType;
    }
 
开发者ID:RabadanLab,项目名称:Pegasus,代码行数:42,代码来源:ExpressionLogical.java

示例14: getRoundedPart

import org.hsqldb.types.DTIType; //导入依赖的package包/类
/**
 * rounded millisecond date object
 */
public static long getRoundedPart(long m, int part) {

    synchronized (tempCalGMT) {
        tempCalGMT.setTimeInMillis(m);

        switch (part) {

            case Types.SQL_INTERVAL_YEAR :
                if (tempCalGMT.get(Calendar.MONTH) > 6) {
                    tempCalGMT.add(Calendar.YEAR, 1);
                }
                break;

            case Types.SQL_INTERVAL_MONTH :
                if (tempCalGMT.get(Calendar.DAY_OF_MONTH) > 15) {
                    tempCalGMT.add(Calendar.MONTH, 1);
                }
                break;

            case Types.SQL_INTERVAL_DAY :
                if (tempCalGMT.get(Calendar.HOUR_OF_DAY) > 11) {
                    tempCalGMT.add(Calendar.DAY_OF_MONTH, 1);
                }
                break;

            case Types.SQL_INTERVAL_HOUR :
                if (tempCalGMT.get(Calendar.MINUTE) > 29) {
                    tempCalGMT.add(Calendar.HOUR_OF_DAY, 1);
                }
                break;

            case Types.SQL_INTERVAL_MINUTE :
                if (tempCalGMT.get(Calendar.SECOND) > 29) {
                    tempCalGMT.add(Calendar.MINUTE, 1);
                }
                break;

            case Types.SQL_INTERVAL_SECOND :
                if (tempCalGMT.get(Calendar.MILLISECOND) > 499) {
                    tempCalGMT.add(Calendar.SECOND, 1);
                }
                break;

            case DTIType.WEEK_OF_YEAR : {
                int year = tempCalGMT.get(Calendar.YEAR);
                int week = tempCalGMT.get(Calendar.WEEK_OF_YEAR);
                int day  = tempCalGMT.get(Calendar.DAY_OF_WEEK);

                if (day > 3) {
                    week++;
                }

                tempCalGMT.clear();
                tempCalGMT.set(Calendar.YEAR, year);
                tempCalGMT.set(Calendar.WEEK_OF_YEAR, week);

                return tempCalGMT.getTimeInMillis();
            }
        }

        zeroFromPart(tempCalGMT, part);

        return tempCalGMT.getTimeInMillis();
    }
}
 
开发者ID:RabadanLab,项目名称:Pegasus,代码行数:69,代码来源:HsqlDateTime.java


注:本文中的org.hsqldb.types.DTIType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。