Java Code Examples for cz.vutbr.web.css.Term#getOperator()
The following examples show how to use
cz.vutbr.web.css.Term#getOperator() .
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: DeclarationTransformerImpl.java From jStyleParser with GNU Lesser General Public License v3.0 | 6 votes |
@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 2
Source File: Decoder.java From jStyleParser with GNU Lesser General Public License v3.0 | 6 votes |
/** * Splits a declaration to multiple declarations by a separating term. * @param src the source declarations * @param separator separating operator * @return a list of declarations where each of them contains a sub-list of terms of the source declaration */ public static List<Declaration> splitDeclarations(Declaration src, Operator sepOperator) { final List<Declaration> ret = new ArrayList<>(); Declaration current = rf.createDeclaration(); current.unlock(); for (Term<?> t : src.asList()) { if (t.getOperator() == sepOperator) { ret.add(current); current = rf.createDeclaration(); current.unlock(); } current.add(t); } ret.add(current); return ret; }
Example 3
Source File: DeclarationTransformerImpl.java From jStyleParser with GNU Lesser General Public License v3.0 | 6 votes |
@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 4
Source File: DeclarationTransformerImpl.java From jStyleParser with GNU Lesser General Public License v3.0 | 6 votes |
@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 5
Source File: DeclarationTransformerImpl.java From jStyleParser with GNU Lesser General Public License v3.0 | 6 votes |
@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 6
Source File: DeclarationTransformerImpl.java From jStyleParser with GNU Lesser General Public License v3.0 | 6 votes |
@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 7
Source File: HtmlUtils.java From openemm with GNU Affero General Public License v3.0 | 6 votes |
/** * This method provides a workaround for bug in jStyleParser library that is currently used. To be used instead of * a plain {@link cz.vutbr.web.css.Declaration#toString()} method. * (see https://github.com/radkovo/jStyleParser/commit/356f39348929569eb8117bc14afd70687d6a23dc) * @param declaration CSS declaration representation to stringify. * @return a string representation of a CSS declaration. */ public static String toString(Declaration declaration) { StringBuilder sb = new StringBuilder(); sb.append(declaration.getProperty()).append(OutputUtil.PROPERTY_OPENING); for (Term<?> term : declaration.asList()) { if (term instanceof TermIntegerImpl) { Term.Operator operator = term.getOperator(); if (operator != null) { sb.append(operator.value()); } sb.append(term.toString()); } else { sb.append(term.toString()); } } if (declaration.isImportant()) { sb.append(OutputUtil.SPACE_DELIM).append(OutputUtil.IMPORTANT_KEYWORD); } sb.append(OutputUtil.PROPERTY_CLOSING.trim()); return sb.toString(); }
Example 8
Source File: DeclarationTransformerImpl.java From jStyleParser with GNU Lesser General Public License v3.0 | 6 votes |
@SuppressWarnings("unused") private boolean processAnimationName(Declaration d, Map<String, CSSProperty> properties, Map<String, Term<?>> values) { if(Decoder.genericOneIdent(AnimationName.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)) { return false; } list.add(t); } if(list.size() == 1) { properties.put(d.getProperty(), AnimationName.custom_ident); values.put(d.getProperty(), list.get(0)); } else { properties.put(d.getProperty(), AnimationName.list_values); values.put(d.getProperty(), list); } return true; }
Example 9
Source File: DeclarationTransformerImpl.java From jStyleParser with GNU Lesser General Public License v3.0 | 6 votes |
@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 10
Source File: DeclarationTransformerImpl.java From jStyleParser with GNU Lesser General Public License v3.0 | 6 votes |
@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 11
Source File: DeclarationTransformerImpl.java From jStyleParser with GNU Lesser General Public License v3.0 | 6 votes |
@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 12
Source File: DeclarationTransformerImpl.java From jStyleParser with GNU Lesser General Public License v3.0 | 5 votes |
@SuppressWarnings("unused") private boolean processAnimationIterationCount(Declaration d, Map<String, CSSProperty> properties, Map<String, Term<?>> values) { if(Decoder.genericOneIdentOrInteger(AnimationIterationCount.class, AnimationIterationCount.number, 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) { return false; } if (t instanceof TermIdent) { CSSProperty property = Decoder.genericPropertyRaw(AnimationIterationCount.class, null, (TermIdent) t); if (property == null) { return false; } } else if(t instanceof TermFloatValue) { if(!isPositive(t)) { return false; } } else { return false; } list.add(t); } properties.put(d.getProperty(), AnimationIterationCount.list_values); values.put(d.getProperty(), list); return true; }
Example 13
Source File: Variator.java From jStyleParser with GNU Lesser General Public License v3.0 | 5 votes |
/** * Tries a single variant that may consist of a term or a list of comma-separated terms. * * @param variant the variant to be tried * @param d the declaration to be processed * @param properties target property map * @param values target value map * @param listValue the list_values value to be used for the property value * @return {@code true} when parsed successfully */ public boolean tryListOfOneTermVariant(int variant, Declaration d, Map<String, CSSProperty> properties, Map<String, Term<?>> values, CSSProperty listValue) { // try inherit variant if (d.size() == 1 && checkInherit(variant, d.get(0), properties)) return true; //scan the list TermList list = tf.createList(); final Map<String, CSSProperty> p = new HashMap<>(); final Map<String, Term<?>> v = new HashMap<>(); boolean first = true; for (Term<?> t : d.asList()) { //terms must be separated by commas if ((first && t.getOperator() != null) || (!first && t.getOperator() != Operator.COMMA)) return false; //process the variant for a single term p.clear(); v.clear(); this.terms = new ArrayList<Term<?>>(); this.terms.add(t); if (!variant(variant, new IntegerRef(0), p, v)) return false; //collect the resulting term final CSSProperty prop = p.values().iterator().next(); final Term<?> val = (v.values().isEmpty()) ? null : v.values().iterator().next(); final TermPropertyValue pval = tf.createPropertyValue(prop, val); if (!first) pval.setOperator(Operator.COMMA); list.add(pval); first = false; } //store the result properties.put(names.get(variant), listValue); values.put(names.get(variant), list); return true; }
Example 14
Source File: DeclarationTransformerImpl.java From jStyleParser with GNU Lesser General Public License v3.0 | 5 votes |
@SuppressWarnings("unused") private boolean processTransitionTimingFunction(Declaration d, Map<String, CSSProperty> properties, Map<String, Term<?>> values) { if(Decoder.genericOneIdent(TransitionTimingFunction.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(TransitionTimingFunction.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(), TransitionTimingFunction.timing_function); values.put(d.getProperty(), list.get(0)); } else { properties.put(d.getProperty(), TransitionTimingFunction.list_values); values.put(d.getProperty(), list); } return true; }
Example 15
Source File: DeclarationTransformerImpl.java From jStyleParser with GNU Lesser General Public License v3.0 | 5 votes |
@SuppressWarnings("unused") private boolean processTransitionProperty(Declaration d, Map<String, CSSProperty> properties, Map<String, Term<?>> values) { if(Decoder.genericOneIdent(TransitionProperty.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(TransitionProperty.class, null, (TermIdent) t); if (property == TransitionProperty.NONE) { return false; } } else { return false; } list.add(t); } if(list.size() == 1) { properties.put(d.getProperty(), TransitionProperty.custom_ident); values.put(d.getProperty(), list.get(0)); } else { properties.put(d.getProperty(), TransitionProperty.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 |
@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: BorderRadiusRepeater.java From jStyleParser with GNU Lesser General Public License v3.0 | 5 votes |
private Term<?> stripSlash(Term<?> src) { if (src.getOperator() == Operator.SLASH) { if (src instanceof TermLength) return tf.createLength((java.lang.Float) src.getValue(), ((TermLength) src).getUnit()); else if (src instanceof TermPercent) return tf.createPercent((java.lang.Float) src.getValue()); else return src; } else return src; }
Example 18
Source File: RuleFontFaceImpl.java From jStyleParser with GNU Lesser General Public License v3.0 | 5 votes |
private String checkForFormat(Term<?> term) { if (term instanceof TermFunction && term.getOperator() == Operator.SPACE) { final TermFunction fn = (TermFunction) term; if (fn.getFunctionName().equalsIgnoreCase("format") && fn.size() == 1 && fn.get(0) instanceof TermString) { return ((TermString) fn.get(0)).getValue(); } else return null; } else return null; }
Example 19
Source File: DeclarationTransformerImpl.java From jStyleParser with GNU Lesser General Public License v3.0 | 4 votes |
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 20
Source File: DeclarationTransformerImpl.java From jStyleParser with GNU Lesser General Public License v3.0 | 4 votes |
@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)); }