Java Code Examples for cz.vutbr.web.css.Declaration#get()

The following examples show how to use cz.vutbr.web.css.Declaration#get() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FunctionsTest.java    From jStyleParser with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Test
public void rectFunctions() throws IOException, CSSException
{
       StyleSheet ss1 = CSSFactory.parseString(TEST_RECT1, null);
       assertEquals("Two properties are accepted", 2, ss1.get(0).size());
       Declaration d1 = (Declaration) ss1.get(0).get(0);
       TermRect r1 = (TermRect) d1.get(0);
       assertEquals("The last one is a correct length", tf.createLength(2f, Unit.ch), r1.getValue().get(3));
    
       StyleSheet ss2 = CSSFactory.parseString(TEST_RECT2, null);
       assertEquals("Two properties are accepted", 2, ss2.get(0).size());
       Declaration d2 = (Declaration) ss2.get(0).get(0);
       TermRect r2 = (TermRect) d2.get(0);
       assertEquals("The last one is a correct length", tf.createLength(2f, Unit.ch), r2.getValue().get(3));
       
       StyleSheet ss3 = CSSFactory.parseString(TEST_RECT3, null);
       assertEquals("Two properties are accepted", 2, ss3.get(0).size());
       Declaration d3 = (Declaration) ss3.get(0).get(0);
       TermRect r3 = (TermRect) d3.get(0);
       assertEquals("The last one is a correct length", null, r3.getValue().get(3));
}
 
Example 2
Source File: DeclarationTransformerImpl.java    From jStyleParser with GNU Lesser General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("unused")
private boolean processAnimationPlayState(Declaration d, Map<String, CSSProperty> properties, Map<String, Term<?>> values) {
    if(Decoder.genericOneIdent(AnimationPlayState.class, d, properties)) {
        return true;
    }
    TermList list = tf.createList();
    for (int i = 0; i < d.size(); i++) {
        Term<?> t = d.get(i);
        if ((i == 0 || t.getOperator() == Operator.COMMA) && t instanceof TermIdent) {
            CSSProperty property = Decoder.genericPropertyRaw(AnimationPlayState.class, null, (TermIdent) t);
            if (property == null) {
                return false;
            }
        } else {
            return false;
        }
        list.add(t);
    }
    properties.put(d.getProperty(), AnimationPlayState.list_values);
    values.put(d.getProperty(), list);
    return true;
}
 
Example 3
Source File: DeclarationTransformerImpl.java    From jStyleParser with GNU Lesser General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("unused")
private boolean processTransitionDelay(Declaration d, Map<String, CSSProperty> properties, Map<String, Term<?>> values) {
    if (Decoder.genericTime(TransitionDelay.class, TransitionDelay.time, ValueRange.DISALLOW_NEGATIVE, d, properties, values)) {
        return true;
    }
    TermList list = tf.createList();
    for (int i = 0; i < d.size(); i++) {
        Term<?> t = d.get(i);
        if ((i == 0 || t.getOperator() == Operator.COMMA) && t instanceof TermTime) {
            if (!isPositive(t)) {
                return false;
            }
        } else {
            return false;
        }
        list.add(t);
    }
    properties.put(d.getProperty(), TransitionDelay.list_values);
    values.put(d.getProperty(), list);
    return true;
}
 
Example 4
Source File: DeclarationTransformerImpl.java    From jStyleParser with GNU Lesser General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("unused")
private boolean processTransitionDuration(Declaration d, Map<String, CSSProperty> properties, Map<String, Term<?>> values) {
    if (Decoder.genericTime(TransitionDuration.class, TransitionDuration.time, ValueRange.DISALLOW_NEGATIVE, d, properties, values)) {
        return true;
    }
    TermList list = tf.createList();
    for (int i = 0; i < d.size(); i++) {
        Term<?> t = d.get(i);
        if ((i == 0 || t.getOperator() == Operator.COMMA) && t instanceof TermTime) {
            if(!isPositive(t)) {
                return false;
            }
        } else {
            return false;
        }
        list.add(t);
    }
    properties.put(d.getProperty(), TransitionDuration.list_values);
    values.put(d.getProperty(), list);
    return true;
}
 
