java.lang.Object
io.sf.carte.doc.style.css.property.ValueFactory
- All Implemented Interfaces:
CSSValueFactory
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) Creates a primitive value according to the given lexical value.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.createCSSValue(LexicalUnit lunit, AbstractCSSStyleDeclaration style, boolean subproperty) 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.protected ParserCreate a parser adequate for parsing media features.protected ParserCreate a default parser adequate for parsing properties.booleanhasFactoryFlag(short flag) Check whether the factory has the given flag set.static booleanTests whether the given NSAC unit type is an angle or percentage unit (or zero, which is to be interpreted as length 0).static booleanisColorSACUnit(LexicalUnit lunit) Test whether the value represents a color.static booleanTests whether the given NSAC unit type is a non-negative<length>or<number>unit (or a unknown unit).static booleanTest whether the value represents a length or a percentage.static booleanisLengthSACUnit(LexicalUnit lunit) Test whether the value represents a non-negative length.static booleanTests whether the given NSAC unit type is a non-negative number (real or integer) or a percentage.static booleanisPositiveSizeSACUnit(LexicalUnit lunit) Tests whether the given NSAC value represents a length (including unknown units) or percentage greater or equal to zero (e.g.static booleanisResolutionSACUnit(LexicalUnit lunit) Tests whether the unit type of the given NSAC lexical unit is a resolution unit.static booleanisSizeOrNumberSACUnit(LexicalUnit lunit) Tests whether the given NSAC unit type is a non-negative<length-percentage>or<number>unit (or a unknown unit).static booleanisSizeSACUnit(LexicalUnit unit) Deprecated.static booleanisTimeSACUnit(LexicalUnit unit) Tests whether the given NSAC 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, Parser parser) Parses a feature value.parseProperty(String value) Parses a property value.parseProperty(String value, Parser 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 propertyName, String value, CSSParser parser) Parses a property value with the supplied parser.
-
Constructor Details
-
ValueFactory
public ValueFactory() -
ValueFactory
public ValueFactory(short flags)
-
-
Method Details
-
isSizeSACUnit
Deprecated.UseisLengthPercentageSACUnit(LexicalUnit)instead.Tests whether the unit type of the given NSAC lexical unit can apply to size (e.g. block size).- Parameters:
unit- the NSAC lexical unit.- Returns:
trueif it is a size type, false otherwise.
-
isLengthSACUnit
Test whether the value represents a non-negative length.- Parameters:
lunit- the lexical unit to test.- Returns:
trueif the value is a length in the [0-∞] interval.- Throws:
CSSLexicalProcessingException- if aPROXYvalue was found.
-
isLengthPercentageSACUnit
public static boolean isLengthPercentageSACUnit(LexicalUnit lunit) throws CSSLexicalProcessingException Test whether the value represents a length or a percentage.The value can be positive or negative.
- Parameters:
lunit- the lexical unit to test.- Returns:
trueif the value is a length or a percentage.- Throws:
CSSLexicalProcessingException- if aPROXYvalue was found.
-
isPositiveSizeSACUnit
Tests whether the given NSAC value represents a length (including unknown units) or percentage greater or equal to zero (e.g.font-sizeorcolumn-width).- Parameters:
lunit- the lexical value.- Returns:
trueif it is a non-negative<length-percentage>type,falseotherwise.- Throws:
CSSLexicalProcessingException- if aPROXYvalue was found.
-
isLengthOrNumberSACUnit
public static boolean isLengthOrNumberSACUnit(LexicalUnit lunit) throws CSSLexicalProcessingException Tests whether the given NSAC unit type is a non-negative<length>or<number>unit (or a unknown unit).- Parameters:
lunit- the lexical value.- Returns:
trueif it is a size or numeric type (including percentage) in the [0-∞] interval,falseotherwise.- Throws:
CSSLexicalProcessingException- if aPROXYvalue was found.
-
isSizeOrNumberSACUnit
Tests whether the given NSAC unit type is a non-negative<length-percentage>or<number>unit (or a unknown unit).- Parameters:
lunit- the lexical value.- Returns:
trueif it is a size or numeric type (including percentage) in the [0-∞] interval,falseotherwise.- Throws:
CSSLexicalProcessingException- if aPROXYvalue was found.
-
isPercentageOrNumberSACUnit
Tests whether the given NSAC unit type is a non-negative number (real or integer) or a percentage.Useful to check for
border-image-slice.- Parameters:
lunit- the lexical value.- Returns:
trueif is a number or a percentage in the [0-∞] interval,falseotherwise.
-
isResolutionSACUnit
Tests whether the unit type of the given NSAC lexical unit is a resolution unit.- Parameters:
lunit- the NSAC lexical unit value.- Returns:
trueif it is a resolution type,falseotherwise.- Throws:
CSSLexicalProcessingException- if aPROXYvalue was found.
-
isAngleOrPercentageSACUnit
public static boolean isAngleOrPercentageSACUnit(LexicalUnit unit) throws CSSLexicalProcessingException Tests whether the given NSAC unit type is an angle or percentage unit (or zero, which is to be interpreted as length 0).This is useful for checking color stops in gradients.
- Parameters:
unit- the lexical value.- Returns:
trueif is an angle or percentage type,falseotherwise.- Throws:
CSSLexicalProcessingException- if aPROXYvalue was found.
-
isTimeSACUnit
Tests whether the given NSAC unit type is a time unit.- Parameters:
unit- the lexical value.- Returns:
trueif is a time type,falseotherwise.- Throws:
CSSLexicalProcessingException- if aPROXYvalue was found.
-
isColorSACUnit
Test whether the value represents a color.- Parameters:
lunit- the lexical unit to test.- Returns:
- true if the value is a color.
- Throws:
CSSLexicalProcessingException- if aPROXYvalue was found.
-
createParser
Create a default parser adequate for parsing properties.- Returns:
- a parser.
-
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 NSAC 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 NSAC 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 NSAC 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 PrimitiveValue object containing the parsed value.
- Throws:
DOMException- if a problem was found parsing the feature.
-
createMediaFeatureParser
Create a parser adequate for parsing media features.- Returns:
- a parser.
-
parseMediaFeature
Parses a feature value.- Parameters:
feature- the string containing the feature value.parser- the parser used to parse values.- Returns:
- the PrimitiveValue 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.
- Specified by:
createCSSValuein interfaceCSSValueFactory- Parameters:
lunit- the lexical value.- Returns:
- a
CSSValueassociated to the given lexical value, ornullif a bracket list was empty. - 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.
- Parameters:
lunit- the lexical value.style- the (style) declaration that should handle errors, ornullto not handle errors.- Returns:
- a
CSSValueassociated to the given lexical value, ornullif a bracket list was empty. - Throws:
DOMException- if the lexical unit had a wrong content to create a value.
-
createCSSValue
public StyleValue createCSSValue(LexicalUnit lunit, AbstractCSSStyleDeclaration style, boolean subproperty) throws DOMException Creates a CSSValue according to the given lexical value.- Parameters:
lunit- the lexical value.style- the (style) declaration that should handle errors, ornullto not handle errors.subproperty- the flag marking whether it is a sub-property.- Returns:
- a
CSSValueassociated to the given lexical value, ornullif a bracket list was empty. - 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.
-
createCSSPrimitiveValue
Creates a primitive value according to the given lexical value.This method won't return a ratio value (callers must check for values spanning more than one lexical unit).
If the lexical unit is a slash operator and is in
contentcontext, returns aLexicalValue.If the lexical unit is an operator and a parameter, returns an
UnknownValue.- Specified by:
createCSSPrimitiveValuein interfaceCSSValueFactory- Parameters:
lunit- the lexical value.- Returns:
- the primitive value.
- Throws:
CSSLexicalProcessingException- if this value is part of a larger lexical chain that should be handled as a lexical value.DOMException- if the lexical unit does not represent a valid primitive.
-
appendValueString
-
appendMinifiedValueString
-
hasFactoryFlag
public boolean hasFactoryFlag(short flag) Check whether the factory has the given flag set.- Parameters:
flag- the flag.- Returns:
trueif the flag is set.
-
isLengthPercentageSACUnit(LexicalUnit)instead.