/* ==================================================================== * Copyright (c) 2006 J.T. Beetstra * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ==================================================================== */ package com.beetstra.jutf7; import java.util.Arrays; /** *
* Represent a base 64 mapping. The 64 characters used in the encoding can be * specified, since modified-UTF-7 uses other characters than UTF-7 (',' instead * of '/'). *
** The exact type of the arguments and result values is adapted to the needs of * the encoder and decoder, as opposed to following a strict interpretation of * base 64. *
** Base 64, as specified in RFC 2045, is an encoding used to encode bytes as * characters. In (modified-)UTF-7 however, it is used to encode characters as * bytes, using some intermediate steps: *
*ch
, false otherwise
*/
boolean contains(final char ch) {
if (ch >= 128)
return false;
return inverseAlphabet[ch] >= 0;
}
/**
* Encodes the six bit group as a character.
*
* @param sextet The six bit group to be encoded
* @return The ASCII value of the character
*/
byte getChar(final int sextet) {
return (byte)alphabet[sextet];
}
}