Example 5
Source File: DeclarationTransformerImpl.java    From jStyleParser with GNU Lesser General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("unused")
private boolean processAnimationFillMode(Declaration d, Map<String, CSSProperty> properties, Map<String, Term<?>> values) {
    if(Decoder.genericOneIdent(AnimationFillMode.class, d, properties)) {
        return true;
    }
    TermList list = tf.createList();
    for (int i = 0; i < d.size(); i++) {
        Term<?> t = d.get(i);
        if ((i == 0 || t.getOperator() == Operator.COMMA) && t instanceof TermIdent) {
            CSSProperty property = Decoder.genericPropertyRaw(AnimationFillMode.class, null, (TermIdent) t);
            if (property == null) {
                return false;
            }
        } else {
            return false;
        }
        list.add(t);
    }
    properties.put(d.getProperty(), AnimationFillMode.list_values);
    values.put(d.getProperty(), list);
    return true;
}
 
Example 6
Source File: DeclarationTransformerImpl.java    From jStyleParser with GNU Lesser General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("unused")
private boolean processAnimationDuration(Declaration d, Map<String, CSSProperty> properties, Map<String, Term<?>> values) {
    if (Decoder.genericTime(AnimationDuration.class, AnimationDuration.time, ValueRange.DISALLOW_NEGATIVE, d, properties, values)) {
        return true;
    }
    TermList list = tf.createList();
    for (int i = 0; i < d.size(); i++) {
        Term<?> t = d.get(i);
        if ((i == 0 || t.getOperator() == Operator.COMMA) && t instanceof TermTime) {
            if(!isPositive(t)) {
                return false;
            }
        } else {
            return false;
        }
        list.add(t);
    }
    properties.put(d.getProperty(), AnimationDuration.list_values);
    values.put(d.getProperty(), list);
    return true;
}
 
Example 7
Source File: DeclarationTransformerImpl.java    From jStyleParser with GNU Lesser General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("unused")
private boolean processAnimationDirection(Declaration d, Map<String, CSSProperty> properties, Map<String, Term<?>> values) {
    if(Decoder.genericOneIdent(AnimationDirection.class, d, properties)) {
        return true;
    }
    TermList list = tf.createList();
    for (int i = 0; i < d.size(); i++) {
        Term<?> t = d.get(i);
        if ((i == 0 || t.getOperator() == Operator.COMMA) && t instanceof TermIdent) {
            CSSProperty property = Decoder.genericPropertyRaw(AnimationDirection.class, null, (TermIdent) t);
            if (property == null) {
                return false;
            }
        } else {
            return false;
        }
        list.add(t);
    }
    properties.put(d.getProperty(), AnimationDirection.list_values);
    values.put(d.getProperty(), list);
    return true;
}
 
Example 8
Source File: DeclarationTransformerImpl.java    From jStyleParser with GNU Lesser General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("unused")
private boolean processAnimationDelay(Declaration d, Map<String, CSSProperty> properties, Map<String, Term<?>> values) {
    if (Decoder.genericTime(AnimationDelay.class, AnimationDelay.time, ValueRange.DISALLOW_NEGATIVE, d, properties, values)) {
        return true;
    }
    TermList list = tf.createList();
    for (int i = 0; i < d.size(); i++) {
        Term<?> t = d.get(i);
        if ((i == 0 || t.getOperator() == Operator.COMMA) && t instanceof TermTime) {
            if (!isPositive(t)) {
                return false;
            }
        } else {
            return false;
        }
        list.add(t);
    }
    properties.put(d.getProperty(), AnimationDelay.list_values);
    values.put(d.getProperty(), list);
    return true;
}
 
