001/* 002 * jPOS Project [http://jpos.org] 003 * Copyright (C) 2000-2026 jPOS Software SRL 004 * 005 * This program is free software: you can redistribute it and/or modify 006 * it under the terms of the GNU Affero General Public License as 007 * published by the Free Software Foundation, either version 3 of the 008 * License, or (at your option) any later version. 009 * 010 * This program is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 013 * GNU Affero General Public License for more details. 014 * 015 * You should have received a copy of the GNU Affero General Public License 016 * along with this program. If not, see <http://www.gnu.org/licenses/>. 017 */ 018 019package org.jpos.iso; 020 021/** 022 * This interface supports the encoding and decoding of binary data. Common 023 * implementations are literal or no conversion, ASCII Hex, EBCDIC Hex and BCD. 024 * 025 * @author joconnor 026 * @version $Revision$ $Date$ 027 */ 028public interface BinaryInterpreter 029{ 030 /** 031 * Converts the binary data into a different interpretation or coding. Standard 032 * interpretations are ASCII Hex, EBCDIC Hex, BCD and LITERAL. 033 * 034 * @param data 035 * The data to be interpreted. 036 * @param b The byte array to write the interpreted data to. 037 * @param offset The starting position in b. 038 */ 039 void interpret(byte[] data, byte[] b, int offset); 040 041 /** 042 * Converts the raw byte array into a uninterpreted byte array. This reverses the 043 * interpret method. 044 * 045 * @param rawData 046 * The interpreted data. 047 * @param offset 048 * The index in rawData to start uninterpreting at. 049 * @param length 050 * The number of uninterpreted bytes to uninterpret. This number may be 051 * different from the number of raw bytes that are uninterpreted. 052 * @return The uninterpreted data. 053 */ 054 byte[] uninterpret(byte[] rawData, int offset, int length); 055 056 /** 057 * Returns the number of bytes required to interpret a byte array of length 058 * nBytes. 059 */ 060 int getPackedLength(int nBytes); 061}