/** * Uses variator functionality to test selected variant on more terms. This * is used when variant is represented by more terms. Since usually only one * term per variant is used, only one multiple variant is allowed per * variator and should be placed as the last one * * @param variant * Number of variant (last variant in variator) * @param properties * Properties map where to store property type * @param values * Values map where to store property value * @param terms * Array of terms used for variant * @return <code>true</code> in case of success, <code>false</code> * otherwise */ public boolean tryMultiTermVariant(int variant, Map<String, CSSProperty> properties, Map<String, Term<?>> values, Term<?>... terms) { this.terms = Arrays.asList(terms); // try inherit variant if (this.terms.size() == 1 && checkInherit(variant, this.terms.get(0), properties)) return true; return variant(variant, new IntegerRef(0), properties, values); }
@Override protected boolean variant(int v, IntegerRef iteration, Map<String, CSSProperty> properties, Map<String, Term<?>> values) { // we won't use multivalue functionallity int i = iteration.get(); switch (v) { case COLOR: // process color return genericTermIdent(types.get(COLOR), terms.get(i), AVOID_INH, names.get(COLOR), properties) || genericTermColor(terms.get(i), names.get(COLOR), OutlineColor.color, properties, values); case STYLE: // process style return genericTermIdent(types.get(STYLE), terms.get(i), AVOID_INH, names.get(STYLE), properties); case WIDTH: // process width return genericTermIdent(types.get(WIDTH), terms.get(i), AVOID_INH, names.get(WIDTH), properties) || genericTermLength(terms.get(i), names.get(WIDTH), OutlineWidth.length, ValueRange.DISALLOW_NEGATIVE, properties, values); default: return false; } } }
for (IntegerRef i = new IntegerRef(0); i.get() < terms.size(); i.inc()) {
for (IntegerRef i = new IntegerRef(0); i.get() < terms.size(); i.inc()) {
for (IntegerRef i = new IntegerRef(0); i.get() < terms.size(); i.inc()) {
for (IntegerRef i = new IntegerRef(0); i.get() < terms.size(); i.inc()) {
@Override protected boolean variant(int v, IntegerRef iteration, Map<String, CSSProperty> properties, Map<String, Term<?>> values) { // we won't use multivalue functionallity int i = iteration.get(); switch (v) { case COLOR: // process color return genericTermIdent(types.get(COLOR), terms.get(i), AVOID_INH, names.get(COLOR), properties) || genericTermColor(terms.get(i), names.get(COLOR), BorderColor.color, properties, values); case STYLE: // process style return genericTermIdent(types.get(STYLE), terms.get(i), AVOID_INH, names.get(STYLE), properties); case WIDTH: // process width return genericTermIdent(types.get(WIDTH), terms.get(i), AVOID_INH, names.get(WIDTH), properties) || genericTermLength(terms.get(i), names .get(WIDTH), BorderWidth.length, true, properties, values); default: return false; } } }
@Override protected boolean variant(int v, IntegerRef iteration, Map<String, CSSProperty> properties, Map<String, Term<?>> values) { // we won't use multivalue functionallity int i = iteration.get(); switch (v) { case COLOR: // process color return genericTermIdent(types.get(COLOR), terms.get(i), AVOID_INH, names.get(COLOR), properties) || genericTermColor(terms.get(i), names.get(COLOR), BorderColor.color, properties, values); case STYLE: // process style return genericTermIdent(types.get(STYLE), terms.get(i), AVOID_INH, names.get(STYLE), properties); case WIDTH: // process width return genericTermIdent(types.get(WIDTH), terms.get(i), AVOID_INH, names.get(WIDTH), properties) || genericTermLength(terms.get(i), names.get(WIDTH), BorderWidth.length, ValueRange.DISALLOW_NEGATIVE, properties, values); default: return false; } } }
@Override protected boolean variant(int v, IntegerRef iteration, Map<String, CSSProperty> properties, Map<String, Term<?>> values) { // we won't use multivalue functionallity int i = iteration.get(); switch (v) { case TYPE: // list style type return genericTermIdent(ListStyleType.class, terms.get(i), AVOID_INH, names.get(TYPE), properties); case POSITION: // list style position return genericTermIdent(ListStylePosition.class, terms.get(i), AVOID_INH, names.get(POSITION), properties); case IMAGE: // list style image return genericTermIdent(types.get(IMAGE), terms.get(i), AVOID_INH, names.get(IMAGE), properties) || genericTerm(TermURI.class, terms.get(i), names .get(IMAGE), ListStyleImage.uri, ValueRange.ALLOW_ALL, properties, values); default: return false; } } }
/** * Uses variator functionality to test selected variant on term * * @param variant * Which variant will be tested * @param d * The declaration on which variant will be tested * @param properties * Properties map where to store property type * @param values * Values map where to store property value * @return <code>true</code> in case of success, <code>false</code> * otherwise */ public boolean tryOneTermVariant(int variant, Declaration d, Map<String, CSSProperty> properties, Map<String, Term<?>> values) { // only one term is allowed if (d.size() != 1) return false; // try inherit variant if (checkInherit(variant, d.get(0), properties)) return true; this.terms = new ArrayList<Term<?>>(); this.terms.add(d.get(0)); return variant(variant, new IntegerRef(0), properties, values); }
@Override protected boolean variant(int v, IntegerRef iteration, Map<String, CSSProperty> properties, Map<String, Term<?>> values) { // we won't use multivalue functionallity int i = iteration.get(); switch (v) { case COLOR: // process color return genericTermIdent(types.get(COLOR), terms.get(i), AVOID_INH, names.get(COLOR), properties) || genericTermColor(terms.get(i), names.get(COLOR), BorderColor.color, properties, values); case STYLE: // process style return genericTermIdent(types.get(STYLE), terms.get(i), AVOID_INH, names.get(STYLE), properties); case WIDTH: // process width return genericTermIdent(types.get(WIDTH), terms.get(i), AVOID_INH, names.get(WIDTH), properties) || genericTermLength(terms.get(i), names.get(WIDTH), BorderWidth.length, ValueRange.DISALLOW_NEGATIVE, properties, values); default: return false; } } }
/** * Uses variator functionality to test selected variant on term * * @param variant * Which variant will be tested * @param d * The declaration on which variant will be tested * @param properties * Properties map where to store property type * @param values * Values map where to store property value * @return <code>true</code> in case of success, <code>false</code> * otherwise */ public boolean tryOneTermVariant(int variant, Declaration d, Map<String, CSSProperty> properties, Map<String, Term<?>> values) { // only one term is allowed if (d.size() != 1) return false; // try inherit variant if (checkInherit(variant, d.get(0), properties)) return true; this.terms = new ArrayList<Term<?>>(); this.terms.add(d.get(0)); return variant(variant, new IntegerRef(0), properties, values); }