java.lang.Object
io.sf.carte.doc.style.css.property.ValueFactory
Factory of CSS values.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThe return value ofparseBracketList(LexicalUnit, AbstractCSSStyleDeclaration, boolean). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionappendMinifiedValueString(StringBuilder buf, LexicalUnit lunit) appendValueString(StringBuilder buf, LexicalUnit lunit) createCSSValue(LexicalUnit lunit) Creates a CSSValue according to the given lexical value.createCSSValue(LexicalUnit lunit, AbstractCSSStyleDeclaration style) Creates a CSSValue according to the given lexical value.createCSSValueItem(LexicalUnit lunit, boolean subproperty) Creates a CSSValue simple item according to the given lexical value.static shortdomPrimitiveType(short sacType) Translate a SAC lexical type into a CSS primitive unit type.booleanhasFactoryFlag(byte flag) Check whether the factory has the given flag set.static booleanisAngleSACUnit(LexicalUnit unit) Tests whether the given SAC unit type is an angle unit.static booleanisNumericSACUnit(LexicalUnit unit) Tests whether the given SAC unit type is numeric.static booleanTests whether the given SAC unit type is a plain number (real or integer) or a percentage.static booleanTests whether the given SAC value can represent a size greater than zero (e.g. font size).static booleanTests whether the unit type of the given SAC lexical unit is a resolution unit.static booleanTests whether the given SAC unit type is a size or numeric unit.static booleanisSizeSACUnit(LexicalUnit unit) Tests whether the unit type of the given SAC lexical unit can apply to size (e.g.static booleanisTimeSACUnit(LexicalUnit unit) Tests whether the given SAC unit type is a time unit.parseBracketList(LexicalUnit nlu, AbstractCSSStyleDeclaration style, boolean subproperty) Parse a bracket list.parseMediaFeature(String feature) Parses a feature value.parseMediaFeature(String feature, Parser2 parser) Parses a feature value.parseProperty(String value) Parses a property value.parseProperty(String propertyName, String value, CSSParser parser) Parses a property value with the supplied parser.parseProperty(String propertyName, String value, Parser parser) Parses a property value with the supplied parser.parseProperty(String value, Parser parser) Parses a property value with the supplied parser.
-
Constructor Details
-
ValueFactory
public ValueFactory() -
ValueFactory
public ValueFactory(byte flags)
-
-
Method Details
-
isSizeSACUnit
Tests whether the unit type of the given SAC lexical unit can apply to size (e.g. block size).- Parameters:
unit- the SAC lexical unit.- Returns:
trueif it is a size type (including percentage and unknown dimension), false otherwise.
-
isResolutionSACUnit
Tests whether the unit type of the given SAC lexical unit is a resolution unit.- Parameters:
unit- the SAC lexical unit value.- Returns:
trueif it is a resolution type,falseotherwise.
-
isPositiveSizeSACUnit
Tests whether the given SAC value can represent a size greater than zero (e.g. font size).- Parameters:
unit- the lexical value.- Returns:
trueif it is a size type (including percentage and unknown dimension), false otherwise.
-
isSizeOrNumberSACUnit
Tests whether the given SAC unit type is a size or numeric unit.- Parameters:
unit- the lexical value.- Returns:
trueif it is a size or numeric type (including percentage and unknown dimension), false otherwise.
-
isPlainNumberOrPercentSACUnit
Tests whether the given SAC unit type is a plain number (real or integer) or a percentage.- Parameters:
unit- the lexical value.- Returns:
trueif is a plain number or a percentage,falseotherwise.
-
isNumericSACUnit
Tests whether the given SAC unit type is numeric.- Parameters:
unit- the lexical value.- Returns:
trueif is a numeric type,falseotherwise.
-
isAngleSACUnit
Tests whether the given SAC unit type is an angle unit.- Parameters:
unit- the lexical value.- Returns:
trueif is an angle type,falseotherwise.
-
isTimeSACUnit
Tests whether the given SAC unit type is a time unit.- Parameters:
unit- the lexical value.- Returns:
trueif is a time type,falseotherwise.
-
parseProperty
Parses a property value. Assumes that the property is not a shorthand sub-property.- Parameters:
value- the string containing the property value.- Returns:
- the CSSValue object containing the parsed value.
- Throws:
DOMException- if a problem was found parsing the property.
-
parseProperty
Parses a property value with the supplied parser.- Parameters:
value- the string containing the property value.parser- the SAC parser.- Returns:
- the CSSValue object containing the parsed value.
- Throws:
DOMException- if a problem was found parsing the property.
-
parseProperty
public StyleValue parseProperty(String propertyName, String value, CSSParser parser) throws DOMException Parses a property value with the supplied parser.- Parameters:
propertyName- the string containing the property name.value- the string containing the property value.parser- the SAC parser.- Returns:
- the CSSValue object containing the parsed value.
- Throws:
DOMException- if a problem was found parsing the property.
-
parseProperty
public StyleValue parseProperty(String propertyName, String value, Parser parser) throws DOMException Parses a property value with the supplied parser.- Parameters:
value- the string containing the property value.parser- the SAC parser.- Returns:
- the CSSValue object containing the parsed value.
- Throws:
DOMException- if a problem was found parsing the property.
-
parseMediaFeature
Parses a feature value.- Parameters:
feature- the string containing the feature value- Returns:
- the CSSPrimitiveValue object containing the parsed value.
- Throws:
DOMException- if a problem was found parsing the feature.
-
parseMediaFeature
Parses a feature value.- Parameters:
feature- the string containing the feature value.parser- the parser used to parse values.- Returns:
- the CSSPrimitiveValue object containing the parsed value.
- Throws:
DOMException- if a problem was found parsing the feature.
-
createCSSValue
Creates a CSSValue according to the given lexical value.The value is assumed to be stand-alone, independent of a shorthand property.
- Parameters:
lunit- the lexical value.- Returns:
- a CSSValue associated to the given lexical value, or null if the lexical unit was not appropriate.
- Throws:
DOMException- if the lexical unit had a wrong content to create a value.
-
createCSSValue
public StyleValue createCSSValue(LexicalUnit lunit, AbstractCSSStyleDeclaration style) throws DOMException Creates a CSSValue according to the given lexical value.The value is assumed to be stand-alone, independent of a shorthand property.
- Parameters:
lunit- the lexical value.style- the (style) declaration that should handle errors, or null to not handle errors.- Returns:
- a CSSValue associated to the given lexical value, or null if the lexical unit was not appropriate.
- Throws:
DOMException- if the lexical unit had a wrong content to create a value.
-
parseBracketList
public ValueFactory.ListValueItem parseBracketList(LexicalUnit nlu, AbstractCSSStyleDeclaration style, boolean subproperty) Parse a bracket list.- Parameters:
nlu- the lexical unit containing the first item in the bracket list.style- the style declaration to report issues to.subproperty-trueif the value must be a subproperty.- Returns:
- the bracket list, or
nullif the list was empty.
-
createCSSValueItem
Creates a CSSValue simple item according to the given lexical value.This method either returns a value or throws an exception, but cannot return null.
- Parameters:
lunit- the lexical value.subproperty- true if the value is created under the umbrella of a shorthand set.- Returns:
- a ValueItem associated to the given lexical value.
- Throws:
DOMException- if a problem was found setting the lexical value to a CSS value.
-
appendValueString
-
appendMinifiedValueString
-
hasFactoryFlag
public boolean hasFactoryFlag(byte flag) Check whether the factory has the given flag set.- Parameters:
flag- the flag.- Returns:
trueif the flag is set.
-
domPrimitiveType
public static short domPrimitiveType(short sacType) Translate a SAC lexical type into a CSS primitive unit type.- Parameters:
sacType- the SAC type.- Returns:
- the unit type according to
CSSPrimitiveValue.
-