Example 9
Source File: Decoder.java    From jStyleParser with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static <T extends CSSProperty> boolean genericInteger(
        Class<T> type, T integerIdentification, ValueRange range,
        Declaration d, Map<String, CSSProperty> properties,
        Map<String, Term<?>> values) {

    if (d.size() != 1)
        return false;
    
    Term<?> term = d.get(0);
    if (term instanceof TermIdent)
    {
        T property = genericPropertyRaw(type, null, (TermIdent) term);
        if (!property.equalsInherit())
            return false;
        else
        {
            properties.put(d.getProperty(), property);
            return true;
        }
    }
    else
    {
        return genericTerm(TermInteger.class, term, d.getProperty(), integerIdentification, range, properties, values);
    }
}
 
Example 10
Source File: DeclarationTransformerImpl.java    From jStyleParser with GNU Lesser General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("unused")
private boolean processGridGap(Declaration d, Map<String, CSSProperty> properties, Map<String, Term<?>> values) {
    Term<?> rowGapTerm, columnGapTerm;
    switch (d.size()) {
        case 1:
            rowGapTerm = columnGapTerm = d.get(0);
            break;
        case 2:
            rowGapTerm = d.get(0);
            columnGapTerm = d.get(1);
            break;
        default:
            return false;
    }
    return (Decoder.genericTermIdent(GridGap.class, rowGapTerm, Decoder.ALLOW_INH, "grid-row-gap", properties)
            || Decoder.genericTermLength(rowGapTerm, "grid-row-gap", GridGap.length, ValueRange.DISALLOW_NEGATIVE, properties, values)
            || Decoder.genericTerm(TermPercent.class, rowGapTerm, "grid-row-gap", GridGap.length, ValueRange.DISALLOW_NEGATIVE, properties, values))
            && (Decoder.genericTermIdent(GridGap.class, columnGapTerm, Decoder.ALLOW_INH, "grid-column-gap", properties)
            || Decoder.genericTermLength(columnGapTerm, "grid-column-gap", GridGap.length, ValueRange.DISALLOW_NEGATIVE, properties, values)
            || Decoder.genericTerm(TermPercent.class, columnGapTerm, "grid-column-gap", GridGap.length, ValueRange.DISALLOW_NEGATIVE, properties, values));
}
 
Example 11
Source File: DeclarationTransformerImpl.java    From jStyleParser with GNU Lesser General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("unused")
private boolean processUnicodeRange(Declaration d,
		Map<String, CSSProperty> properties, Map<String, Term<?>> values) {
    
	if (d.size() > 0) {
	    TermList list = tf.createList();
	    for (int i = 0; i < d.size(); i++) {
	        Term<?> term = d.get(i);
	        if (term instanceof TermUnicodeRange
	                && ((i == 0 && term.getOperator() == null) || (i != 0 && term.getOperator() == Operator.COMMA))) {
	            list.add(term);
	        } else {
	            return false;
	        }
	    }
	    properties.put("unicode-range", UnicodeRange.list_values);
	    values.put("unicode-range", list);
	    return true;
	}
	else
	    return false;
}
 
Example 12
Source File: DeclarationTransformerImpl.java    From jStyleParser with GNU Lesser General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("unused")
private boolean processOverflow(Declaration d,
		Map<String, CSSProperty> properties, Map<String, Term<?>> values) {
    
    if (d.size() == 1) {
        Term<?> term = d.get(0);
        if (term instanceof TermIdent) {
            return Decoder.genericProperty(Overflow.class, (TermIdent) term, Decoder.ALLOW_INH, properties, "overflow-x")
                    && Decoder.genericProperty(Overflow.class, (TermIdent) term, Decoder.ALLOW_INH, properties, "overflow-y");
        }
        else
            return false;
    }
    else
        return false;
}
 
Example 13
Source File: RuleFontFaceImpl.java    From jStyleParser with GNU Lesser General Public License v3.0 6 votes vote down vote up
private String getStringValue(String propertyName) 
{
    Declaration decl = getDeclaration(propertyName);
	if (decl == null) {
		return null;
	}
	
	Term<?> term= decl.get(0);
	if (term == null) {
		return null;
	}
	
	Object value = term.getValue();
	if (!(value instanceof String)) {
		return null;
	}
	
	return (String)value;
}
 
