* @return <tt>true</tt> if it does apply, <tt>false</tt> if it doesn't apply
*/
boolean selects(final Condition condition, final HtmlElement element) {
switch (condition.getConditionType()) {
case Condition.SAC_ID_CONDITION:
final AttributeCondition ac4 = (AttributeCondition) condition;
return ac4.getValue().equals(element.getId());
case Condition.SAC_CLASS_CONDITION:
final AttributeCondition ac3 = (AttributeCondition) condition;
final String v3 = ac3.getValue();
final String a3 = element.getAttribute("class");
return a3.equals(v3) || a3.startsWith(v3 + " ") || a3.endsWith(" " + v3) || a3.contains(" " + v3 + " ");
case Condition.SAC_AND_CONDITION:
final CombinatorCondition cc1 = (CombinatorCondition) condition;
return selects(cc1.getFirstCondition(), element) && selects(cc1.getSecondCondition(), element);
case Condition.SAC_ATTRIBUTE_CONDITION:
final AttributeCondition ac1 = (AttributeCondition) condition;
if (ac1.getSpecified()) {
return element.getAttribute(ac1.getLocalName()).equals(ac1.getValue());
}
return element.hasAttribute(ac1.getLocalName());
case Condition.SAC_BEGIN_HYPHEN_ATTRIBUTE_CONDITION:
final AttributeCondition ac2 = (AttributeCondition) condition;
final String v = ac2.getValue();
final String a = element.getAttribute(ac2.getLocalName());
return a.equals(v) || a.startsWith(v + "-") || a.endsWith("-" + v) || a.contains("-" + v + "-");
case Condition.SAC_ONE_OF_ATTRIBUTE_CONDITION:
final AttributeCondition ac5 = (AttributeCondition) condition;
final String v2 = ac5.getValue();
final String a2 = element.getAttribute(ac5.getLocalName());
return a2.equals(v2) || a2.startsWith(v2 + " ") || a2.endsWith(" " + v2) || a2.contains(" " + v2 + " ");
case Condition.SAC_OR_CONDITION:
final CombinatorCondition cc2 = (CombinatorCondition) condition;
return selects(cc2.getFirstCondition(), element) || selects(cc2.getSecondCondition(), element);
case Condition.SAC_NEGATIVE_CONDITION: