Search in sources :

Example 1 with BeginHyphenAttributeCondition

use of com.gargoylesoftware.css.parser.condition.BeginHyphenAttributeCondition in project LoboEvolution by LoboEvolution.

the class CSS3Parser method attrib.

// 
// attrib
// : '[' S* IDENT S* [ [ '=' | INCLUDES | DASHMATCH | PREFIXMATCH | SUFFIXMATCH | SUBSTRINGMATCH ] S*
// [ IDENT | STRING ] S* ]? ']'
// ;
// 
public final Condition attrib(boolean pseudoElementFound) throws ParseException {
    Token t;
    String name = null;
    String value = null;
    int type = 0;
    Locator locator;
    try {
        jj_consume_token(LSQUARE);
        locator = createLocator(token);
        label_48: while (true) {
            switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
                case S:
                    {
                        ;
                        break;
                    }
                default:
                    jj_la1[74] = jj_gen;
                    break label_48;
            }
            jj_consume_token(S);
        }
        if (pseudoElementFound) {
            throw generateParseException();
        }
        t = jj_consume_token(IDENT);
        name = unescape(t.image, false);
        label_49: while (true) {
            switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
                case S:
                    {
                        ;
                        break;
                    }
                default:
                    jj_la1[75] = jj_gen;
                    break label_49;
            }
            jj_consume_token(S);
        }
        switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
            case INCLUDES:
            case DASHMATCH:
            case PREFIXMATCH:
            case SUFFIXMATCH:
            case SUBSTRINGMATCH:
            case EQUALS:
                {
                    switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
                        case PREFIXMATCH:
                            {
                                jj_consume_token(PREFIXMATCH);
                                type = 4;
                                break;
                            }
                        case SUFFIXMATCH:
                            {
                                jj_consume_token(SUFFIXMATCH);
                                type = 5;
                                break;
                            }
                        case SUBSTRINGMATCH:
                            {
                                jj_consume_token(SUBSTRINGMATCH);
                                type = 6;
                                break;
                            }
                        case EQUALS:
                            {
                                jj_consume_token(EQUALS);
                                type = 1;
                                break;
                            }
                        case INCLUDES:
                            {
                                jj_consume_token(INCLUDES);
                                type = 2;
                                break;
                            }
                        case DASHMATCH:
                            {
                                jj_consume_token(DASHMATCH);
                                type = 3;
                                break;
                            }
                        default:
                            jj_la1[76] = jj_gen;
                            jj_consume_token(-1);
                            throw new ParseException();
                    }
                    label_50: while (true) {
                        switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
                            case S:
                                {
                                    ;
                                    break;
                                }
                            default:
                                jj_la1[77] = jj_gen;
                                break label_50;
                        }
                        jj_consume_token(S);
                    }
                    switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
                        case IDENT:
                            {
                                t = jj_consume_token(IDENT);
                                value = unescape(t.image, false);
                                break;
                            }
                        case STRING:
                            {
                                t = jj_consume_token(STRING);
                                value = unescape(t.image, false);
                                break;
                            }
                        default:
                            jj_la1[78] = jj_gen;
                            jj_consume_token(-1);
                            throw new ParseException();
                    }
                    label_51: while (true) {
                        switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
                            case S:
                                {
                                    ;
                                    break;
                                }
                            default:
                                jj_la1[79] = jj_gen;
                                break label_51;
                        }
                        jj_consume_token(S);
                    }
                    break;
                }
            default:
                jj_la1[80] = jj_gen;
                ;
        }
        jj_consume_token(RSQUARE);
        Condition c = null;
        switch(type) {
            case 0:
                c = new AttributeCondition(name, null);
                break;
            case 1:
                c = new AttributeCondition(name, value);
                break;
            case 2:
                c = new OneOfAttributeCondition(name, value);
                break;
            case 3:
                c = new BeginHyphenAttributeCondition(name, value);
                break;
            case 4:
                c = new PrefixAttributeCondition(name, value);
                break;
            case 5:
                c = new SuffixAttributeCondition(name, value);
                break;
            case 6:
                c = new SubstringAttributeCondition(name, value);
                break;
        }
        c.setLocator(locator);
        return c;
    } catch (ParseException e) {
        throw toCSSParseException("invalidAttrib", e);
    }
}
Also used : SubstringAttributeCondition(com.gargoylesoftware.css.parser.condition.SubstringAttributeCondition) Condition(com.gargoylesoftware.css.parser.condition.Condition) IdCondition(com.gargoylesoftware.css.parser.condition.IdCondition) AttributeCondition(com.gargoylesoftware.css.parser.condition.AttributeCondition) PseudoClassCondition(com.gargoylesoftware.css.parser.condition.PseudoClassCondition) SuffixAttributeCondition(com.gargoylesoftware.css.parser.condition.SuffixAttributeCondition) BeginHyphenAttributeCondition(com.gargoylesoftware.css.parser.condition.BeginHyphenAttributeCondition) ClassCondition(com.gargoylesoftware.css.parser.condition.ClassCondition) LangCondition(com.gargoylesoftware.css.parser.condition.LangCondition) PrefixAttributeCondition(com.gargoylesoftware.css.parser.condition.PrefixAttributeCondition) OneOfAttributeCondition(com.gargoylesoftware.css.parser.condition.OneOfAttributeCondition) Locator(com.gargoylesoftware.css.parser.Locator) OneOfAttributeCondition(com.gargoylesoftware.css.parser.condition.OneOfAttributeCondition) SubstringAttributeCondition(com.gargoylesoftware.css.parser.condition.SubstringAttributeCondition) AttributeCondition(com.gargoylesoftware.css.parser.condition.AttributeCondition) SuffixAttributeCondition(com.gargoylesoftware.css.parser.condition.SuffixAttributeCondition) BeginHyphenAttributeCondition(com.gargoylesoftware.css.parser.condition.BeginHyphenAttributeCondition) PrefixAttributeCondition(com.gargoylesoftware.css.parser.condition.PrefixAttributeCondition) OneOfAttributeCondition(com.gargoylesoftware.css.parser.condition.OneOfAttributeCondition) CSSParseException(com.gargoylesoftware.css.parser.CSSParseException) BeginHyphenAttributeCondition(com.gargoylesoftware.css.parser.condition.BeginHyphenAttributeCondition) PrefixAttributeCondition(com.gargoylesoftware.css.parser.condition.PrefixAttributeCondition) SuffixAttributeCondition(com.gargoylesoftware.css.parser.condition.SuffixAttributeCondition) SubstringAttributeCondition(com.gargoylesoftware.css.parser.condition.SubstringAttributeCondition)

Aggregations

CSSParseException (com.gargoylesoftware.css.parser.CSSParseException)1 Locator (com.gargoylesoftware.css.parser.Locator)1 AttributeCondition (com.gargoylesoftware.css.parser.condition.AttributeCondition)1 BeginHyphenAttributeCondition (com.gargoylesoftware.css.parser.condition.BeginHyphenAttributeCondition)1 ClassCondition (com.gargoylesoftware.css.parser.condition.ClassCondition)1 Condition (com.gargoylesoftware.css.parser.condition.Condition)1 IdCondition (com.gargoylesoftware.css.parser.condition.IdCondition)1 LangCondition (com.gargoylesoftware.css.parser.condition.LangCondition)1 OneOfAttributeCondition (com.gargoylesoftware.css.parser.condition.OneOfAttributeCondition)1 PrefixAttributeCondition (com.gargoylesoftware.css.parser.condition.PrefixAttributeCondition)1 PseudoClassCondition (com.gargoylesoftware.css.parser.condition.PseudoClassCondition)1 SubstringAttributeCondition (com.gargoylesoftware.css.parser.condition.SubstringAttributeCondition)1 SuffixAttributeCondition (com.gargoylesoftware.css.parser.condition.SuffixAttributeCondition)1