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 * Implementations convert Strings into byte arrays and vice versa.
023 * 
024 * @author joconnor
025 * @version $Revision$ $Date$
026 */
027public interface Interpreter
028{
029    /**
030         * Converts the string data into a different interpretation. Standard
031         * interpretations are ASCII, EBCDIC, BCD and LITERAL.
032         * 
033     * @throws ISOException on error
034         */
035    void interpret(String data, byte[] b, int offset) throws ISOException;
036
037    /**
038         * Converts the byte array into a String. This reverses the interpret
039         * method.
040         * 
041         * @param rawData
042         *            The interpreted data.
043         * @param offset
044         *            The index in rawData to start interpreting at.
045         * @param length
046         *            The number of data units to interpret.
047     * @throws ISOException on error
048         * @return The uninterpreted data.
049         */
050    String uninterpret(byte[] rawData, int offset, int length) throws ISOException;
051
052    /**
053         * Returns the number of bytes required to interpret a String of length
054         * nDataUnits.
055         */
056    int getPackedLength(int nDataUnits);
057}