A pure Java implementation of a CSS query engine. Presents a simple API for loading stylesheets into an in-memory DOM and then enabling selector and property name queries to retrieve property values. The design goal is to completely hide the DOM. All interactions are intended to be based on stylesheets, selectors, properties and property values.
Based on code extracted and heavily refactored from The Flying Saucer Project. Uses the CSSParser package to create and manage the in-memory DOM.
Operation and use is generally consistent with Cascading Style Sheets Level 2.
/*************************************************/ /** Convenience method to create a stylesheet DB */ /** Load an existing StyleSheet */ CssQuery#parse(Reader reader) throws IOException /*********************************************/ /** Convenience methods to query by selector */ /** * Returns a list of the properties defined for the given selector * Supports simple selector inheritance. * * @return list of properties in an ArrayList<String> */ CssQuery#findProperties(String selectorName) /** * Determines whether a property is defined for the given selector. * Supports simple selector inheritance. * * @return true if the property is defined by the stylesheet. */ CssQuery#hasProperty(String selectorName, String property) /** * Retrieves the value for the given selector and property. * Supports simple selector inheritance. * * @return an Object containing the property value */ CssQuery#findPropertyValue(String selectorName, String property) /***********************************************/ /** If you insist, the DOM is still accessible */ /** * For the given selector, retrieves the W3C SelectorList, * CSSRule, and CSSStyleDeclaration collected together * in a simple CssRecord object. * * @return a CssRecord object */ CssQuery#find(String selectorName)
Available only under these terms:
Version 0.3.0 for Eclipse 3.5.x (In development):
Version 0.2.0 for Eclipse 3.4+ (09.02.2008):
Version 0.1.0 for Eclipse 3.4+ (03.23.2008):