private void checkCoderResult(CoderResult result) throws CharacterCodingException { if (malformedInputAction == CodingErrorAction.REPORT && result.isMalformed()) { throw new MalformedInputException(result.length()); } else if (unmappableCharacterAction == CodingErrorAction.REPORT && result.isUnmappable()) { throw new UnmappableCharacterException(result.length()); } }
LOGGER.finer("Charset translation: cannot mapped to an output char byte: " + e.getMessage()); return null; } catch (CharacterCodingException e) {
@JSFunction public static Object convert(Context cx, Scriptable thisObj, Object[] args, Function funObj) { ensureArg(args, 0); boolean lastChunk = booleanArg(args, 1, true); ByteBuffer inBuf; IconvImpl self = (IconvImpl)thisObj; if (args[0] == null) { inBuf = null; } else { Buffer.BufferImpl b = objArg(args, 0, Buffer.BufferImpl.class, true); inBuf = b.getBuffer(); } try { ByteBuffer result = self.converter.convert(inBuf, lastChunk); if (lastChunk) { self.converter.reset(); } if (result == null) { return null; } return Buffer.BufferImpl.newBuffer(cx, funObj, result, false); } catch (UnmappableCharacterException uce) { throw Utils.makeError(cx, funObj, uce.toString(), Constants.EILSEQ); } catch (CharacterCodingException cce) { throw Utils.makeError(cx, funObj, cce.toString(), Constants.EINVAL); } } }
private void checkCoderResult(CoderResult result) throws CharacterCodingException { if (result.isMalformed() && malformedInputAction == CodingErrorAction.REPORT) { throw new MalformedInputException(result.length()); } else if (result.isUnmappable() && unmappableCharacterAction == CodingErrorAction.REPORT) { throw new UnmappableCharacterException(result.length()); } }
/** * Throws an exception corresponding to this coder result. * * @throws BufferUnderflowException * in case this is an underflow. * @throws BufferOverflowException * in case this is an overflow. * @throws UnmappableCharacterException * in case this is an unmappable-character error. * @throws MalformedInputException * in case this is a malformed-input error. * @throws CharacterCodingException * the default exception. */ public void throwException() throws BufferUnderflowException, BufferOverflowException, UnmappableCharacterException, MalformedInputException, CharacterCodingException { switch (this.type) { case TYPE_UNDERFLOW: throw new BufferUnderflowException(); case TYPE_OVERFLOW: throw new BufferOverflowException(); case TYPE_UNMAPPABLE_CHAR: throw new UnmappableCharacterException(this.length); case TYPE_MALFORMED_INPUT: throw new MalformedInputException(this.length); default: throw new CharacterCodingException(); } }
throw new MalformedInputException(result.length()); } else if (result.isUnmappable()) { throw new UnmappableCharacterException(result.length());
public static ReadableCharBuf ascii(char[] values, int start, int length) { byte[] data = new byte[length]; for (int i = start; i < (start + length); i++) { char c = values[i]; if (c >= '\u0080') { throw new RuntimeException(new UnmappableCharacterException(2)); } data[i] = (byte) c; } return new ByteArrayReadOnlyAsciiBuf(data); }
@Override public Appendable append(char c) throws IOException { if (c >= '\u0080') { throw new UnmappableCharacterException(2); } content().writeByte((byte) c); return this; } }
@Override public Appendable append(CharSequence csq, int start, int end) throws IOException { if (csq.length() < end) { throw new IndexOutOfBoundsException(); } if (csq instanceof ReadOnlyAsciiBuf) { content().writeBytes(((ReadOnlyAsciiBuf) csq).content()); } else { for (int i = start; i < end; i++) { char c = csq.charAt(i); if (c >= '\u0080') { throw new UnmappableCharacterException(2); } content().writeByte((byte) c); } } return this; }
throw new UnmappableCharacterException(result.length());
public void throwException() throws CharacterCodingException { switch (type) { case CR_UNDERFLOW: throw new BufferUnderflowException(); case CR_OVERFLOW: throw new BufferOverflowException(); case CR_MALFORMED: throw new MalformedInputException(length); case CR_UNMAPPABLE: throw new UnmappableCharacterException(length); default: assert false; } }
throw new MalformedInputException(result.length()); } else if (result.isUnmappable()) { throw new UnmappableCharacterException(result.length());
throw new MalformedInputException(result.length()); } else if (result.isUnmappable()) { throw new UnmappableCharacterException(result.length());
throw new MalformedInputException(result.length()); } else if (result.isUnmappable()) { throw new UnmappableCharacterException(result.length());
/** * @param result result to check * @throws IllegalStateException if result is overflow * @throws MalformedInputException if result represents malformed input * @throws UnmappableCharacterException if result represents an unmappable character */ private static void throwIfError(CoderResult result) throws MalformedInputException, UnmappableCharacterException { if (result.isOverflow()) { throw new IllegalStateException("Byte buffer overflow, this should not happen"); } if (result.isMalformed()) { throw new MalformedInputException(result.length()); } if (result.isUnmappable()) { throw new UnmappableCharacterException(result.length()); } }
/** * @param result result to check * @throws IllegalStateException if result is overflow * @throws MalformedInputException if result represents malformed input * @throws UnmappableCharacterException if result represents an unmappable character */ private static void checkResult(CoderResult result) throws MalformedInputException, UnmappableCharacterException { if (result.isOverflow()) { throw new IllegalStateException("Byte buffer overflow; this should not happen."); } if (result.isMalformed()) { throw new MalformedInputException(result.length()); } if (result.isUnmappable()) { throw new UnmappableCharacterException(result.length()); } } }
new UnmappableCharacterException(result.length()));
private void checkCoderResult(CoderResult result) throws CharacterCodingException { if (result.isMalformed() && malformedInputAction == CodingErrorAction.REPORT) { throw new MalformedInputException(result.length()); } else if (result.isUnmappable() && unmappableCharacterAction == CodingErrorAction.REPORT) { throw new UnmappableCharacterException(result.length()); } }
private void checkCoderResult(CoderResult result) throws CharacterCodingException { if (result.isMalformed() && malformedInputAction == CodingErrorAction.REPORT) { throw new MalformedInputException(result.length()); } else if (result.isUnmappable() && unmappableCharacterAction == CodingErrorAction.REPORT) { throw new UnmappableCharacterException(result.length()); } }
private void checkCoderResult(CoderResult result) throws CharacterCodingException { if (result.isMalformed() && malformedInputAction == CodingErrorAction.REPORT) { throw new MalformedInputException(result.length()); } else if (result.isUnmappable() && unmappableCharacterAction == CodingErrorAction.REPORT) { throw new UnmappableCharacterException(result.length()); } }