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.packager;
020
021import org.jpos.iso.ISOException;
022import org.jpos.iso.ISOFieldPackager;
023import org.jpos.iso.X92_BITMAP;
024
025import java.io.InputStream;
026
027/**
028 * ISO-8583 packager for the X9.2 generic message format.
029 * @see GenericPackager
030 * @author Alejandro Revilla
031 * @version $$evision: $ $Date$
032 */
033
034public class X92GenericPackager extends GenericPackager {
035    /** Shared bitmap packager used by X9.2 messages. */
036    protected static ISOFieldPackager bitMapPackager =
037        new X92_BITMAP (16, "X9.2 BIT MAP");
038
039    /**
040     * Default constructor.
041     *
042     * @throws ISOException if the underlying packager cannot be initialized
043     */
044    public X92GenericPackager() throws ISOException {
045        super();
046    }
047    /**
048     * Constructs a packager loading its field descriptions from an XML file.
049     *
050     * @param filename XML descriptor file
051     * @throws ISOException if the file cannot be read or parsed
052     */
053    public X92GenericPackager(String filename) throws ISOException {
054        super(filename);
055    }
056    /**
057     * Constructs a packager loading its field descriptions from an XML stream.
058     *
059     * @param stream XML descriptor input stream
060     * @throws ISOException if the stream cannot be read or parsed
061     */
062    public X92GenericPackager(InputStream stream) throws ISOException {
063        super(stream);
064    }
065    /**
066     * @return Bitmap's ISOFieldPackager
067     */
068    protected ISOFieldPackager getBitMapfieldPackager() {
069        return bitMapPackager;
070    }
071    /**
072     * Although field 1 is not a Bitmap ANSI X9.2 do have
073     * a Bitmap field that have to be packed/unpacked
074     * @see org.jpos.iso.ISOBasePackager
075     * @return true
076     */
077    protected boolean emitBitMap () {
078        return true;
079    }
080    /**
081     * @return 64 for ANSI X9.2
082     */
083    protected int getMaxValidField() {
084        return 64;
085    }
086}
087