// Path: src/org/jbookreader/book/bom/IBinaryData.java
// public interface IBinaryData {
// 
// 	/**
// 	 * Returns the content-type of the blob.
// 	 * @return the content-type.
// 	 */
// 	String getContentType();
// 
// 	/**
// 	 * Sets the content-type of the blob.
// 	 * @param contentType new content-type
// 	 */
// 	void setContentType(String contentType);
// 	
// 	/**
// 	 * Returns a character sequence iterating over base64-encoded
// 	 * representation of the binary data.
// 	 * @return a character sequence iterating over base64-encoded
// 	 * representation of the binary data.
// 	 */
// 	CharSequence getBase64Encoded();
// 
// 	/**
// 	 * Sets the contents of the blob by providing base64-encoding
// 	 * representation of data.
// 	 * @param base64Encoded the base64-encoded representation of data
// 	 */
// 	void setBase64Encoded(char[] base64Encoded);
// 
// 	/**
// 	 * Sets the contents by providing a byte array and a length.
// 	 * @param contents the new contents array.
// 	 * @param length the length of contents.
// 	 */
// 	void setContents(byte[] contents, int length);
// 
// 	/**
// 	 * Returns the contents array of the data.
// 	 * Note, that data can fill not the whole array, but the part of it.
// 	 * @return the contents array.
// 	 * @see #getContentsLength()
// 	 */
// 	byte[] getContentsArray();
// 
// 	/**
// 	 * Returns the contents length
// 	 * @return the length of the contents in the contents array.
// 	 */
// 	int getContentsLength();
// 
// }


import org.jbookreader.book.bom.IBinaryData;
		if (bits < 0 || bits > 63) {
			throw new IllegalArgumentException("Bad character number during encoding: " + bits);
		} else if (bits < 26) {
			return (char) ('A' + bits);
		} else if (bits < 52) {
			return (char) ('a' + bits - 26);
		} else if (bits < 62) {
			return (char) ('0' + bits - 52);
		} else if (bits == 62) {
			return '+';
		} else { // 63 
			return '/' ;
		}
	}
	
	public CharSequence getBase64Encoded() {
		StringBuilder result = new StringBuilder();
		int bitbuffer = 0;
		for (int i = 0; i < this.myContentsLength; i++) {
			bitbuffer = (bitbuffer << 8) | (this.myContentsArray[i] & 0xff);

			switch (i%3) {
				case 0:
					result.append(getBase64Char((bitbuffer >>> 2) & 0x3F));
					break;
				case 1:
					result.append(getBase64Char((bitbuffer >>> 4) & 0x3F));
					break;
				case 2:
					result.append(getBase64Char((bitbuffer >>> 6) & 0x3F));
// Path: src/org/jbookreader/book/bom/IBinaryData.java
// public interface IBinaryData {
// 
// 	/**
// 	 * Returns the content-type of the blob.
// 	 * @return the content-type.
// 	 */
// 	String getContentType();
// 
// 	/**
// 	 * Sets the content-type of the blob.
// 	 * @param contentType new content-type
// 	 */
// 	void setContentType(String contentType);
// 	
// 	/**
// 	 * Returns a character sequence iterating over base64-encoded
// 	 * representation of the binary data.
// 	 * @return a character sequence iterating over base64-encoded
// 	 * representation of the binary data.
// 	 */
// 	CharSequence getBase64Encoded();
// 
// 	/**
// 	 * Sets the contents of the blob by providing base64-encoding
// 	 * representation of data.
// 	 * @param base64Encoded the base64-encoded representation of data
// 	 */
// 	void setBase64Encoded(char[] base64Encoded);
// 
// 	/**
// 	 * Sets the contents by providing a byte array and a length.
// 	 * @param contents the new contents array.
// 	 * @param length the length of contents.
// 	 */
// 	void setContents(byte[] contents, int length);
// 
// 	/**
// 	 * Returns the contents array of the data.
// 	 * Note, that data can fill not the whole array, but the part of it.
// 	 * @return the contents array.
// 	 * @see #getContentsLength()
// 	 */
// 	byte[] getContentsArray();
// 
// 	/**
// 	 * Returns the contents length
// 	 * @return the length of the contents in the contents array.
// 	 */
// 	int getContentsLength();
// 
// }


// Path: src/org/jbookreader/book/bom/impl/BinaryData.java
import org.jbookreader.book.bom.IBinaryData;

		if (bits < 0 || bits > 63) {
			throw new IllegalArgumentException("Bad character number during encoding: " + bits);
		} else if (bits < 26) {
			return (char) ('A' + bits);
		} else if (bits < 52) {
			return (char) ('a' + bits - 26);
		} else if (bits < 62) {
			return (char) ('0' + bits - 52);
		} else if (bits == 62) {
			return '+';
		} else { // 63 
			return '/' ;
		}
	}
	
	public CharSequence getBase64Encoded() {
		StringBuilder result = new StringBuilder();
		int bitbuffer = 0;
		for (int i = 0; i < this.myContentsLength; i++) {
			bitbuffer = (bitbuffer << 8) | (this.myContentsArray[i] & 0xff);

			switch (i%3) {
				case 0:
					result.append(getBase64Char((bitbuffer >>> 2) & 0x3F));
					break;
				case 1:
					result.append(getBase64Char((bitbuffer >>> 4) & 0x3F));
					break;
				case 2:
					result.append(getBase64Char((bitbuffer >>> 6) & 0x3F));
					result.append(getBase64Char((bitbuffer >>> 0) & 0x3F));