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


Java ArrayUtil.byteArrayToChars方法代码示例

本文整理汇总了Java中org.hsqldb.lib.ArrayUtil.byteArrayToChars方法的典型用法代码示例。如果您正苦于以下问题:Java ArrayUtil.byteArrayToChars方法的具体用法?Java ArrayUtil.byteArrayToChars怎么用?Java ArrayUtil.byteArrayToChars使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.hsqldb.lib.ArrayUtil的用法示例。


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

示例1: getChars

import org.hsqldb.lib.ArrayUtil; //导入方法依赖的package包/类
public Result getChars(long lobID, long offset, int length) {

        Result result;

        writeLock.lock();

        try {
            if (compressLobs || cryptLobs) {
                result = getBytesCompressed(lobID, offset * 2, length * 2,
                                            true);
            } else {
                result = getBytesNormal(lobID, offset * 2, length * 2);
            }
        } finally {
            writeLock.unlock();
        }

        if (result.isError()) {
            return result;
        }

        byte[] bytes = ((ResultLob) result).getByteArray();
        char[] chars = ArrayUtil.byteArrayToChars(bytes);

        return ResultLob.newLobGetCharsResponse(lobID, offset, chars);
    }
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:27,代码来源:LobManager.java

示例2: compareTextCompressed

import org.hsqldb.lib.ArrayUtil; //导入方法依赖的package包/类
private int compareTextCompressed(Collation collation, long aID,
                                  long bID) {

    long[][] aParts = getParts(aID, 0, Long.MAX_VALUE);
    long[][] bParts = getParts(bID, 0, Long.MAX_VALUE);

    for (int i = 0; i < aParts.length && i < bParts.length; i++) {
        int aPartLength = (int) aParts[i][ALLOC_PART.PART_LENGTH];

        getPartBytesCompressedInBuffer(aID, aParts[i], true);

        String aString = new String(ArrayUtil.byteArrayToChars(dataBuffer,
            aPartLength));
        int bPartLength = (int) bParts[i][ALLOC_PART.PART_LENGTH];

        getPartBytesCompressedInBuffer(bID, bParts[i], true);

        String bString = new String(ArrayUtil.byteArrayToChars(dataBuffer,
            bPartLength));
        int diff = collation.compare(aString, bString);

        if (diff != 0) {
            return diff;
        }
    }

    if (aParts.length == bParts.length) {
        return 0;
    }

    return aParts.length > bParts.length ? 1
                                         : -1;
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:34,代码来源:LobManager.java

示例3: compare

import org.hsqldb.lib.ArrayUtil; //导入方法依赖的package包/类
/** @todo - implement as compareText() */
public int compare(Collation collation, ClobData a, String b) {

    writeLock.lock();

    try {
        Object[] data    = getLobHeader(a.getId());
        long     aLength = ((Long) data[LOB_IDS.LOB_LENGTH]).longValue();
        int[][] aAddresses = getBlockAddresses(a.getId(), 0,
                                               Integer.MAX_VALUE);
        int aIndex  = 0;
        int bOffset = 0;
        int aOffset = 0;

        if (aLength == 0) {
            return b.length() == 0 ? 0
                                   : -1;
        }

        if (b.length() == 0) {
            return 1;
        }

        while (true) {
            int aBlockOffset = aAddresses[aIndex][LOBS.BLOCK_ADDR]
                               + aOffset;
            byte[] aBytes = getLobStore().getBlockBytes(aBlockOffset, 1);
            long aLimit =
                aLength
                - ((long) aAddresses[aIndex][LOBS.BLOCK_OFFSET] + aOffset)
                  * lobBlockSize / 2;

            if (aLimit > lobBlockSize / 2) {
                aLimit = lobBlockSize / 2;
            }

            String aString = new String(ArrayUtil.byteArrayToChars(aBytes),
                                        0, (int) aLimit);
            int bLimit = b.length() - bOffset;

            if (bLimit > lobBlockSize / 2) {
                bLimit = lobBlockSize / 2;
            }

            String bString = b.substring(bOffset, bOffset + bLimit);
            int    diff    = collation.compare(aString, bString);

            if (diff != 0) {
                return diff;
            }

            aOffset++;

            bOffset += lobBlockSize / 2;

            if (aOffset == aAddresses[aIndex][LOBS.BLOCK_COUNT]) {
                aOffset = 0;

                aIndex++;
            }

            if (aIndex == aAddresses.length) {
                break;
            }

            if (bOffset >= b.length()) {
                break;
            }
        }

        if (aLength == b.length()) {
            return 0;
        }

        return aLength > b.length() ? 1
                                    : -1;
    } finally {
        writeLock.unlock();
    }
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:81,代码来源:LobManager.java


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