public abstract class Variator extends Object
border: blue 1px| Modifier and Type | Class and Description |
|---|---|
protected static class |
Variator.IntegerRef
Reference to integer
|
| Modifier and Type | Field and Description |
|---|---|
protected static int |
ALL_VARIANTS
All variants flag
|
protected List<String> |
names
Property names according to each variant
|
protected List<Term<?>> |
terms
Terms over which variants are tested
|
protected List<Class<? extends CSSProperty>> |
types |
protected boolean[] |
variantPassed
Results of variants.
|
protected int |
variants
Total variants available
|
| Constructor and Description |
|---|
Variator(int variants)
Creates variator which contains
variants variants to be
tested |
| Modifier and Type | Method and Description |
|---|---|
void |
assignDefaults(Map<String,CSSProperty> properties,
Map<String,Term<?>> values)
Assigns the default values to all the properties.
|
void |
assignTerms(Term<?>... terms)
Assigns terms to be checked by variator
|
void |
assignTermsFromDeclaration(Declaration d)
Assigns terms from declaration
|
void |
assignVariantPropertyNames(String... variantPropertyNames)
Assigns property names for each variant
|
protected boolean |
checkInherit(int variant,
Term<?> term,
Map<String,CSSProperty> properties)
Solves variant which leads to
inherit CSS Property value. |
boolean |
tryMultiTermVariant(int variant,
Map<String,CSSProperty> properties,
Map<String,Term<?>> values,
Term<?>... terms)
Uses variator functionality to test selected variant on more terms.
|
boolean |
tryOneTermVariant(int variant,
Declaration d,
Map<String,CSSProperty> properties,
Map<String,Term<?>> values)
Uses variator functionality to test selected variant on term
|
protected abstract boolean |
variant(int variant,
Variator.IntegerRef iteration,
Map<String,CSSProperty> properties,
Map<String,Term<?>> values)
This function contains parsing block for variants
|
protected boolean |
variantCondition(int variant,
Variator.IntegerRef term)
Check if variant, which was passed is able to be located in place where it was
found.
|
boolean |
vary(Map<String,CSSProperty> properties,
Map<String,Term<?>> values)
Test all terms
|
protected static final int ALL_VARIANTS
protected int variants
protected boolean[] variantPassed
protected List<Class<? extends CSSProperty>> types
public Variator(int variants)
variants variants to be
testedvariants - protected abstract boolean variant(int variant,
Variator.IntegerRef iteration,
Map<String,CSSProperty> properties,
Map<String,Term<?>> values)
variant - Tested variantiteration - Number of iteration, that is term to be tested.
This number may be changed internally in function
to inform that more than one term was used for variantproperties - Properties map where to store properties typesvalues - Values map where to store properties valuestrue in case of success, false
otherwiseprotected boolean checkInherit(int variant,
Term<?> term,
Map<String,CSSProperty> properties)
inherit CSS Property value.
This overrides all other possible variants and no other informations are
allowed per CSS Declaration.
This method is called before check for variants or before variant itself
is called in one shot way.
Example: margin: inherit is valid value and leads to setting
of
margin-top: inheritmargin-right: inheritmargin-bottom: inheritmargin-left: inheritmargin: 0px inherit is invalid value.variant - Number of variant or identifier of all variants
VARIANT_ALLproperties - Properties map where to store properties typesterm - Term to be checkedtrue in case of success, false
otherwiseprotected boolean variantCondition(int variant,
Variator.IntegerRef term)
font: 12px/14px sans-serif
Then according to grammar:
[
[ <'font-style'> || <'font-variant'> || <'font-weight'> ]?
<'font-size'>
[ / <'line-height'> ]?
<'font-family'>
]
| caption | icon | menu | message-box |
small-caption | status-bar | inherit
12px is assigned to font-size14px is checked to have SLASH operator before
and check to whether font-size was defined before itsans-serif is tested to have at least
definition of font-size before itselfvariant - Identification of current variant which passed testterm - Position in term list of terms which passed test, for multiple
value term allow to change ittrue in case of success, false elsewhereTerm.Operatorpublic boolean vary(Map<String,CSSProperty> properties, Map<String,Term<?>> values)
public boolean tryOneTermVariant(int variant,
Declaration d,
Map<String,CSSProperty> properties,
Map<String,Term<?>> values)
variant - Which variant will be testedd - The declaration on which variant will be testedproperties - Properties map where to store property typevalues - Values map where to store property valuetrue in case of success, false
otherwisepublic boolean tryMultiTermVariant(int variant,
Map<String,CSSProperty> properties,
Map<String,Term<?>> values,
Term<?>... terms)
variant - Number of variant (last variant in variator)properties - Properties map where to store property typevalues - Values map where to store property valueterms - Array of terms used for varianttrue in case of success, false
otherwisepublic void assignVariantPropertyNames(String... variantPropertyNames)
variantPropertyNames - List of property namespublic void assignTerms(Term<?>... terms)
terms - Terms to be assignedpublic void assignTermsFromDeclaration(Declaration d)
d - Declaration which contains termsCopyright © 2014. All rights reserved.