public void test_isBmpCodePoint() throws Exception { assertTrue(Character.isBmpCodePoint(0x0000)); assertTrue(Character.isBmpCodePoint(0x0666)); assertTrue(Character.isBmpCodePoint(0xffff)); assertFalse(Character.isBmpCodePoint(0x10000)); assertFalse(Character.isBmpCodePoint(-1)); assertFalse(Character.isBmpCodePoint(Integer.MAX_VALUE)); assertFalse(Character.isBmpCodePoint(Integer.MIN_VALUE)); }
/* */ protected CoderResult decodeLoop( ByteBuffer paramByteBuffer, CharBuffer paramCharBuffer) /* */ { /* 65 */ if (paramByteBuffer.remaining() < 4) /* 66 */ return CoderResult.UNDERFLOW; /* 67 */ int i = paramByteBuffer.position(); /* */ try /* */ { /* */ int j; /* 70 */ if (this.currentBO == 0) { /* 71 */ j = (paramByteBuffer.get() & 0xFF) << 24 | (paramByteBuffer.get() & 0xFF) << 16 | (paramByteBuffer.get() & 0xFF) << 8 | paramByteBuffer.get() & 0xFF; /* */ /* 75 */ if ((j == 65279) && (this.expectedBO != 2)) { /* 76 */ this.currentBO = 1; /* 77 */ i += 4; /* 78 */ } else if ((j == -131072) && (this.expectedBO != 1)) { /* 79 */ this.currentBO = 2; /* 80 */ i += 4; /* */ } else { /* 82 */ if (this.expectedBO == 0) /* 83 */ this.currentBO = 1; /* */ else /* 85 */ this.currentBO = this.expectedBO; /* 86 */ paramByteBuffer.position(i); /* */ } /* */ } /* */ CoderResult localCoderResult; /* 89 */ while (paramByteBuffer.remaining() >= 4) { /* 90 */ j = getCP(paramByteBuffer); /* 91 */ if (Character.isBmpCodePoint(j)) { /* 92 */ if (!paramCharBuffer.hasRemaining()) /* 93 */ return CoderResult.OVERFLOW; /* 94 */ i += 4; /* 95 */ paramCharBuffer.put((char) j); /* 96 */ } else if (Character.isValidCodePoint(j)) { /* 97 */ if (paramCharBuffer.remaining() < 2) /* 98 */ return CoderResult.OVERFLOW; /* 99 */ i += 4; /* 100 */ paramCharBuffer.put(Character.highSurrogate(j)); /* 101 */ paramCharBuffer.put(Character.lowSurrogate(j)); /* */ } else { /* 103 */ return CoderResult.malformedForLength(4); /* */ } /* */ } /* 106 */ return CoderResult.UNDERFLOW; /* */ } finally { /* 108 */ paramByteBuffer.position(i); /* */ } /* */ }
protected CoderResult decodeLoop(ByteBuffer src, CharBuffer dst) { if (src.remaining() < 4) return CoderResult.UNDERFLOW; int mark = src.position(); int cp; try { if (currentBO == NONE) { cp = ((src.get() & 0xff) << 24) | ((src.get() & 0xff) << 16) | ((src.get() & 0xff) << 8) | (src.get() & 0xff); if (cp == BOM_BIG && expectedBO != LITTLE) { currentBO = BIG; mark += 4; } else if (cp == BOM_LITTLE && expectedBO != BIG) { currentBO = LITTLE; mark += 4; } else { if (expectedBO == NONE) currentBO = BIG; else currentBO = expectedBO; src.position(mark); } } while (src.remaining() >= 4) { cp = getCP(src); if (Character.isBmpCodePoint(cp)) { if (!dst.hasRemaining()) return CoderResult.OVERFLOW; mark += 4; dst.put((char) cp); } else if (Character.isValidCodePoint(cp)) { if (dst.remaining() < 2) return CoderResult.OVERFLOW; mark += 4; dst.put(Character.highSurrogate(cp)); dst.put(Character.lowSurrogate(cp)); } else { return CoderResult.malformedForLength(4); } } return CoderResult.UNDERFLOW; } finally { src.position(mark); } }