kz.gamma.hardware.util.encoders
Class Base64Encoder

java.lang.Object
  extended by kz.gamma.hardware.util.encoders.Base64Encoder
All Implemented Interfaces:
Encoder
Direct Known Subclasses:
UrlBase64Encoder

public class Base64Encoder
extends java.lang.Object
implements Encoder

BASE64 кодировщик


Field Summary
protected  byte[] decodingTable
          set up the decoding table.
protected  byte[] encodingTable
          Таблица кодирования
protected  byte padding
           
 
Constructor Summary
Base64Encoder()
          Конструктор
 
Method Summary
 int decode(byte[] data, int off, int length, java.io.OutputStream out)
          decode the base 64 encoded byte data writing it to the given output stream, whitespace characters will be ignored.
 int decode(java.lang.String data, java.io.OutputStream out)
          decode the base 64 encoded String data writing it to the given output stream, whitespace characters will be ignored.
private  int decodeLastBlock(java.io.OutputStream out, char c1, char c2, char c3, char c4)
           
 int encode(byte[] data, int off, int length, java.io.OutputStream out)
          encode the input data producing a base 64 output stream.
private  boolean ignore(char c)
          Игнорирование символов '\n', '\r', '\t', ' '
protected  void initialiseDecodingTable()
          Инициализация таблицы декодирования
 boolean isArrayByteBase64(byte[] arrayOctect)
          Tests a given byte array to see if it contains only valid characters within the Base64 alphabet.
private  boolean isBase64Byte(byte octect)
          Проверка на то, является ли октет символом BASE64
private  int nextI(byte[] data, int i, int finish)
           
private  int nextI(java.lang.String data, int i, int finish)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

encodingTable

protected final byte[] encodingTable
Таблица кодирования


padding

protected byte padding

decodingTable

protected final byte[] decodingTable
set up the decoding table.

Constructor Detail

Base64Encoder

public Base64Encoder()
Конструктор

Method Detail

isBase64Byte

private boolean isBase64Byte(byte octect)
Проверка на то, является ли октет символом BASE64

Parameters:
octect - Октет
Returns:
true, если октет является символом BASE64, иначе false

isArrayByteBase64

public boolean isArrayByteBase64(byte[] arrayOctect)
Tests a given byte array to see if it contains only valid characters within the Base64 alphabet.

Parameters:
arrayOctect - byte array to test
Returns:
true if all bytes are valid characters in the Base64 alphabet or if the byte array is empty; false, otherwise

initialiseDecodingTable

protected void initialiseDecodingTable()
Инициализация таблицы декодирования


encode

public int encode(byte[] data,
                  int off,
                  int length,
                  java.io.OutputStream out)
           throws java.io.IOException
encode the input data producing a base 64 output stream.

Specified by:
encode in interface Encoder
Parameters:
data - Данные для кодирования
off - Начальный сдвиг
length - Длина
out - Поток для записи
Returns:
the number of bytes produced.
Throws:
java.io.IOException

ignore

private boolean ignore(char c)
Игнорирование символов '\n', '\r', '\t', ' '

Parameters:
c - Символ
Returns:
true, если необходимо игнорировать символ, иначе false

decode

public int decode(byte[] data,
                  int off,
                  int length,
                  java.io.OutputStream out)
           throws java.io.IOException
decode the base 64 encoded byte data writing it to the given output stream, whitespace characters will be ignored.

Specified by:
decode in interface Encoder
Parameters:
data - Данные для декодирования
off - Начальный сдвиг
length - Длина
out - Поток для записи
Returns:
the number of bytes produced.
Throws:
java.io.IOException

nextI

private int nextI(byte[] data,
                  int i,
                  int finish)
Parameters:
data -
i -
finish -
Returns:

decode

public int decode(java.lang.String data,
                  java.io.OutputStream out)
           throws java.io.IOException
decode the base 64 encoded String data writing it to the given output stream, whitespace characters will be ignored.

Specified by:
decode in interface Encoder
Parameters:
data - Данные для декодирования
out - Поток для записи
Returns:
the number of bytes produced.
Throws:
java.io.IOException

decodeLastBlock

private int decodeLastBlock(java.io.OutputStream out,
                            char c1,
                            char c2,
                            char c3,
                            char c4)
                     throws java.io.IOException
Parameters:
out -
c1 -
c2 -
c3 -
c4 -
Returns:
Throws:
java.io.IOException

nextI

private int nextI(java.lang.String data,
                  int i,
                  int finish)
Parameters:
data -
i -
finish -
Returns:


Copyright © 2013 Gamma Technologies. All Rights Reserved.