public static class FontWeight extends AbstractPropertyBuilder {
// normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | inherit
public List buildDeclarations(
CSSName cssName, List values, int origin, boolean important, boolean inheritAllowed) {
checkValueCount(cssName, 1, values.size());
PropertyValue value = (PropertyValue)values.get(0);
checkInheritAllowed(value, inheritAllowed);
if (value.getCssValueType() != CSSPrimitiveValue.CSS_INHERIT) {
checkIdentOrNumberType(cssName, value);
short type = value.getPrimitiveType();
if (type == CSSPrimitiveValue.CSS_IDENT) {
checkIdentType(cssName, value);
IdentValue ident = checkIdent(cssName, value);
checkValidity(cssName, getAllowed(), ident);
} else if (type == CSSPrimitiveValue.CSS_NUMBER) {
IdentValue weight = Conversions.getNumericFontWeight(value.getFloatValue());
if (weight == null) {
throw new CSSParseException(value + " is not a valid font weight", -1);
}
PropertyValue replacement = new PropertyValue(
CSSPrimitiveValue.CSS_IDENT, weight.toString(), weight.toString());
replacement.setIdentValue(weight);
return Collections.singletonList(
new PropertyDeclaration(cssName, replacement, important, origin));
}
}