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


Java CoderResult.UNDERFLOW属性代码示例

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


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

示例1: decodeArrayLoop

private CoderResult decodeArrayLoop(ByteBuffer src, CharBuffer dst) {
    byte[] sa = src.array();
    int sp = src.arrayOffset() + src.position();
    int sl = src.arrayOffset() + src.limit();

    char[] da = dst.array();
    int dp = dst.arrayOffset() + dst.position();
    int dl = dst.arrayOffset() + dst.limit();

    CoderResult cr = CoderResult.UNDERFLOW;
    if ((dl - dp) < (sl - sp)) {
        sl = sp + (dl - dp);
        cr = CoderResult.OVERFLOW;
    }

    while (sp < sl) {
        char c = decode(sa[sp]);
        if (c == UNMAPPABLE_DECODING) {
            return withResult(CoderResult.unmappableForLength(1),
                       src, sp, dst, dp);
        }
        da[dp++] = c;
        sp++;
    }
    return withResult(cr, src, sp, dst, dp);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:SingleByte.java

示例2: decodeBufferLoop

private CoderResult decodeBufferLoop(ByteBuffer src,
                                     CharBuffer dst)
{
    int mark = src.position();
    try {
        while (src.hasRemaining()) {
            byte b = src.get();
            if (b >= 0) {
                if (!dst.hasRemaining())
                    return CoderResult.OVERFLOW;
                dst.put((char)b);
                mark++;
                continue;
            }
            return CoderResult.malformedForLength(1);
        }
        return CoderResult.UNDERFLOW;
    } finally {
        src.position(mark);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:US_ASCII.java

示例3: encodeBufferLoop

private CoderResult encodeBufferLoop(CharBuffer src, ByteBuffer dst) {
    int mark = src.position();
    try {
        while (src.hasRemaining()) {
            char c = src.get();
            int b = encode(c);
            if (b == UNMAPPABLE_ENCODING) {
                if (Character.isSurrogate(c)) {
                    if (sgp == null)
                        sgp = new Surrogate.Parser();
                    if (sgp.parse(c, src) < 0)
                        return sgp.error();
                    return sgp.unmappableResult();
                }
                return CoderResult.unmappableForLength(1);
            }
            if (!dst.hasRemaining())
                return CoderResult.OVERFLOW;
            dst.put((byte)b);
            mark++;
        }
        return CoderResult.UNDERFLOW;
    } finally {
        src.position(mark);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:26,代码来源:SingleByte.java

示例4: implFlush

protected CoderResult implFlush(CharBuffer out) {
    if(needFlushing) {
        if (out.remaining() < 1) {
            return CoderResult.OVERFLOW;
        } else {
            out.put(contextChar);
        }
    }
    contextChar = INVALID_CHAR;
    needFlushing = false;
    return CoderResult.UNDERFLOW;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:ISCII91.java

示例5: decodeBufferLoop

private CoderResult decodeBufferLoop(ByteBuffer src, CharBuffer dst) {
    int mark = src.position();
    try {
        while (src.hasRemaining()) {
            char[] cc = null;
            int b1 = src.get() & 0xff;
            char c = decodeSingle(b1);
            int inSize = 1, outSize = 1;
            if (c == UNMAPPABLE) {
                if (src.remaining() < 1)
                    return CoderResult.UNDERFLOW;
                int b2 = src.get() & 0xff;
                inSize++;
                c = decodeDouble(b1, b2);
                if (c == UNMAPPABLE) {
                    cc = decodeDoubleEx(b1, b2);
                    if (cc == null) {
                        if (decodeSingle(b2) == UNMAPPABLE)
                            return CoderResult.unmappableForLength(2);
                        else
                            return CoderResult.unmappableForLength(1);
                    }
                    outSize++;
                }
            }
            if (dst.remaining() < outSize)
                return CoderResult.OVERFLOW;
            if (outSize == 2) {
                dst.put(cc[0]);
                dst.put(cc[1]);
            } else {
                dst.put(c);
            }
            mark += inSize;
        }
        return CoderResult.UNDERFLOW;
    } finally {
        src.position(mark);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:40,代码来源:SJIS_0213.java

示例6: encodeBufferLoop

private CoderResult encodeBufferLoop(CharBuffer src, ByteBuffer dst) {
    int mark = src.position();
    try {
        while (src.hasRemaining()) {
            char c = src.get();
            if (Character.isSurrogate(c)) {
                if (sgp.parse(c, src) < 0)
                    return sgp.error();
                return sgp.unmappableResult();
            }
            if (c >= '\uFFFE')
                return CoderResult.unmappableForLength(1);
            if (!dst.hasRemaining())
                return CoderResult.OVERFLOW;

            char e = index2.charAt(index1[(c & mask1) >> shift]
                                   + (c & mask2));

            // If output byte is zero because input char is zero
            // then character is mappable, o.w. fail
            if (e == '\u0000' && c != '\u0000')
                return CoderResult.unmappableForLength(1);

            mark++;
            dst.put((byte)e);
        }
        return CoderResult.UNDERFLOW;
    } finally {
        src.position(mark);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:31,代码来源:SingleByteEncoder.java

示例7: decodeLoop

@Override
protected CoderResult decodeLoop(ByteBuffer in, CharBuffer out) {
  while (in.hasRemaining() && out.hasRemaining()) {
    char ch = (char) (in.get() & 0xff);
    if (ch >= 0xA0) {
      ch = TABLE[ch - 0xA0];
    }
    out.put(ch);
  }
  return in.hasRemaining() ? CoderResult.OVERFLOW : CoderResult.UNDERFLOW;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:11,代码来源:ISO8859_14Decoder.java

示例8: decodeArrayLoop

private CoderResult decodeArrayLoop(ByteBuffer src, CharBuffer dst) {
    byte[] sa = src.array();
    int sp = src.arrayOffset() + src.position();
    int sl = src.arrayOffset() + src.limit();
    assert (sp <= sl);
    sp = (sp <= sl ? sp : sl);
    char[] da = dst.array();
    int dp = dst.arrayOffset() + dst.position();
    int dl = dst.arrayOffset() + dst.limit();
    assert (dp <= dl);
    dp = (dp <= dl ? dp : dl);

    try {
        while (sp < sl) {
            int b = sa[sp];

            char c = decode(b);
            if (c == '\uFFFD')
                return CoderResult.unmappableForLength(1);
            if (dl - dp < 1)
                return CoderResult.OVERFLOW;
            da[dp++] = c;
            sp++;
        }
        return CoderResult.UNDERFLOW;
    } finally {
        src.position(sp - src.arrayOffset());
        dst.position(dp - dst.arrayOffset());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:30,代码来源:SingleByteDecoder.java

示例9: decodeBufferLoop

protected CoderResult decodeBufferLoop(ByteBuffer src, CharBuffer dst) {
    int mark = src.position();
    try {
        while (src.hasRemaining()) {
            char[] cc = null;
            int b1 = src.get() & 0xff;
            int inSize = 1, outSize = 1;
            char c = decodeSingle(b1);
            if (c == UNMAPPABLE_DECODING) {
                if (src.remaining() < 1)
                    return CoderResult.UNDERFLOW;
                int b2 = src.get() & 0xff;
                inSize++;
                if (b2 < b2Min || b2 > b2Max)
                    return CoderResult.unmappableForLength(2);
                c = decodeDouble(b1, b2);           //bmp
                if (c == UNMAPPABLE_DECODING) {
                    c = decodeDoubleEx(b1, b2);     //supp
                    if (c == UNMAPPABLE_DECODING) {
                        c = decodeBig5(b1, b2);     //big5
                        if (c == UNMAPPABLE_DECODING)
                            return CoderResult.unmappableForLength(2);
                    } else {
                        outSize = 2;
                    }
                }
            }
            if (dst.remaining() < outSize)
                return CoderResult.OVERFLOW;
            if (outSize == 2) {
                dst.put(Surrogate.high(0x20000 + c));
                dst.put(Surrogate.low(0x20000 + c));
            } else {
                dst.put(c);
            }
            mark += inSize;
        }
        return CoderResult.UNDERFLOW;
    } finally {
        src.position(mark);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:42,代码来源:HKSCS.java

示例10: decodeArrayLoop

private CoderResult decodeArrayLoop(ByteBuffer src,
                                    CharBuffer dst)
{
    byte[] sa = src.array();
    int sp = src.arrayOffset() + src.position();
    int sl = src.arrayOffset() + src.limit();
    assert (sp <= sl);
    sp = (sp <= sl ? sp : sl);

    char[] da = dst.array();
    int dp = dst.arrayOffset() + dst.position();
    int dl = dst.arrayOffset() + dst.limit();
    assert (dp <= dl);
    dp = (dp <= dl ? dp : dl);

    int b1 = 0, b2 = 0;
    int inputSize = 0;
    char outputChar = UNMAPPABLE_DECODING;
    try {
        while (sp < sl) {
            b1 = sa[sp] & 0xff;
            inputSize = 1;

            if ((b1 & 0x80) == 0) {
                outputChar = (char)b1;
            } else {                        // Multibyte char
                if (b1 == 0x8f) {           // JIS0212
                    if (sp + 3 > sl)
                       return CoderResult.UNDERFLOW;
                    b1 = sa[sp + 1] & 0xff;
                    b2 = sa[sp + 2] & 0xff;
                    inputSize += 2;
                    if (dec0212 == null)    // JIS02012 not supported
                        return CoderResult.unmappableForLength(inputSize);
                    outputChar = dec0212.decodeDouble(b1-0x80, b2-0x80);
                } else {                     // JIS0201, JIS0208
                    if (sp + 2 > sl)
                       return CoderResult.UNDERFLOW;
                    b2 = sa[sp + 1] & 0xff;
                    inputSize++;
                    outputChar = decodeDouble(b1, b2);
                }
            }
            if (outputChar == UNMAPPABLE_DECODING) { // can't be decoded
                return CoderResult.unmappableForLength(inputSize);
            }
            if (dp + 1 > dl)
                return CoderResult.OVERFLOW;
            da[dp++] = outputChar;
            sp += inputSize;
        }
        return CoderResult.UNDERFLOW;
    } finally {
        src.position(sp - src.arrayOffset());
        dst.position(dp - dst.arrayOffset());
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:57,代码来源:EUC_JP.java

示例11: encodeArrayLoop

private CoderResult encodeArrayLoop(CharBuffer src,
                                    ByteBuffer dst)
{
    char[] sa = src.array();
    int sp = src.arrayOffset() + src.position();
    int sl = src.arrayOffset() + src.limit();
    assert (sp <= sl);
    sp = (sp <= sl ? sp : sl);
    byte[] da = dst.array();
    int dp = dst.arrayOffset() + dst.position();
    int dl = dst.arrayOffset() + dst.limit();
    assert (dp <= dl);
    dp = (dp <= dl ? dp : dl);

    int outputSize;
    byte [] outputByte = new byte[4];

    try {
        while (sp < sl) {
            int inputSize = 1;

            if (Surrogate.is(sa[sp])) {
                char surr = sa[sp];
                if (sgp.parse(surr, sa, sp, sl) < 0)
                    return sgp.error();
                outputSize = unicodeToEUC(sa[sp], sa[sp+1], outputByte);
                inputSize = 2;
            } else if ( sa[sp] < 0x80) {  // ASCII
                outputSize = 1;
                outputByte[0] = (byte)sa[sp];
            } else {
                outputSize = unicodeToEUC(sa[sp], '\uFFFD', outputByte);
            }
            if (outputSize == -1)
               return CoderResult.unmappableForLength(inputSize);

            if ( dl - dp < outputSize)
                return CoderResult.OVERFLOW;
            for (int i = 0; i < outputSize; i++)
                da[dp++] = outputByte[i];
            sp  += inputSize;
            }
        return CoderResult.UNDERFLOW;
    } finally {
        src.position(sp - src.arrayOffset());
        dst.position(dp - dst.arrayOffset());
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:48,代码来源:EUC_TW_OLD.java

示例12: encodeArrayLoop

private CoderResult encodeArrayLoop(CharBuffer src,
                                    ByteBuffer dst)
{
    char[] sa = src.array();
    int sp = src.arrayOffset() + src.position();
    int sl = src.arrayOffset() + src.limit();
    assert (sp <= sl);
    sp = (sp <= sl ? sp : sl);
    byte[] da = dst.array();
    int dp = dst.arrayOffset() + dst.position();
    int dl = dst.arrayOffset() + dst.limit();
    assert (dp <= dl);
    dp = (dp <= dl ? dp : dl);

    int outputSize = 0;
    byte[]  outputByte;
    int     inputSize = 0;                 // Size of input
    byte[]  tmpBuf = new byte[3];

    try {
        while (sp < sl) {
            outputByte = tmpBuf;
            char c = sa[sp];
            if (Character.isSurrogate(c)) {
                if (sgp.parse(c, sa, sp, sl) < 0)
                    return sgp.error();
                return sgp.unmappableResult();
            }
            outputSize = encodeSingle(c, outputByte);
            if (outputSize == 0) { // DoubleByte
                int ncode = encodeDouble(c);
                if (ncode != UNMAPPABLE_ENCODING) {
                    if ((ncode & 0xFF0000) == 0) {
                        outputByte[0] = (byte) ((ncode & 0xff00) >> 8);
                        outputByte[1] = (byte) (ncode & 0xff);
                        outputSize = 2;
                    } else {
                        outputByte[0] = (byte) 0x8f;
                        outputByte[1] = (byte) ((ncode & 0xff00) >> 8);
                        outputByte[2] = (byte) (ncode & 0xff);
                        outputSize = 3;
                    }
                } else {
                    return CoderResult.unmappableForLength(1);
                }
            }
            if (dl - dp < outputSize)
                return CoderResult.OVERFLOW;
            // Put the byte in the output buffer
            for (int i = 0; i < outputSize; i++) {
                da[dp++] = outputByte[i];
            }
            sp++;
        }
        return CoderResult.UNDERFLOW;
    } finally {
        src.position(sp - src.arrayOffset());
        dst.position(dp - dst.arrayOffset());
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:60,代码来源:EUC_JP.java

示例13: decodeArrayLoop

private CoderResult decodeArrayLoop(ByteBuffer src, CharBuffer dst) {
    byte[] sa = src.array();
    int sp = src.arrayOffset() + src.position();
    int sl = src.arrayOffset() + src.limit();
    assert (sp <= sl);
    sp = (sp <= sl ? sp : sl);
    char[] da = dst.array();
    int dp = dst.arrayOffset() + dst.position();
    int dl = dst.arrayOffset() + dst.limit();
    assert (dp <= dl);
    dp = (dp <= dl ? dp : dl);

    try {
    while (sp < sl) {
        int byte1, byte2;
        int inputSize = 1;
        char outputChar = '\uFFFD';
        byte1 = sa[sp] & 0xff;

        if (byte1 == SS2) {
            if (sl - sp < 2) {
                return CoderResult.UNDERFLOW;
            }
            byte1 = sa[sp + 1] & 0xff;
            inputSize = 2;
            if ( byte1 < 0xa1 || byte1 > 0xfe) {   //valid first byte for G2
                return CoderResult.malformedForLength(2);
            }
            outputChar = mappingTableG2.charAt(byte1 - 0xa1);
        } else if(byte1 == SS3 ) {                 //G3
            if (sl - sp < 3) {
                return CoderResult.UNDERFLOW;
            }
            byte1 = sa[sp + 1] & 0xff;
            byte2 = sa[sp + 2] & 0xff;
            inputSize = 3;
            if ( byte1 < 0xa1 || byte1 > 0xfe) {
                return CoderResult.malformedForLength(2);
            }
            if ( byte2 < 0xa1 || byte2 > 0xfe) {
                return CoderResult.malformedForLength(3);
            }
            outputChar = mappingTableG3.charAt(((byte1 - 0xa1) * 94) + byte2 - 0xa1);
        } else if ( byte1 <= 0x9f ) {                // valid single byte
            outputChar = byteToCharTable.charAt(byte1);
        } else if (byte1 < 0xa1 || byte1 > 0xfe) {   // invalid range?
            return CoderResult.malformedForLength(1);
        } else {                                     // G1
            if (sl - sp < 2) {
                return CoderResult.UNDERFLOW;
            }
            byte2 = sa[sp + 1] & 0xff;
            inputSize = 2;
            if ( byte2 < 0xa1 || byte2 > 0xfe) {
                return CoderResult.malformedForLength(2);
            }
            outputChar = mappingTableG1.charAt(((byte1 - 0xa1) * 94) + byte2 - 0xa1);
        }
        if  (outputChar == '\uFFFD')
            return CoderResult.unmappableForLength(inputSize);
        if (dl - dp < 1)
            return CoderResult.OVERFLOW;
        da[dp++] = outputChar;
        sp += inputSize;
    }
    return CoderResult.UNDERFLOW;
    } finally {
        src.position(sp - src.arrayOffset());
        dst.position(dp - dst.arrayOffset());
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:71,代码来源:IBM33722.java

示例14: encodeBufferLoop

protected CoderResult encodeBufferLoop(CharBuffer src, ByteBuffer dst) {
    int mark = src.position();
    try {
        while (src.hasRemaining()) {
            char c = src.get();
            int bb = encodeChar(c);
            if (bb == UNMAPPABLE_ENCODING) {
                if (Character.isSurrogate(c)) {
                    if (sgp().parse(c, src) < 0)
                        return sgp.error();
                    return sgp.unmappableResult();
                }
                return CoderResult.unmappableForLength(1);
            }
            if (bb > MAX_SINGLEBYTE) {  // DoubleByte
                if (currentState == SBCS) {
                    if (dst.remaining() < 1)
                        return CoderResult.OVERFLOW;
                    currentState = DBCS;
                    dst.put(SO);
                }
                if (dst.remaining() < 2)
                    return CoderResult.OVERFLOW;
                dst.put((byte)(bb >> 8));
                dst.put((byte)(bb));
            } else {                  // Single-byte
                if (currentState == DBCS) {
                    if (dst.remaining() < 1)
                        return CoderResult.OVERFLOW;
                    currentState = SBCS;
                    dst.put(SI);
                }
                if (dst.remaining() < 1)
                    return CoderResult.OVERFLOW;
                dst.put((byte)bb);
            }
            mark++;
        }
        return CoderResult.UNDERFLOW;
    } finally {
        src.position(mark);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:43,代码来源:DoubleByte.java

示例15: encodeArrayLoop

private CoderResult encodeArrayLoop(CharBuffer src,
                                    ByteBuffer dst)
{
    char[] sa = src.array();
    int sp = src.arrayOffset() + src.position();
    int sl = src.arrayOffset() + src.limit();

    byte[] da = dst.array();
    int dp = dst.arrayOffset() + dst.position();
    int dl = dst.arrayOffset() + dst.limit();
    int dlASCII = dp + Math.min(sl - sp, dl - dp);

    // ASCII only loop
    while (dp < dlASCII && sa[sp] < '\u0080')
        da[dp++] = (byte) sa[sp++];
    while (sp < sl) {
        char c = sa[sp];
        if (c < 0x80) {
            // Have at most seven bits
            if (dp >= dl)
                return overflow(src, sp, dst, dp);
            da[dp++] = (byte)c;
        } else if (c < 0x800) {
            // 2 bytes, 11 bits
            if (dl - dp < 2)
                return overflow(src, sp, dst, dp);
            da[dp++] = (byte)(0xc0 | (c >> 6));
            da[dp++] = (byte)(0x80 | (c & 0x3f));
        } else if (Character.isSurrogate(c)) {
            // Have a surrogate pair
            if (sgp == null)
                sgp = new Surrogate.Parser();
            int uc = sgp.parse(c, sa, sp, sl);
            if (uc < 0) {
                updatePositions(src, sp, dst, dp);
                return sgp.error();
            }
            if (dl - dp < 4)
                return overflow(src, sp, dst, dp);
            da[dp++] = (byte)(0xf0 | ((uc >> 18)));
            da[dp++] = (byte)(0x80 | ((uc >> 12) & 0x3f));
            da[dp++] = (byte)(0x80 | ((uc >>  6) & 0x3f));
            da[dp++] = (byte)(0x80 | (uc & 0x3f));
            sp++;  // 2 chars
        } else {
            // 3 bytes, 16 bits
            if (dl - dp < 3)
                return overflow(src, sp, dst, dp);
            da[dp++] = (byte)(0xe0 | ((c >> 12)));
            da[dp++] = (byte)(0x80 | ((c >>  6) & 0x3f));
            da[dp++] = (byte)(0x80 | (c & 0x3f));
        }
        sp++;
    }
    updatePositions(src, sp, dst, dp);
    return CoderResult.UNDERFLOW;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:57,代码来源:UTF_8.java


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