complex-barcode/maxicode-structured-second-message.js

const MwMaxiCodeStructuredSecondMessage = require("../_mwbridge/_mw-bridge.js").MwMaxiCodeStructuredSecondMessage;
const MaxiCodeSecondMessage = require("./maxicode-second-message");
const  BarcodeException  = require("../barcode-exception");

/**
 * Class for encoding and decoding structured second message for MaxiCode barcode.
 */
class MaxiCodeStructuredSecondMessage extends MaxiCodeSecondMessage
{
    constructor()
    {
        try
        {
            super(new MwMaxiCodeStructuredSecondMessage());
        }
        catch (ex)
        {
            throw new BarcodeException(ex);
        }
    }

    static _fromMwObject(mwObject)
    {
        let _class = new MaxiCodeStructuredSecondMessage();
        _class.setJavaClass(mwObject);

        return _class;
    }

    /**
     *  Gets year. Year must be 2 digit integer value.
     */
    getYear()
    {
        return this.getJavaClass().getYearSync();
    }

    /**
     *  Sets year. Year must be 2 digit integer value.
     */
    setYear(value)
    {
        this.getJavaClass().setYearSync(value);
    }

    /**
     *  Gets identifiers list
     * @return List of identifiers
     */
    getIdentifiers()
    {
        let identifiers_string = this.getJavaClass().getIdentifiersSync();
        let delimeter = "\\/\\";
        let identifiers = identifiers_string.split(delimeter);

        return identifiers;
    }

    /**
     * Adds new identifier
     * @param identifier Identifier to be added
     */
    add(identifier)
    {
        this.getJavaClass().addSync(identifier);
    }

    /**
     * Clear identifiers list
     */
    clear()
    {
        this.getJavaClass().clearSync();
    }

    /**
     * Gets constructed second message
     * @return Constructed second message
     */
    getMessage()
    {
        return this.getJavaClass().getMessageSync();
    }

    /**
     * Returns a value indicating whether this instance is equal to a specified <see cref="MaxiCodeStructuredSecondMessage"/> value.
     * @param obj "obj">An <see cref="MaxiCodeStructuredSecondMessage"/> value to compare to this instance.
     * @return <b>true</b> if obj has the same value as this instance; otherwise, <b>false</b>.
     */
    equals(obj)
    {
        return this.getJavaClass().equalsSync(obj.getJavaClass());
    }

    /**
     * Returns the hash code for this instance.
     * @return A 32-bit signed integer hash code.
     */
    getHashCode()
    {
        return this.getJavaClass().getHashCodeSync();
    }

    _initializeWrapperMembers()
    {
    }
}

module.exports = MaxiCodeStructuredSecondMessage