Example 14
Source File: DeclarationTransformerImpl.java    From jStyleParser with GNU Lesser General Public License v3.0 5 votes vote down vote up
private boolean processGridStartEnd(Declaration d, Map<String, CSSProperty> properties, Map<String, Term<?>> values) {
    if (d.isEmpty()) {
        return false;
    }
    if (Decoder.genericOneIdentOrInteger(GridStartEnd.class, GridStartEnd.number, ValueRange.DISALLOW_ZERO, d, properties, values)) {
        return !GridStartEnd.SPAN.equals(properties.get(d.getProperty()));
    }
    // auto | <custom-ident> | [ <integer> && <custom-ident>? ] | [ span && [ <integer> || <custom-ident> ] ]
    int valueValue = 0;
    int valueIndex = -1;
    int spanIndex = -1;
    int identIndex = -1;
    TermList list = tf.createList();
    for (int i = 0; i < d.size(); i++) {
        Term<?> t = d.get(i);
        if (t instanceof TermIdent) {
            CSSProperty property = Decoder.genericPropertyRaw(GridStartEnd.class, null, (TermIdent) t);
            if (GridStartEnd.SPAN.equals(property) && spanIndex < 0 && (valueIndex < 0 || valueValue > 0)) {
                spanIndex = i;
            } else if (property == null && identIndex < 0 
                    && (spanIndex < 0 || valueIndex < 0 || spanIndex < valueIndex)) {
                identIndex = i;
            } else {
                return false;
            }
        } else if (t instanceof TermInteger && ((TermInteger) t).getIntValue() != 0
                && (spanIndex < 0 || ((TermInteger) t).getIntValue() > 0)
                && valueIndex < 0 && (identIndex < 0 || identIndex > spanIndex)) {
            valueValue = ((TermInteger) t).getIntValue();
            valueIndex = i;
        } else {
            return false;
        }
        list.add(t);
    }
    return setStartEndProperties(d.getProperty(), list, properties, values);
}
 
Example 15
Source File: DeclarationTransformerImpl.java    From jStyleParser with GNU Lesser General Public License v3.0 5 votes vote down vote up
private boolean processGridTemplateRowsColumns(Declaration d, Map<String, CSSProperty> properties, Map<String, Term<?>> values) {
    if (d.isEmpty()) {
        return false;
    }
    if (Decoder.genericOneIdent(GridTemplateRowsColumns.class, d, properties)) {
        return true;
    }
    TermList list = tf.createList();
    boolean bracketedIdentUsed = false;
    boolean repeatUsed = false;
    for (int i = 0; i < d.size(); i++) {
        Term<?> t = d.get(i);
        if (t instanceof TermIdent) {
            CSSProperty property = Decoder.genericPropertyRaw(GridTemplateRowsColumns.class, null, (TermIdent) t);
            if (property == null || property == GridTemplateRowsColumns.NONE) {
                return false;
            }
        } else if (t instanceof TermBracketedIdents) {
            if (bracketedIdentUsed) {
                return false;
            } else {
                bracketedIdentUsed = true;
                list.add(t);
                continue;
            }
        } else if (t instanceof TermFunction.Repeat && !repeatUsed) {
            repeatUsed = true;
        } else if (!(t instanceof TermLengthOrPercent)
                && !(t instanceof TermFunction.MinMax)
                && !(t instanceof TermFunction.FitContent)) {
            return false;
        }
        list.add(t);
        bracketedIdentUsed = false;
    }
    properties.put(d.getProperty(), GridTemplateRowsColumns.list_values);
    values.put(d.getProperty(), list);
    return true;
}
 
