@Override int decodeTo(byte[] target, CharSequence chars) throws DecodingException { checkNotNull(target); if (chars.length() % 2 == 1) { throw new DecodingException("Invalid input length " + chars.length()); } int bytesWritten = 0; for (int i = 0; i < chars.length(); i += 2) { int decoded = alphabet.decode(chars.charAt(i)) << 4 | alphabet.decode(chars.charAt(i + 1)); target[bytesWritten++] = (byte) decoded; } return bytesWritten; }
@Override int decodeTo(byte[] target, CharSequence chars) throws DecodingException { checkNotNull(target); if (chars.length() % 2 == 1) { throw new DecodingException("Invalid input length " + chars.length()); } int bytesWritten = 0; for (int i = 0; i < chars.length(); i += 2) { int decoded = alphabet.decode(chars.charAt(i)) << 4 | alphabet.decode(chars.charAt(i + 1)); target[bytesWritten++] = (byte) decoded; } return bytesWritten; }
@Override int decodeTo(byte[] target, CharSequence chars) throws DecodingException { checkNotNull(target); chars = trimTrailingPadding(chars); if (!alphabet.isValidPaddingStartPosition(chars.length())) { throw new DecodingException("Invalid input length " + chars.length()); } int bytesWritten = 0; for (int charIdx = 0; charIdx < chars.length(); charIdx += alphabet.charsPerChunk) { long chunk = 0; int charsProcessed = 0; for (int i = 0; i < alphabet.charsPerChunk; i++) { chunk <<= alphabet.bitsPerChar; if (charIdx + i < chars.length()) { chunk |= alphabet.decode(chars.charAt(charIdx + charsProcessed++)); } } final int minOffset = alphabet.bytesPerChunk * 8 - charsProcessed * alphabet.bitsPerChar; for (int offset = (alphabet.bytesPerChunk - 1) * 8; offset >= minOffset; offset -= 8) { target[bytesWritten++] = (byte) ((chunk >>> offset) & 0xFF); } } return bytesWritten; }
int decode(char ch) throws IOException { if (ch > Ascii.MAX || decodabet[ch] == -1) { throw new DecodingException("Unrecognized character: " + ch); } return decodabet[ch]; }
int decode(char ch) throws IOException { if (ch > Ascii.MAX || decodabet[ch] == -1) { throw new DecodingException("Unrecognized character: " + ch); } return decodabet[ch]; }
if (readChar == -1) { if (!hitPadding && !alphabet.isValidPaddingStartPosition(readChars)) { throw new DecodingException("Invalid input length " + readChars); if (!hitPadding && (readChars == 1 || !alphabet.isValidPaddingStartPosition(readChars - 1))) { throw new DecodingException("Padding cannot start at index " + readChars); throw new DecodingException( "Expected padding character but found '" + ch + "' at index " + readChars); } else {
if (readChar == -1) { if (!hitPadding && !alphabet.isValidPaddingStartPosition(readChars)) { throw new DecodingException("Invalid input length " + readChars); if (!hitPadding && (readChars == 1 || !alphabet.isValidPaddingStartPosition(readChars - 1))) { throw new DecodingException("Padding cannot start at index " + readChars); throw new DecodingException( "Expected padding character but found '" + ch + "' at index " + readChars); } else {
if (readChar == -1) { if (!hitPadding && !alphabet.isValidPaddingStartPosition(readChars)) { throw new DecodingException("Invalid input length " + readChars); if (!hitPadding && (readChars == 1 || !alphabet.isValidPaddingStartPosition(readChars - 1))) { throw new DecodingException("Padding cannot start at index " + readChars); throw new DecodingException( "Expected padding character but found '" + ch + "' at index " + readChars); } else {
@Override int decodeTo(byte[] target, CharSequence chars) throws DecodingException { checkNotNull(target); chars = trimTrailingPadding(chars); if (!alphabet.isValidPaddingStartPosition(chars.length())) { throw new DecodingException("Invalid input length " + chars.length()); } int bytesWritten = 0; for (int charIdx = 0; charIdx < chars.length(); charIdx += alphabet.charsPerChunk) { long chunk = 0; int charsProcessed = 0; for (int i = 0; i < alphabet.charsPerChunk; i++) { chunk <<= alphabet.bitsPerChar; if (charIdx + i < chars.length()) { chunk |= alphabet.decode(chars.charAt(charIdx + charsProcessed++)); } } final int minOffset = alphabet.bytesPerChunk * 8 - charsProcessed * alphabet.bitsPerChar; for (int offset = (alphabet.bytesPerChunk - 1) * 8; offset >= minOffset; offset -= 8) { target[bytesWritten++] = (byte) ((chunk >>> offset) & 0xFF); } } return bytesWritten; }
@Override int decodeTo(byte[] target, CharSequence chars) throws DecodingException { checkNotNull(target); chars = trimTrailingPadding(chars); if (!alphabet.isValidPaddingStartPosition(chars.length())) { throw new DecodingException("Invalid input length " + chars.length()); } int bytesWritten = 0; for (int i = 0; i < chars.length(); ) { int chunk = alphabet.decode(chars.charAt(i++)) << 18; chunk |= alphabet.decode(chars.charAt(i++)) << 12; target[bytesWritten++] = (byte) (chunk >>> 16); if (i < chars.length()) { chunk |= alphabet.decode(chars.charAt(i++)) << 6; target[bytesWritten++] = (byte) ((chunk >>> 8) & 0xFF); if (i < chars.length()) { chunk |= alphabet.decode(chars.charAt(i++)); target[bytesWritten++] = (byte) (chunk & 0xFF); } } } return bytesWritten; }
if (readChar == -1) { if (!hitPadding && !alphabet.isValidPaddingStartPosition(readChars)) { throw new DecodingException("Invalid input length " + readChars); if (!hitPadding && (readChars == 1 || !alphabet.isValidPaddingStartPosition(readChars - 1))) { throw new DecodingException("Padding cannot start at index " + readChars); throw new DecodingException( "Expected padding character but found '" + ch + "' at index " + readChars); } else {
@Override int decodeTo(byte[] target, CharSequence chars) throws DecodingException { checkNotNull(target); chars = trimTrailingPadding(chars); if (!alphabet.isValidPaddingStartPosition(chars.length())) { throw new DecodingException("Invalid input length " + chars.length()); } int bytesWritten = 0; for (int charIdx = 0; charIdx < chars.length(); charIdx += alphabet.charsPerChunk) { long chunk = 0; int charsProcessed = 0; for (int i = 0; i < alphabet.charsPerChunk; i++) { chunk <<= alphabet.bitsPerChar; if (charIdx + i < chars.length()) { chunk |= alphabet.decode(chars.charAt(charIdx + charsProcessed++)); } } final int minOffset = alphabet.bytesPerChunk * 8 - charsProcessed * alphabet.bitsPerChar; for (int offset = (alphabet.bytesPerChunk - 1) * 8; offset >= minOffset; offset -= 8) { target[bytesWritten++] = (byte) ((chunk >>> offset) & 0xFF); } } return bytesWritten; }
@Override int decodeTo(byte[] target, CharSequence chars) throws DecodingException { checkNotNull(target); chars = trimTrailingPadding(chars); if (!alphabet.isValidPaddingStartPosition(chars.length())) { throw new DecodingException("Invalid input length " + chars.length()); } int bytesWritten = 0; for (int i = 0; i < chars.length(); ) { int chunk = alphabet.decode(chars.charAt(i++)) << 18; chunk |= alphabet.decode(chars.charAt(i++)) << 12; target[bytesWritten++] = (byte) (chunk >>> 16); if (i < chars.length()) { chunk |= alphabet.decode(chars.charAt(i++)) << 6; target[bytesWritten++] = (byte) ((chunk >>> 8) & 0xFF); if (i < chars.length()) { chunk |= alphabet.decode(chars.charAt(i++)); target[bytesWritten++] = (byte) (chunk & 0xFF); } } } return bytesWritten; }
int decode(char ch) throws DecodingException { if (ch > Ascii.MAX) { throw new DecodingException("Unrecognized character: 0x" + Integer.toHexString(ch)); } int result = decodabet[ch]; if (result == -1) { if (ch <= 0x20 || ch == Ascii.MAX) { throw new DecodingException("Unrecognized character: 0x" + Integer.toHexString(ch)); } else { throw new DecodingException("Unrecognized character: " + ch); } } return result; }
@Override int decodeTo(byte[] target, CharSequence chars) throws DecodingException { checkNotNull(target); if (chars.length() % 2 == 1) { throw new DecodingException("Invalid input length " + chars.length()); } int bytesWritten = 0; for (int i = 0; i < chars.length(); i += 2) { int decoded = alphabet.decode(chars.charAt(i)) << 4 | alphabet.decode(chars.charAt(i + 1)); target[bytesWritten++] = (byte) decoded; } return bytesWritten; }
if (readChar == -1) { if (!hitPadding && !alphabet.isValidPaddingStartPosition(readChars)) { throw new DecodingException("Invalid input length " + readChars); if (!hitPadding && (readChars == 1 || !alphabet.isValidPaddingStartPosition(readChars - 1))) { throw new DecodingException("Padding cannot start at index " + readChars); throw new DecodingException( "Expected padding character but found '" + ch + "' at index " + readChars); } else {
if (readChar == -1) { if (!hitPadding && !alphabet.isValidPaddingStartPosition(readChars)) { throw new DecodingException("Invalid input length " + readChars); if (!hitPadding && (readChars == 1 || !alphabet.isValidPaddingStartPosition(readChars - 1))) { throw new DecodingException("Padding cannot start at index " + readChars); throw new DecodingException( "Expected padding character but found '" + ch + "' at index " + readChars); } else {
int decode(char ch) throws DecodingException { if (ch > Ascii.MAX) { throw new DecodingException("Unrecognized character: 0x" + Integer.toHexString(ch)); } int result = decodabet[ch]; if (result == -1) { if (ch <= 0x20 || ch == Ascii.MAX) { throw new DecodingException("Unrecognized character: 0x" + Integer.toHexString(ch)); } else { throw new DecodingException("Unrecognized character: " + ch); } } return result; }
@Override int decodeTo(byte[] target, CharSequence chars) throws DecodingException { checkNotNull(target); chars = trimTrailingPadding(chars); if (!alphabet.isValidPaddingStartPosition(chars.length())) { throw new DecodingException("Invalid input length " + chars.length()); } int bytesWritten = 0; for (int i = 0; i < chars.length(); ) { int chunk = alphabet.decode(chars.charAt(i++)) << 18; chunk |= alphabet.decode(chars.charAt(i++)) << 12; target[bytesWritten++] = (byte) (chunk >>> 16); if (i < chars.length()) { chunk |= alphabet.decode(chars.charAt(i++)) << 6; target[bytesWritten++] = (byte) ((chunk >>> 8) & 0xFF); if (i < chars.length()) { chunk |= alphabet.decode(chars.charAt(i++)); target[bytesWritten++] = (byte) (chunk & 0xFF); } } } return bytesWritten; }
int decode(char ch) throws DecodingException { if (ch > Ascii.MAX) { throw new DecodingException("Unrecognized character: 0x" + Integer.toHexString(ch)); } int result = decodabet[ch]; if (result == -1) { if (ch <= 0x20 || ch == Ascii.MAX) { throw new DecodingException("Unrecognized character: 0x" + Integer.toHexString(ch)); } else { throw new DecodingException("Unrecognized character: " + ch); } } return result; }