kz.gamma.hardware.util.encoders
Class HexEncoder

java.lang.Object
  extended by kz.gamma.hardware.util.encoders.HexEncoder
All Implemented Interfaces:
Encoder

public class HexEncoder
extends java.lang.Object
implements Encoder

HEX кодировщик


Field Summary
protected  byte[] decodingTable
           
protected  byte[] encodingTable
          Таблица кодирования
 
Constructor Summary
HexEncoder()
          Конструктор
 
Method Summary
 int decode(byte[] data, int off, int length, java.io.OutputStream out)
          decode the Hex 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 Hex encoded String data writing it to the given output stream, whitespace characters will be ignored.
 int encode(byte[] data, int off, int length, java.io.OutputStream out)
          encode the input data producing a Hex output stream.
private  boolean ignore(char c)
          Игнорирование символов '\n', '\r', '\t', ' '
protected  void initialiseDecodingTable()
          Инициализация таблицы декодирования
 
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
Таблица кодирования


decodingTable

protected final byte[] decodingTable
Constructor Detail

HexEncoder

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

Method Detail

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 Hex 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 Hex 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

decode

public int decode(java.lang.String data,
                  java.io.OutputStream out)
           throws java.io.IOException
decode the Hex 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


Copyright © 2013 Gamma Technologies. All Rights Reserved.