001package Torello.CSS;
002
003import java.util.Vector;
004
005@Torello.JavaDoc.JDHeaderBackgroundImg(EmbedTagFileID="CSS_TOK")
006public class Func extends Identifier
007    implements CharSequence, java.io.Serializable, Comparable<CharSequence>
008{
009    /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */
010    protected static final long serialVersionUID = 1;
011
012
013    // ********************************************************************************************
014    // ********************************************************************************************
015    // Private Constructor, API "is" and "if" Methods
016    // ********************************************************************************************
017    // ********************************************************************************************
018
019
020    Func(
021            final int[]     css,
022            final int       sPos,
023            final int       ePos,
024            final String    functionName
025        )
026    { super(css, sPos, ePos, functionName); }
027
028    @Override 
029    public final boolean isFunc() { return true; }
030
031    @Override
032    public final Func ifFunc() { return this; }
033
034
035    // ********************************************************************************************
036    // ********************************************************************************************
037    // User's Constructor: a static "build" method
038    // ********************************************************************************************
039    // ********************************************************************************************
040
041
042    /**
043     * <EMBED CLASS=defs DATA-TOK=Func DATA-P=funcIdentifier>
044     * <EMBED CLASS='external-html' DATA-FILE-ID=BUILD_DESC>
045     * @param funcIdentifier <EMBED CLASS='external-html' DATA-FILE-ID=BUILD_PARAM>
046     * @return <EMBED CLASS='external-html' DATA-FILE-ID=BUILD_RET>
047     * @throws TokenizeException <EMBED CLASS='external-html' DATA-FILE-ID=BUILD_TOK_EX>
048     */
049    @SuppressWarnings("unchecked")
050    public static Func build(final String funcIdentifier)
051    {
052        return (Func) CSSToken.build
053            (funcIdentifier, INPUT_CHECKER, Identifier::consumeIdentLikeSequence);
054    }
055
056    private static final CSSToken.InputChecker INPUT_CHECKER = (int[] css) ->
057    {
058        if (css.length < 2) throw new TokenizeException(Func.class);
059
060        if (css[css.length - 1] != '(') throw new TokenizeException
061            ("Input String does not end with a Left-Parenthesis");
062
063        if (! Identifier.startsIdentSequence(css, 0)) throw new TokenizeException
064            ("String-text beginning does not constitute a valid CSS Function-Token");
065    };
066}