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
021import java.io.Serializable;
022
023/**
024 * Represents the optional header portion of an ISO-8583 message frame.
025 * @author Eoin.Flood@orbiscom.com
026 */
027
028public interface ISOHeader extends Cloneable,Serializable
029{
030    /**
031     * Packs this header into a byte array.
032     * @return this header serialised as a byte array
033     */
034    byte[] pack();
035
036    /**
037     * Unpacks the header from a raw byte array.
038     * @param b raw bytes to parse
039     * @return the number of bytes consumed
040     */
041    int unpack(byte[] b);
042
043    /**
044     * Sets the destination address in this ISOHeader.
045     * @param dst the destination address
046     */
047    void setDestination(String dst);
048
049    /**
050     * Returns the destination address in this ISOHeader.
051     * @return the destination address, or null if not set
052     */
053    String getDestination();
054
055    /**
056     * Sets the source address in this ISOHeader.
057     * @param src the source address
058     */
059    void setSource(String src);
060
061    /**
062     * Returns the source address in this ISOHeader.
063     * @return the source address, or null if not set
064     */
065    String getSource();
066
067    /**
068     * Returns the number of bytes in this ISOHeader when packed.
069     * @return header length in bytes
070     */
071    int getLength();
072
073    /**
074     * Swaps the source and destination addresses in this ISOHeader (if they exist).
075     */
076    void swapDirection();
077
078    /**
079     * Returns a clone of this ISOHeader.
080     * @return cloned ISOHeader instance
081     */
082    Object clone();
083}