本文整理汇总了Java中java.nio.charset.CoderResult.OVERFLOW属性的典型用法代码示例。如果您正苦于以下问题:Java CoderResult.OVERFLOW属性的具体用法?Java CoderResult.OVERFLOW怎么用?Java CoderResult.OVERFLOW使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.nio.charset.CoderResult
的用法示例。
在下文中一共展示了CoderResult.OVERFLOW属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: encodeBufferLoop
private CoderResult encodeBufferLoop(CharBuffer src,
ByteBuffer dst)
{
int mark = src.position();
try {
while (src.hasRemaining()) {
char c = src.get();
if (c <= '\u00FF') {
if (!dst.hasRemaining())
return CoderResult.OVERFLOW;
dst.put((byte)c);
mark++;
continue;
}
if (sgp.parse(c, src) < 0)
return sgp.error();
return sgp.unmappableResult();
}
return CoderResult.UNDERFLOW;
} finally {
src.position(mark);
}
}
示例2: 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);
}
}
示例3: encodeBufferLoop
private CoderResult encodeBufferLoop(CharBuffer src,
ByteBuffer dst)
{
int mark = src.position();
try {
while (src.hasRemaining()) {
char c = src.get();
if (c < 0x80) {
if (!dst.hasRemaining())
return CoderResult.OVERFLOW;
dst.put((byte)c);
mark++;
continue;
}
if (sgp.parse(c, src) < 0)
return sgp.error();
return sgp.unmappableResult();
}
return CoderResult.UNDERFLOW;
} finally {
src.position(mark);
}
}
示例4: encodeBufferLoop
private CoderResult encodeBufferLoop(CharBuffer src, ByteBuffer dst) {
int mark = src.position();
try {
while (src.hasRemaining()) {
char c = src.get();
if (Surrogate.is(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);
}
}
示例5: implFlush
protected CoderResult implFlush(ByteBuffer out) {
if (byteState == DBCS) {
if (out.remaining() < 1)
return CoderResult.OVERFLOW;
out.put(SI);
}
implReset();
return CoderResult.UNDERFLOW;
}
示例6: encodeBufferLoop
protected CoderResult encodeBufferLoop(CharBuffer src, ByteBuffer dst) {
int mark = src.position();
try {
while (src.hasRemaining()) {
int inSize = 1;
char c = src.get();
int bb = encodeChar(c);
if (bb == UNMAPPABLE_ENCODING) {
if (Character.isSurrogate(c)) {
int cp;
if ((cp = sgp().parse(c, src)) < 0)
return sgp.error();
bb = encodeSupp(cp);
if (bb == UNMAPPABLE_ENCODING)
return CoderResult.unmappableForLength(2);
inSize = 2;
} else {
return CoderResult.unmappableForLength(1);
}
}
if (bb > MAX_SINGLEBYTE) { // DoubleByte
if (dst.remaining() < 2)
return CoderResult.OVERFLOW;
dst.put((byte)(bb >> 8));
dst.put((byte)(bb));
} else {
if (dst.remaining() < 1)
return CoderResult.OVERFLOW;
dst.put((byte)bb);
}
mark += inSize;
}
return CoderResult.UNDERFLOW;
} finally {
src.position(mark);
}
}
示例7: encodeBufferLoop
private CoderResult encodeBufferLoop(CharBuffer src, ByteBuffer dst) {
int mark = src.position();
try {
while (src.hasRemaining()) {
char c = src.get();
if (Character.isSurrogate(c)) {
int surr;
if ((surr = sgp.parse(c, src)) < 0)
return sgp.error();
char c2 = Surrogate.low(surr);
byte[] outputBytes = new byte[2];
outputBytes = encodeSurrogate(c, c2);
if (outputBytes == null) {
return sgp.unmappableResult();
} else {
if (dst.remaining() < 2)
return CoderResult.OVERFLOW;
mark += 2;
dst.put(outputBytes[0]);
dst.put(outputBytes[1]);
continue;
}
}
if (c >= '\uFFFE')
return CoderResult.unmappableForLength(1);
int b = encodeSingle(c);
if (b != -1) { // Single-byte character
if (dst.remaining() < 1)
return CoderResult.OVERFLOW;
mark++;
dst.put((byte)b);
continue;
}
// Double Byte character
int ncode = encodeDouble(c);
if (ncode != 0 && c != '\u0000') {
if (dst.remaining() < 2)
return CoderResult.OVERFLOW;
mark++;
dst.put((byte) ((ncode & 0xff00) >> 8));
dst.put((byte) ncode);
continue;
}
return CoderResult.unmappableForLength(1);
}
return CoderResult.UNDERFLOW;
} finally {
src.position(mark);
}
}
示例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);
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());
}
}
示例9: encodeBufferLoop
private CoderResult encodeBufferLoop(CharBuffer src,
ByteBuffer dst)
{
int outputSize = 0;
byte[] outputByte = new byte[8];
int inputSize = 0; // Size of input
newshiftout = shiftout;
newSODesDefined = SODesDefined;
newSS2DesDefined = SS2DesDefined;
newSS3DesDefined = SS3DesDefined;
int mark = src.position();
try {
while (src.hasRemaining()) {
char inputChar = src.get();
if (Character.isSurrogate(inputChar)) {
if (sgp.parse(inputChar, src) < 0)
return sgp.error();
return sgp.unmappableResult();
}
if (inputChar < 0x80) { // ASCII
if (shiftout){
newshiftout = false;
outputSize = 2;
outputByte[0] = ISO_SI;
outputByte[1] = (byte)(inputChar & 0x7f);
} else {
outputSize = 1;
outputByte[0] = (byte)(inputChar & 0x7f);
}
if(inputChar == '\n'){
newSODesDefined = false;
newSS2DesDefined = false;
newSS3DesDefined = false;
}
} else {
outputSize = unicodeToNative(inputChar, outputByte);
if (outputSize == 0) {
return CoderResult.unmappableForLength(1);
}
}
if (dst.remaining() < outputSize)
return CoderResult.OVERFLOW;
for (int i = 0; i < outputSize; i++)
dst.put(outputByte[i]);
mark++;
shiftout = newshiftout;
SODesDefined = newSODesDefined;
SS2DesDefined = newSS2DesDefined;
SS3DesDefined = newSS3DesDefined;
}
return CoderResult.UNDERFLOW;
} finally {
src.position(mark);
}
}
示例10: decodeNotHasArray
private CoderResult decodeNotHasArray(ByteBuffer in, CharBuffer out) {
int outRemaining = out.remaining();
int pos = in.position();
int limit = in.limit();
try {
while (pos < limit) {
if (outRemaining == 0) {
return CoderResult.OVERFLOW;
}
int jchar = in.get();
if (jchar < 0) {
jchar = jchar & 0x7F;
int tail = remainingBytes[jchar];
if (tail == -1) {
return CoderResult.malformedForLength(1);
}
if (limit - pos < 1 + tail) {
// No early test for invalid sequences here as peeking
// at the next byte is harder
return CoderResult.UNDERFLOW;
}
int nextByte;
for (int i = 0; i < tail; i++) {
nextByte = in.get() & 0xFF;
if ((nextByte & 0xC0) != 0x80) {
return CoderResult.malformedForLength(1 + i);
}
jchar = (jchar << 6) + nextByte;
}
jchar -= remainingNumbers[tail];
if (jchar < lowerEncodingLimit[tail]) {
// Should have been encoded in a fewer octets
return CoderResult.malformedForLength(1);
}
pos += tail;
}
// Apache Tomcat added test
if (jchar >= 0xD800 && jchar <= 0xDFFF) {
return CoderResult.unmappableForLength(3);
}
// Apache Tomcat added test
if (jchar > 0x10FFFF) {
return CoderResult.unmappableForLength(4);
}
if (jchar <= 0xffff) {
out.put((char) jchar);
outRemaining--;
} else {
if (outRemaining < 2) {
return CoderResult.OVERFLOW;
}
out.put((char) ((jchar >> 0xA) + 0xD7C0));
out.put((char) ((jchar & 0x3FF) + 0xDC00));
outRemaining -= 2;
}
pos++;
}
return CoderResult.UNDERFLOW;
} finally {
in.position(pos);
}
}
示例11: overflow
private static CoderResult overflow(CharBuffer src, int mark) {
src.position(mark);
return CoderResult.OVERFLOW;
}
示例12: decodeBufferLoop
private CoderResult decodeBufferLoop(ByteBuffer src, CharBuffer dst) {
int mark = src.position();
try {
while (src.hasRemaining()) {
int byte1, byte2;
int inputSize = 1;
char outputChar = '\uFFFD';
byte1 = src.get() & 0xff;
if (byte1 == SS2) {
if (src.remaining() < 3)
return CoderResult.UNDERFLOW;
byte1 = src.get() & 0xff;
inputSize = 2;
if ( byte1 == 0xa2)
mappingTableG2 = mappingTableG2a2;
else if ( byte1 == 0xac)
mappingTableG2 = mappingTableG2ac;
else if ( byte1 == 0xad)
mappingTableG2 = mappingTableG2ad;
else
return CoderResult.malformedForLength(2);
byte1 = src.get() & 0xff;
if ( byte1 < 0xa1 || byte1 > 0xfe)
return CoderResult.malformedForLength(3);
byte2 = src.get() & 0xff;
if ( byte2 < 0xa1 || byte2 > 0xfe)
return CoderResult.malformedForLength(4);
inputSize = 4;
outputChar = mappingTableG2.charAt(((byte1 - 0xa1) * 94) + byte2 - 0xa1);
} else if (byte1 == SS3 ) {
return CoderResult.malformedForLength(1);
} 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 (src.remaining() < 1)
return CoderResult.UNDERFLOW;
byte2 = src.get() & 0xff;
if ( byte2 < 0xa1 || byte2 > 0xfe) {
return CoderResult.malformedForLength(2);
}
inputSize = 2;
outputChar = mappingTableG1.charAt(((byte1 - 0xa1) * 94) + byte2 - 0xa1);
}
if (outputChar == '\uFFFD')
return CoderResult.unmappableForLength(inputSize);
if (!dst.hasRemaining())
return CoderResult.OVERFLOW;
dst.put(outputChar);
mark += inputSize;
}
return CoderResult.UNDERFLOW;
} finally {
src.position(mark);
}
}
示例13: 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 = new byte[8];
newshiftout = shiftout;
newSODesDefined = SODesDefined;
newSS2DesDefined = SS2DesDefined;
newSS3DesDefined = SS3DesDefined;
try {
while (sp < sl) {
char c = sa[sp];
if (Character.isSurrogate(c)) {
if (sgp.parse(c, sa, sp, sl) < 0)
return sgp.error();
return sgp.unmappableResult();
}
if (c < 0x80) { // ASCII
if (shiftout){
newshiftout = false;
outputSize = 2;
outputByte[0] = ISO_SI;
outputByte[1] = (byte)(c & 0x7f);
} else {
outputSize = 1;
outputByte[0] = (byte)(c & 0x7f);
}
if(sa[sp] == '\n'){
newSODesDefined = false;
newSS2DesDefined = false;
newSS3DesDefined = false;
}
} else {
outputSize = unicodeToNative(c, outputByte);
if (outputSize == 0) {
return CoderResult.unmappableForLength(1);
}
}
if (dl - dp < outputSize)
return CoderResult.OVERFLOW;
for (int i = 0; i < outputSize; i++)
da[dp++] = outputByte[i];
sp++;
shiftout = newshiftout;
SODesDefined = newSODesDefined;
SS2DesDefined = newSS2DesDefined;
SS3DesDefined = newSS3DesDefined;
}
return CoderResult.UNDERFLOW;
} finally {
src.position(sp - src.arrayOffset());
dst.position(dp - dst.arrayOffset());
}
}
示例14: 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();
try {
while (sp < sl) {
char c = sa[sp];
if (Character.isSurrogate(c)) {
if (sgp.parse(c, sa, sp, sl) < 0)
return sgp.error();
if (sl - sp < 2)
return CoderResult.UNDERFLOW;
char c2 = sa[sp + 1];
byte[] outputBytes = new byte[2];
outputBytes = encodeSurrogate(c, c2);
if (outputBytes == null) {
return sgp.unmappableResult();
}
else {
if (dl - dp < 2)
return CoderResult.OVERFLOW;
da[dp++] = outputBytes[0];
da[dp++] = outputBytes[1];
sp += 2;
continue;
}
}
if (c >= '\uFFFE')
return CoderResult.unmappableForLength(1);
int b = encodeSingle(c);
if (b != -1) { // Single Byte
if (dl - dp < 1)
return CoderResult.OVERFLOW;
da[dp++] = (byte)b;
sp++;
continue;
}
int ncode = encodeDouble(c);
if (ncode != 0 && c != '\u0000' ) {
if (dl - dp < 2)
return CoderResult.OVERFLOW;
da[dp++] = (byte) ((ncode & 0xff00) >> 8);
da[dp++] = (byte) (ncode & 0xff);
sp++;
continue;
}
return CoderResult.unmappableForLength(1);
}
return CoderResult.UNDERFLOW;
} finally {
src.position(sp - src.arrayOffset());
dst.position(dp - dst.arrayOffset());
}
}
示例15: encodeBufferLoop
private CoderResult encodeBufferLoop(CharBuffer src,
ByteBuffer dst)
{
int outputSize = 0;
byte[] outputByte;
int inputSize = 0; // Size of input
byte[] tmpBuf = new byte[3];
int mark = src.position();
try {
while (src.hasRemaining()) {
outputByte = tmpBuf;
char c = src.get();
if (Character.isSurrogate(c)) {
if (sgp.parse(c, src) < 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 (dst.remaining() < outputSize)
return CoderResult.OVERFLOW;
// Put the byte in the output buffer
for (int i = 0; i < outputSize; i++) {
dst.put(outputByte[i]);
}
mark++;
}
return CoderResult.UNDERFLOW;
} finally {
src.position(mark);
}
}