001package Torello.CSS;
002
003/**
004 * This exception will be thrown by the Static-Build Methods offered by each of the individual
005 * {@link CSSToken} Classes if the User provides faulty {@code String}-Input.
006 */
007public class TokenizeException extends RuntimeException 
008{
009    /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */
010    protected static final long serialVersionUID = 1;
011
012    /** Constructs a {@code TokenizeException} with no detail message. */
013    public TokenizeException()
014    { super(); }
015
016    /**
017     * Constructs a {@code TokenizeException} with the specified detail message.
018     * @param message the detail message.
019     */
020    public TokenizeException(String message)
021    { super(message); }
022
023
024    // Constructors invoked by CSSToken.build (there are 2 "build" methods in that class)
025    // That is the super / parent "build" method for all subclass build methods (except URLToken)
026    //
027    // These methods are package-private because they don't serve any purpose whatsoever to an
028    // API-User writing code using Torello.CSS.  These are strictly internal
029
030    TokenizeException(String inputStr, String tokenizedStr)
031    {
032        this(
033            "The Tokenzier was unable to convert the entire Input-String provided into a single " +
034            "CSSToken instance. In tokenizing Input-String:\n" +
035            "\t[" + inputStr + "] - Length: " + inputStr.length() + "] characters\n" +
036            "The following partially tokenized Output-String was generated:\n" +
037            "\t[" + tokenizedStr + "] - Length: " + tokenizedStr.length() + "] characters"
038        );
039    }
040
041    // This one is also a constructor used by CSSToken's two "build" methods
042    TokenizeException(Class<? extends CSSToken> tokenClass)
043    {
044        this(
045            "The Input-String provided does not contain enough character data to form a " +
046            "CSSToken '" + tokenClass.getSimpleName()  + "' instance."
047        );
048    }
049}