package com.jscape.inet.terminal;

/**
 * Sequence type with '#', '(', ')' second sequence character.
 * In general there are three characters in such sequence type: "\033SC",
 * where S is an intermediate symbol ('#', '(', ')'), C - alpha or digit
 * character.
 */
public class ICType
        implements SequenceType {

    private static final ICType INSTANCE = new ICType();

    //----------------------------------------------------------------------------

    /**
     * Returns one and only one instance of this type.
     *
     * @return one and only one instance of <code>ICType</code> object.
     */
    public static ICType getInstance() {
        return INSTANCE;
    }

    //----------------------------------------------------------------------------

    /**
     * Private constructor to prevent uncontrolled creation.
     */
    private ICType() {
    }

    //----------------------------------------------------------------------------

    /**
     * Checks if sequence is complete.
     *
     * @param value sequence value.
     *
     * @return true if sequence is complete.
     */
    public boolean isComplete(StringBuffer value) {
        return (value.length() == 3);
    }

    //----------------------------------------------------------------------------

    /**
     * Extracts and returns sequence parameters as array of <code>int</code>.
     *
     * @param value sequence value.
     *
     * @return array of <code>int</code>.
     */
    public int[] getParameters(StringBuffer value) {
        return new int[0];
    }

    //----------------------------------------------------------------------------

    /**
     * Returns "canonical" form of control sequence (i.e. without parameters).
     * For example: having "\033#7" incoming sequence its "canonical" form
     * will be "\033#7".
     *
     * @param value sequence value.
     *
     * @return string with "canonical" sequence form.
     */
    public String getCanonicalForm(StringBuffer value) {
        return value.toString();
    }

}