return (evaluateCondition(node, cc.getFirstCondition()) ||
evaluateCondition(node, cc.getSecondCondition()));
}
case Condition.SAC_ATTRIBUTE_CONDITION:
{
final AttributeCondition ac = (AttributeCondition) condition;
final LayoutContext layoutContext = node.getLayoutContext();
String namespaceURI = ac.getNamespaceURI();
if (namespaceURI == null)
{
namespaceURI = layoutContext.getNamespace();
}
final AttributeMap attributes = layoutContext.getAttributes();
final Object attr = attributes.getAttribute
(namespaceURI, ac.getLocalName());
if (ac.getValue() == null)
{
// dont care what's inside, as long as there is a value ..
return attr != null;
}
else
{
return ObjectUtilities.equal(attr, ac.getValue());
}
}
case Condition.SAC_CLASS_CONDITION:
{
final AttributeCondition ac = (AttributeCondition) condition;
final LayoutContext layoutContext = node.getLayoutContext();
final String namespace = layoutContext.getNamespace();
if (namespace == null)
{
return false;
}
final NamespaceDefinition ndef = namespaces.getDefinition(namespace);
if (ndef == null)
{
return false;
}
final String[] classAttribute = ndef.getClassAttribute(
layoutContext.getTagName());
for (int i = 0; i < classAttribute.length; i++)
{
final String attr = classAttribute[i];
final String htmlAttr = (String)
layoutContext.getAttributes().getAttribute(
namespace, attr);
if (isOneOfAttributes(htmlAttr, ac.getValue()))
{
return true;
}
}
return false;
}
case Condition.SAC_ID_CONDITION:
{
final AttributeCondition ac = (AttributeCondition) condition;
final LayoutContext layoutContext = node.getLayoutContext();
final AttributeMap attributes = layoutContext.getAttributes();
final Object id = attributes.getAttribute(Namespaces.XML_NAMESPACE,
"id");
return ObjectUtilities.equal(ac.getValue(), id);
}
case Condition.SAC_LANG_CONDITION:
{
final AttributeCondition ac = (AttributeCondition) condition;
final LayoutContext layoutContext = node.getLayoutContext();
final Locale locale = layoutContext.getLanguage();
final String lang = locale.getLanguage();
return isBeginHyphenAttribute(lang, ac.getValue());
}
case Condition.SAC_NEGATIVE_CONDITION:
{
final NegativeCondition nc = (NegativeCondition) condition;
return evaluateCondition(node, nc.getCondition()) == false;
}
case Condition.SAC_ONE_OF_ATTRIBUTE_CONDITION:
{
final AttributeCondition ac = (AttributeCondition) condition;
final LayoutContext layoutContext = node.getLayoutContext();
final String attr = (String)
layoutContext.getAttributes().getAttribute
(ac.getNamespaceURI(), ac.getLocalName());
return isOneOfAttributes(attr, ac.getValue());
}
case Condition.SAC_PSEUDO_CLASS_CONDITION:
{
final AttributeCondition ac = (AttributeCondition) condition;
final LayoutContext layoutContext = node.getLayoutContext();
final String pseudoClass = layoutContext.getPseudoElement();
if (pseudoClass == null)
{
return false;
}
if (pseudoClass.equals(ac.getValue()))
{
return true;
}
return false;
}