private Term<?> stripSlash(Term<?> src) { if (src.getOperator() == Operator.SLASH) { if (src instanceof TermLength) return tf.createLength((Float) src.getValue(), ((TermLength) src).getUnit()); else if (src instanceof TermPercent) return tf.createPercent((Float) src.getValue()); else return src; } else return src; }
public NodeData push(Declaration d) { Map<String,CSSProperty> properties = new HashMap<String,CSSProperty>(COMMON_DECLARATION_SIZE); Map<String,Term<?>> terms = new HashMap<String, Term<?>>(COMMON_DECLARATION_SIZE); boolean result = transformer.parseDeclaration(d, properties, terms); // in case of false do not insert anything if(!result) return this; //set the sources and store the properties for(Entry<String,CSSProperty> entry: properties.entrySet()) { propertiesOwn.put(entry.getKey(), entry.getValue()); sourcesOwn.put(entry.getKey(), d); } // remove operators from terms and store the values for(Entry<String,Term<?>> entry: terms.entrySet()) { Term<?> t = entry.getValue(); if (t.getOperator() != null) t = t.shallowClone().setOperator(null); valuesOwn.put(entry.getKey(), t); } return this; }
@Override public Object clone() { TermListImpl clone; { try { clone = (TermListImpl)super.clone(); } catch (CloneNotSupportedException e) { throw new InternalError("coding error"); } } clone.value = new ArrayList<Term<?>>(); for (Term<?> t : value) clone.value.add((Term<?>)t.clone()); return clone; } }
private static String serializeDeclaration(Declaration declaration) { String value = ""; for (Term<?> t : declaration) { if (!value.isEmpty()) { Term.Operator o = t.getOperator(); if (o != null) switch (o) { case COMMA: value += ","; } value += " "; } value += serializeTerm.apply(t); } return declaration.getProperty() + ": " + value + ";"; }
@Override public List<String> getUnicodeRanges() { Declaration decl = getDeclaration(PROPERTY_UNICODE_RANGE); if (decl != null) { List<String> ret = new ArrayList<>(decl.size()); for (Term<?> term : decl) { ret.add(term.getValue().toString()); } return ret; } else return null; }
public NodeData push(Declaration d) { Map<String,CSSProperty> properties = new HashMap<String,CSSProperty>(COMMON_DECLARATION_SIZE); Map<String,Term<?>> terms = new HashMap<String, Term<?>>(COMMON_DECLARATION_SIZE); boolean result = transformer.parseDeclaration(d, properties, terms); // in case of false do not insert anything if(!result) return this; this.propertiesOwn.putAll(properties); // remove operators from terms for(Entry<String,Term<?>> entry: terms.entrySet()) { entry.getValue().setOperator(null); valuesOwn.put(entry.getKey(), entry.getValue()); } return this; }
if (curOp.getValue() == '-') { Float newVal = -((TermFloatValue) curVal).getValue(); curVal = (TermFloatValue) curVal.shallowClone(); ((TermFloatValue) curVal).setValue(newVal); } else if (curOp.getValue() != '+') { if (curOp.getValue() == '-') { Float newVal = -((TermFloatValue) curVal).getValue(); curVal = (TermFloatValue) curVal.shallowClone(); ((TermFloatValue) curVal).setValue(newVal); } else if (curOp.getValue() != '+') {
@Override protected boolean variantCondition(int variant, IntegerRef iteration) { switch (variant) { case POSITION: if (variantPassed[SIZE]) return false; return terms.get(iteration.get()).getOperator() != Operator.SLASH; case SIZE: if (!variantPassed[POSITION]) return false; return terms.get(iteration.get()).getOperator() == Operator.SLASH; default: return true; } }
@Override public List<String> getUnicodeRanges() { Declaration decl = getDeclaration(PROPERTY_UNICODE_RANGE); if (decl != null) { List<String> ret = new ArrayList<>(decl.size()); for (Term<?> term : decl) { ret.add(term.getValue().toString()); } return ret; } else return null; }
public NodeData push(Declaration d) { Map<String,CSSProperty> properties = new HashMap<String,CSSProperty>(COMMON_DECLARATION_SIZE); Map<String,Term<?>> terms = new HashMap<String, Term<?>>(COMMON_DECLARATION_SIZE); boolean result = transformer.parseDeclaration(d, properties, terms); // in case of false do not insert anything if(!result) return this; this.propertiesOwn.putAll(properties); // remove operators from terms and set the sources for(Entry<String,Term<?>> entry: terms.entrySet()) { entry.getValue().setOperator(null); valuesOwn.put(entry.getKey(), entry.getValue()); sourcesOwn.put(entry.getKey(), d); } return this; }
if (curOp.getValue() == '-') { Float newVal = -((TermFloatValue) curVal).getValue(); curVal = (TermFloatValue) curVal.shallowClone(); ((TermFloatValue) curVal).setValue(newVal); } else if (curOp.getValue() != '+') { if (curOp.getValue() == '-') { Float newVal = -((TermFloatValue) curVal).getValue(); curVal = (TermFloatValue) curVal.shallowClone(); ((TermFloatValue) curVal).setValue(newVal); } else if (curOp.getValue() != '+') {
private Term<?> stripSlash(Term<?> src) { if (src.getOperator() == Operator.SLASH) { if (src instanceof TermLength) return tf.createLength((Float) src.getValue(), ((TermLength) src).getUnit()); else if (src instanceof TermPercent) return tf.createPercent((Float) src.getValue()); else return src; } else return src; }
@Override protected boolean variantCondition(int variant, IntegerRef iteration) { switch (variant) { case POSITION: if (variantPassed[SIZE]) return false; return terms.get(iteration.get()).getOperator() != Operator.SLASH; case SIZE: if (!variantPassed[POSITION]) return false; return terms.get(iteration.get()).getOperator() == Operator.SLASH; default: return true; } }
public NodeData push(Declaration d) { Map<String,CSSProperty> properties = new HashMap<String,CSSProperty>(COMMON_DECLARATION_SIZE); Map<String,Term<?>> terms = new HashMap<String, Term<?>>(COMMON_DECLARATION_SIZE); boolean result = transformer.parseDeclaration(d, properties, terms); // in case of false do not insert anything if(!result) return this; //set the sources and store the properties for(Entry<String,CSSProperty> entry: properties.entrySet()) { propertiesOwn.put(entry.getKey(), entry.getValue()); sourcesOwn.put(entry.getKey(), d); } // remove operators from terms and store the values for(Entry<String,Term<?>> entry: terms.entrySet()) { Term<?> t = entry.getValue(); if (t.getOperator() != null) t = t.shallowClone().setOperator(null); valuesOwn.put(entry.getKey(), t); } return this; }
public NodeData push(Declaration d) { Map<String,CSSProperty> properties = new HashMap<String,CSSProperty>(COMMON_DECLARATION_SIZE); Map<String,Term<?>> terms = new HashMap<String, Term<?>>(COMMON_DECLARATION_SIZE); boolean result = transformer.parseDeclaration(d, properties, terms); // in case of false do not insert anything if(!result) return this; for(String key: properties.keySet()) { Quadruple q = map.get(key); if(q==null) q = new Quadruple(); q.curProp = properties.get(key); q.curValue = terms.get(key); // remove operator if(q.curValue!=null) q.curValue = q.curValue.setOperator(null); map.put(key, q); } return this; }
@Override public Object clone() { DeclarationImpl clone; { try { clone = (DeclarationImpl)super.clone(); } catch (CloneNotSupportedException e) { throw new InternalError("coding error"); } } clone.list = new ArrayList<Term<?>>(); for (Term<?> t : list) clone.list.add((Term<?>)t.clone()); return clone; } }
private Term<?> stripSlash(Term<?> src) { if (src.getOperator() == Operator.SLASH) { if (src instanceof TermLength) return tf.createLength((Float) src.getValue(), ((TermLength) src).getUnit()); else if (src instanceof TermPercent) return tf.createPercent((Float) src.getValue()); else return src; } else return src; }
@Override protected boolean variantCondition(int variant, IntegerRef iteration) { switch (variant) { case POSITION: if (variantPassed[SIZE]) return false; return terms.get(iteration.get()).getOperator() != Operator.SLASH; case SIZE: if (!variantPassed[POSITION]) return false; return terms.get(iteration.get()).getOperator() == Operator.SLASH; default: return true; } }
public NodeData push(Declaration d) { Map<String,CSSProperty> properties = new HashMap<String,CSSProperty>(COMMON_DECLARATION_SIZE); Map<String,Term<?>> terms = new HashMap<String, Term<?>>(COMMON_DECLARATION_SIZE); boolean result = transformer.parseDeclaration(d, properties, terms); // in case of false do not insert anything if(!result) return this; for(String key: properties.keySet()) { Quadruple q = map.get(key); if(q==null) q = new Quadruple(); q.curProp = properties.get(key); q.curValue = terms.get(key); q.curSource = d; // remove operator if((q.curValue!=null) && (q.curValue.getOperator() != null)) { q.curValue = q.curValue.shallowClone().setOperator(null); } map.put(key, q); } return this; }