complex-barcode/usa-drive-id-codetext.js

const IComplexCodetext = require("./i-complex-codetext");
const {MwUSADriveIdCodetext, J_ArrayList} = require("../_mwbridge/_mw-bridge");
const USADriveIdJurisdSubfile = require("./usa-drive-id-jurisd-subfile");
const OptionalFields = require("./optional-fields");
const MandatoryFields = require("./mandatory-fields");
const {_internalCtor} = require("./subfile-properties");


/**
 * <p>
 * Class for encoding and decoding the text embedded in the USA Driving License PDF417 code.
 * </p>
 */
class USADriveIdCodetext extends IComplexCodetext
{

    constructor(usaDriveIdCodetext)
    {
        super(usaDriveIdCodetext != null ? usaDriveIdCodetext : new MwUSADriveIdCodetext);
    }

    _initializeWrapperMembers()
    {
        this.auto_JurisdictionSpecificSubfile = new USADriveIdJurisdSubfile(this.getJavaClass().getJurisdictionSpecificSubfileSync());
        this.auto_OptionalElements = new OptionalFields(this.getJavaClass().getOptionalElementsSync());
        this.auto_MandatoryElements = new MandatoryFields(this.getJavaClass().getMandatoryElementsSync());
    }
    /**
     * <p>
     * This number uniquely identifies
     * the issuing jurisdiction and can be obtained by contacting the ISO
     * Issuing Authority(AAMVA).  The full 6-digit IIN should be encoded.
     * </p>
     */
    getIssuerIdentificationNumber()
    {
        return this.getJavaClass().getIssuerIdentificationNumberSync();
    }
    /**
     * <p>
     * This number uniquely identifies
     * the issuing jurisdiction and can be obtained by contacting the ISO
     * Issuing Authority(AAMVA).  The full 6-digit IIN should be encoded.
     * </p>
     */
    setIssuerIdentificationNumber(value)
    {
        this.getJavaClass().setIssuerIdentificationNumberSync(value);
    }
    /**
     * <p>
     * AAMVA Version Number 00-99
     * </p>
     */
    getAAMVAVersionNumber()
    {
        return this.getJavaClass().getAAMVAVersionNumberSync();
    }
    /**
     * <p>
     * AAMVA Version Number 00-99
     * </p>
     */
    setAAMVAVersionNumber(value)
    {
        this.getJavaClass().setAAMVAVersionNumberSync(value);
    }
    /**
     * <p>
     * Jurisdiction Version Number 00-99
     * </p>
     */
    getJurisdictionVersionNumber()
    {
        return this.getJavaClass().getJurisdictionVersionNumberSync();
    }
    /**
     * <p>
     * Jurisdiction Version Number 00-99
     * </p>
     */
    setJurisdictionVersionNumber(value)
    {
        this.getJavaClass().setJurisdictionVersionNumberSync(value);
    }
    /**
     * <p>
     * Number 00-99 of subfiles
     * </p>
     */
    getNumberOfEntries()
    {
        return this.getJavaClass().getNumberOfEntriesSync();
    }
    /**
     * <p>
     * Number 00-99 of subfiles
     * </p>
     */
    setNumberOfEntries(value)
    {
        this.getJavaClass().setNumberOfEntriesSync(value);
    }
    /**
     * <p>
     * Contains information about following subfiles, types, offsets and lengths.
     * Important: set only type, offset and length will be set automatically.
     * </p>
     */
    getSubfileDesignator()
    {
        const javaSubfileDesignatorList = this.getJavaClass().getSubfileDesignatorSync();

        let subfileDesignator = [];
        for(let i = 0; i < javaSubfileDesignatorList.sizeSync(); i++)
        {
            subfileDesignator.push(_internalCtor(javaSubfileDesignatorList.getSync(i)));
        }

        return subfileDesignator;
    }
    /**
     * <p>
     * Contains information about following subfiles, types, offsets and lengths.
     * Important: set only type, offset and length will be set automatically.
     * </p>
     */
    addSubfileDesignator(value)
    {
        this.getJavaClass().addSubfileDesignatorSync(value.getJavaClass());
    }

    /**
     * <p>
     * Contains information about following subfiles, types, offsets and lengths.
     * Important: set only type, offset and length will be set automatically.
     * </p>
     */
    setSubfileDesignator(value)
    {
        let subfileDesignatorJava = new J_ArrayList();

        for(let i = 0; i < value.length; i++)
        {
            subfileDesignatorJava.addSync(value[i].getJavaClass());
        }

        this.getJavaClass().setSubfileDesignatorSync(subfileDesignatorJava);
    }

    /**
     * <p>
     * Mandatory elements (fields) of the card
     * </p>
     */
    getMandatoryElements()
    {
        return this.auto_MandatoryElements;
    }
    /**
     * <p>
     * Mandatory elements (fields) of the card
     * </p>
     */
    setMandatoryElements(value)
    {
        this.auto_MandatoryElements = value;
        this.getJavaClass().setMandatoryElementsSync(value.getJavaClass());
    }

    /**
     * <p>
     * Optional elements (fields) of the card
     * </p>
     */
    getOptionalElements()
    {
        return this.auto_OptionalElements;
    }
    /**
     * <p>
     * Optional elements (fields) of the card
     * </p>
     */
    setOptionalElements(value)
    {
        this.auto_OptionalElements = value;
        this.getJavaClass().setOptionalElementsSync(value.getJavaClass());
    }

    /**
     * <p>
     * Jurisdiction Specific Fields
     * </p>
     */
    getJurisdictionSpecificSubfile()
    {
        return this.auto_JurisdictionSpecificSubfile;
    }
    /**
     * <p>
     * Jurisdiction Specific Fields
     * </p>
     */
    setJurisdictionSpecificSubfile(value)
    {
        this.auto_JurisdictionSpecificSubfile = value;
        this.getJavaClass().setJurisdictionSpecificSubfileSync(value.getJavaClass());
    }

    /**
     * <p>
     * Construct codetext from USA DL data
     * </p>
     * @return Constructed codetext
     */
    getConstructedCodetext()
    {
        return this.getJavaClass().getConstructedCodetextSync();
    }

    /**
     * <p>
     * Initialize USA DL object from codetext
     * </p>
     * @param constructedCodetext Constructed codetext
     */
    initFromString(constructedCodetext)
    {
        this.getJavaClass().initFromStringSync(constructedCodetext);
        this._initializeWrapperMembers();
    }

    /**
     * <p>
     * Returns barcode type of USA DL (Pdf417)
     * </p>
     * @return Barcode type (Pdf417)
     */
    getBarcodeType()
    {
        return this.getJavaClass().getBarcodeTypeSync();
    }

    saveToXml()
    {
        let buf = Buffer.from(this.getJavaClass().saveToXmlSync(), "base64");

        let xml = buf.toString("utf8");
        if (xml.charCodeAt(0) === 0xfeff) xml = xml.slice(1);

        return xml;
    }
}

module.exports = USADriveIdCodetext