Example 16
Source File: DeclarationTransformerImpl.java    From jStyleParser with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("unused")
private boolean processAnimationTimingFunction(Declaration d, Map<String, CSSProperty> properties, Map<String, Term<?>> values) {
    if(Decoder.genericOneIdent(AnimationTimingFunction.class, d, properties)) {
        return true;
    }
    TermList list = tf.createList();
    for (int i = 0; i < d.size(); i++) {
        Term<?> t = d.get(i);
        if(i > 0 && t.getOperator() != Operator.COMMA) {
            return false;
        }
        if (t instanceof TermIdent) {
            CSSProperty property = Decoder.genericPropertyRaw(AnimationTimingFunction.class, null, (TermIdent) t);
            if (property == null) {
                return false;
            }
        } else if (!(t instanceof TermFunction.TimingFunction)) {
            return false;
        }
        list.add(t);
    }
    if(list.size() == 1) {
        properties.put(d.getProperty(), AnimationTimingFunction.timing_function);
        values.put(d.getProperty(), list.get(0));
    } else {
        properties.put(d.getProperty(), AnimationTimingFunction.list_values);
        values.put(d.getProperty(), list);
    }
    return true;
}
 
Example 17
Source File: DeclarationTransformerImpl.java    From jStyleParser with GNU Lesser General Public License v3.0 4 votes vote down vote up
private boolean processPropertiesInList(String[] propertyList, Declaration d, Map<String, CSSProperty> properties, Map<String, Term<?>> values) {
    Declaration subDeclaration = (Declaration) rf.createDeclaration().unlock();
    TermList[] termLists = new TermList[propertyList.length];
    for (int i = 0; i < termLists.length; i++) termLists[i] = tf.createList();
    boolean[] propertySet = new boolean[propertyList.length];
    Arrays.fill(propertySet, false);

    for (int i = 0; i < d.size(); i++) {
        Term<?> t = d.get(i);
        subDeclaration.add(t);
        if (t.getOperator() == Operator.COMMA) {
            Arrays.fill(propertySet, false);
        }
        for (int propertyIndex = 0; propertyIndex <= propertyList.length; propertyIndex++) {
            if (propertyIndex == propertyList.length) {
                return false;
            }
            if (propertySet[propertyIndex]) {
                continue;
            }
            subDeclaration.setProperty(propertyList[propertyIndex]);
            if (parseDeclaration(subDeclaration, properties, values)) {
                propertySet[propertyIndex] = true;
                t.setOperator(termLists[propertyIndex].isEmpty() ? null : Operator.COMMA);
                termLists[propertyIndex].add(t);
                break;
            }
        }
        subDeclaration.clear();
    }

    for (int propertyIndex = 0; propertyIndex < propertyList.length; propertyIndex++) {
        subDeclaration.setProperty(propertyList[propertyIndex]);
        subDeclaration.addAll(termLists[propertyIndex]);
        if (!subDeclaration.isEmpty() && !parseDeclaration(subDeclaration, properties, values)) {
            return false;
        }
        subDeclaration.clear();
    }
    return true;
}
 
