{
throw new NullPointerException("Rule given is null.");
}
final String normalizedName = name.toLowerCase();
final StyleKey key = registry.findKeyByName(normalizedName);
if (value.getLexicalUnitType() == LexicalUnit.SAC_INHERIT)
{
if (key == null)
{
setCompundInheritValue(normalizedName, rule, important);
return;
}
rule.setPropertyValue(key, CSSInheritValue.getInstance());
rule.setImportant(key, important);
return;
}
if (value.getLexicalUnitType() == LexicalUnit.SAC_ATTR)
{
final CSSAttrFunction attrFn = parseAttrFunction(value);
// ATTR function.
if (attrFn != null)
{
if (key == null)
{
// Log.warn("Got no key for attribute-function " + normalizedName);
setCompundAttrValue(normalizedName, attrFn, rule, important);
return;
}
rule.setPropertyValue(key, attrFn);
rule.setImportant(key, important);
}
return;
}
else if (isFunctionValue(value) && "attr".equals(value.getFunctionName()))
{
// ATTR function (extended version).
if (key == null)
{
logger.warn("Got no key for attribute-function " + normalizedName);
return;
}
final CSSAttrFunction attrFn = parseComplexAttrFn(value.getParameters());
if (attrFn != null)
{
rule.setPropertyValue(key, attrFn);
rule.setImportant(key, important);
}
return;
}
if (key != null)
{
final CSSValue cssValue = createValue(key, value);
if (cssValue != null)
{
rule.setPropertyValue(key, cssValue);
rule.setImportant(key, important);
//Log.debug ("Got value " + key.getName() + " = " + cssValue + "(" + cssValue.getClass() + ") - (important = " + important + ")");
return;
}
}
final CSSCompoundValueReadHandler module =
(CSSCompoundValueReadHandler) compoundHandlers.get(normalizedName);
if (module == null)
{
if (key == null)
{
logger.info("Unknown style-key: Neither compound handlers nor single-value handers are registered for " + normalizedName);
return;
}
logger.warn("Unparsable value: Got no valid result for " + normalizedName + " (" + value + ')');
return; // ignore this rule ..
}
final Map map = module.createValues(value);
if (map == null)
{
return;
}
final Iterator iterator = map.entrySet().iterator();
while (iterator.hasNext())
{
final Map.Entry entry = (Map.Entry) iterator.next();
final StyleKey entryKey = (StyleKey) entry.getKey();
final CSSValue mapCssValue = (CSSValue) entry.getValue();
rule.setPropertyValue(entryKey, mapCssValue);
rule.setImportant(entryKey, important);
//Log.debug ("Got value " + entryKey.getName() + " = " + mapCssValue + "(" + mapCssValue.getClass() + ") - (important = " + important + ")");