/** * Adds a feature to the Condition attribute of the Selector object * * @param c The feature to be added to the Condition attribute */ private void addCondition(Condition c) { if (conditions == null) { conditions = new java.util.ArrayList(); } if (_pe != null) { conditions.add(Condition.createUnsupportedCondition()); XRLog.match(Level.WARNING, "Trying to append conditions to pseudoElement " + _pe); } conditions.add(c); }
/** Check if the given Element matches this selector. Note: the parser should give all class */ public boolean matches(Object e, AttributeResolver attRes, TreeResolver treeRes) { if (siblingSelector != null) { Object sib = siblingSelector.getAppropriateSibling(e, treeRes); if (sib == null) { return false; } if (!siblingSelector.matches(sib, attRes, treeRes)) { return false; } } if (_name == null || treeRes.matchesElement(e, _namespaceURI, _name)) { if (conditions != null) { // all conditions need to be true for (java.util.Iterator i = conditions.iterator(); i.hasNext(); ) { Condition c = (Condition) i.next(); if (!c.matches(e, attRes, treeRes)) { return false; } } } return true; } return false; }
/** the CSS condition [attribute|=value] */ public void addAttributeMatchesFirstPartCondition( String namespaceURI, String name, String value) { _specificityC++; addCondition(Condition.createAttributeMatchesFirstPartCondition(namespaceURI, name, value)); }
/** the CSS condition [attribute] */ public void addAttributeExistsCondition(String namespaceURI, String name) { _specificityC++; addCondition(Condition.createAttributeExistsCondition(namespaceURI, name)); }
/** the CSS condition [attribute*=value] */ public void addAttributeSubstringCondition(String namespaceURI, String name, String value) { _specificityC++; addCondition(Condition.createAttributeSubstringCondition(namespaceURI, name, value)); }
/** the CSS condition #ID */ public void addIDCondition(String id) { _specificityB++; addCondition(Condition.createIDCondition(id)); }
/** the CSS condition .class */ public void addClassCondition(String className) { _specificityC++; addCondition(Condition.createClassCondition(className)); _text = _name + Token.TK_PERIOD.getExternalName() + className; }
/** the CSS condition :lang(Xx) */ public void addLangCondition(String lang) { _specificityC++; addCondition(Condition.createLangCondition(lang)); }
/** the CSS condition that element has pseudo-class :odd */ public void addOddChildCondition() { _specificityC++; addCondition(Condition.createOddChildCondition()); }
/** the CSS condition that element has pseudo-class :first-child */ public void addFirstChildCondition() { _specificityC++; addCondition(Condition.createFirstChildCondition()); }
/** the CSS condition that element has pseudo-class :link */ public void addLinkCondition() { _specificityC++; addCondition(Condition.createLinkCondition()); }
/** for unsupported or invalid CSS */ public void addUnsupportedCondition() { addCondition(Condition.createUnsupportedCondition()); }