Example 18
Source File: DeclarationTransformerImpl.java    From jStyleParser with GNU Lesser General Public License v3.0 4 votes vote down vote up
private boolean processNStartEnds(int n, String[] propertyNames,
        Declaration d, Map<String, CSSProperty> properties, Map<String, Term<?>> values) {
    if (n != propertyNames.length) {
        return false;
    }
    TermList[] lists = new TermList[n];
    for (int i = 0; i < n; i++) {
        lists[i] = tf.createList();
    }
    Map<String, TermList> identOnly = new HashMap<>();
    int listIndex = 0;
    // auto | <custom-ident> | [ <integer> && <custom-ident>? ] | [ span && [ <integer> || <custom-ident> ] ]
    int valueValue = 0;
    int valueIndex = -1;
    int spanIndex = -1;
    int identIndex = -1;
    boolean autoSet = false;
    
    for (int i = 0; i < d.size(); i++) {
        Term<?> t = d.get(i);
        if (t.getOperator() == Term.Operator.SLASH) {
            if(!autoSet && spanIndex < 0 && valueIndex < 0) {
                identOnly.put(propertyNames[listIndex], lists[listIndex]);
            }
            listIndex++;
            valueIndex = -1;
            spanIndex = -1;
            identIndex = -1;
            autoSet = false;
            if (listIndex >= n) {
                return false;
            }
        }
        if (t instanceof TermIdent) {
            CSSProperty property = Decoder.genericPropertyRaw(GridStartEnd.class, null, (TermIdent) t);
            if (GridStartEnd.AUTO.equals(property) && lists[listIndex].isEmpty()) {
                autoSet = true;
            } else if (GridStartEnd.SPAN.equals(property) && spanIndex < 0 && !autoSet
                     &&(valueIndex < 0 || valueValue > 0)) {
                spanIndex = i;
            } else if (property == null && identIndex < 0 
                    && (spanIndex < 0 || valueIndex < 0 || spanIndex < valueIndex) && !autoSet) {
                identIndex = i;
            } else {
                return false;
            }
        } else if (t instanceof TermInteger && ((TermInteger) t).getIntValue() != 0
                && (spanIndex < 0 || ((TermInteger) t).getIntValue() > 0)
                && valueIndex < 0 && (identIndex < 0 || identIndex > spanIndex) && !autoSet) {
            valueValue = ((TermInteger) t).getIntValue();
            valueIndex = i;
        } else {
            return false;
        }
        lists[listIndex].add(t);
    }
    if(!autoSet && spanIndex < 0 && valueIndex < 0) {
        identOnly.put(propertyNames[listIndex], lists[listIndex]);
    }
    
    for (int i = 1; i < n; i++) {
        if(i <= listIndex) { // Property set explicitly
            setStartEndProperties(propertyNames[i], lists[i], properties, values);
        } else {
            switch(propertyNames[i]) { // Inherit indentifier from other property from declaration
                case "grid-column-start":
                    if(identOnly.containsKey("grid-row-start")) {
                        setStartEndProperties(propertyNames[i], identOnly.get("grid-row-start"), properties, values);
                    }
                    break;
                case "grid-row-end":
                    if(identOnly.containsKey("grid-row-start")) {
                        setStartEndProperties(propertyNames[i], identOnly.get("grid-row-start"), properties, values);
                    }
                    break;
                case "grid-column-end":
                    if(identOnly.containsKey("grid-column-start")) {
                        setStartEndProperties(propertyNames[i], identOnly.get("grid-column-start"), properties, values);
                    } else if(identOnly.containsKey("grid-row-start")) {
                        setStartEndProperties(propertyNames[i], identOnly.get("grid-row-start"), properties, values);
                    }
                    break;
            }
        }
    }
    return setStartEndProperties(propertyNames[0], lists[0], properties, values);
}
 
Example 19
Source File: DeclarationTransformerImpl.java    From jStyleParser with GNU Lesser General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("unused")
private boolean processGrid(Declaration d, Map<String, CSSProperty> properties, Map<String, Term<?>> values) {
    // <'grid-template'> 
    // | <'grid-template-rows'> / [ auto-flow && dense? ] <'grid-auto-columns'>?
    // | [ auto-flow && dense? ] <'grid-auto-rows'>? / <'grid-template-columns'>
    Declaration templateDecl = rf.createDeclaration(d);
    templateDecl.setProperty("grid-template");
    if (processGridTemplate(templateDecl, properties, values)) {
        return true;
    }

    boolean beforeSlash = true;
    boolean autoFlowBeforeSlash = false;
    Declaration autoFlowDecl = (Declaration) rf.createDeclaration().unlock();
    autoFlowDecl.setProperty("grid-auto-flow");
    Declaration templateRowsDecl = (Declaration) rf.createDeclaration().unlock();
    templateRowsDecl.setProperty("grid-template-rows");
    Declaration autoRowsDecl = (Declaration) rf.createDeclaration().unlock();
    autoRowsDecl.setProperty("grid-auto-rows");
    Declaration templateColumnsDecl = (Declaration) rf.createDeclaration().unlock();
    templateColumnsDecl.setProperty("grid-template-columns");
    Declaration autoColumnsDecl = (Declaration) rf.createDeclaration().unlock();
    autoColumnsDecl.setProperty("grid-auto-columns");

    for (int i = 0; i < d.size(); i++) {
        Term<?> t = d.get(i);
        if (t.getOperator() == Term.Operator.SLASH) {
            beforeSlash = false;
        }

        if (t instanceof TermIdent) {
            CSSProperty property = Decoder.genericPropertyRaw(Grid.class, null, (TermIdent) t);
            if (Grid.AUTO_FLOW.equals(property)) {
                if (beforeSlash) {
                    autoFlowDecl.add(tf.createIdent("row"));
                } else {
                    autoFlowDecl.add(tf.createIdent("column"));
                }
                autoFlowBeforeSlash = beforeSlash;
                continue;
            } else {
                property = Decoder.genericPropertyRaw(GridAutoFlow.class, null, (TermIdent) t);
                if (GridAutoFlow.DENSE.equals(property)) {
                    autoFlowDecl.add(t);
                    continue;
                }
            }
        }

        if (autoFlowDecl.isEmpty()) {
            if (beforeSlash) {
                templateRowsDecl.add(t);
            }
        } else {
            if (beforeSlash) {
                autoRowsDecl.add(t);
            } else if (autoFlowBeforeSlash) {
                templateColumnsDecl.add(t);
            } else {
                autoColumnsDecl.add(t);
            }
        }
    }
    processGridAutoRows(autoRowsDecl, properties, values);
    processGridAutoColumns(autoColumnsDecl, properties, values);

    return processGridAutoFlow(autoFlowDecl, properties, values)
            && (processGridTemplateRows(templateRowsDecl, properties, values)
            || processGridTemplateColumns(templateColumnsDecl, properties, values));
}
 
Example 20
Source File: FunctionsTest.java    From jStyleParser with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Test
public void contentValid() throws IOException, CSSException
{
    for (int i = 0; i < TEST_CONTENT.length; i++)
    {
        StyleSheet ss = CSSFactory.parseString(TEST_CONTENT[i], null);
        //System.out.println(i + " ss: " + ss);
        assertEquals("One rule is parset [" + i + "]", 1, ss.size());
        assertEquals("One property is set [" + i + "]", 1, ss.get(0).size());
        Declaration d = (Declaration) ss.get(0).get(0);
        TermFunction fn = (TermFunction) d.get(0);
        //System.out.println(i + ": " + d);
        switch (i)
        {
            case 0:
                assertEquals(AttrImpl.class, fn.getClass());
                assertEquals("Name is correct", "title", ((AttrImpl) fn).getName());
                break;
            case 1:
                assertEquals(CounterImpl.class, fn.getClass());
                assertEquals("Name is correct", "chapter_counter", ((CounterImpl) fn).getName());
                assertNull("Style is not set", ((CounterImpl) fn).getStyle());
                break;
            case 2:
                assertEquals(CounterImpl.class, fn.getClass());
                assertEquals("Name is correct", "chapter_counter", ((CounterImpl) fn).getName());
                assertEquals("Style is correct", CSSProperty.ListStyleType.LOWER_ALPHA, ((CounterImpl) fn).getStyle()); 
                break;
            case 3:
                assertEquals(CountersImpl.class, fn.getClass());
                assertEquals("Name is correct", "chapter_counter", ((CountersImpl) fn).getName());
                assertEquals("Separator is correct", "..", ((CountersImpl) fn).getSeparator());
                assertNull("Style is not set", ((CountersImpl) fn).getStyle());
                break;
            case 4:
                assertEquals(CountersImpl.class, fn.getClass());
                assertEquals("Name is correct", "chapter_counter", ((CountersImpl) fn).getName());
                assertEquals("Separator is correct", "::", ((CountersImpl) fn).getSeparator());
                assertEquals("Style is correct", CSSProperty.ListStyleType.LOWER_ROMAN, ((CountersImpl) fn).getStyle()); 
                break;
            case 5:
                assertEquals(CounterImpl.class, fn.getClass());
                assertEquals("Name is correct", "c", ((CounterImpl) fn).getName());
                assertEquals("Style is correct", CSSProperty.ListStyleType.NONE, ((CounterImpl) fn).getStyle());
                TermString str = (TermString) d.get(1);
                assertEquals("String is parsed", "z", str.getValue());
                break;
        }
    }
}