info.informatica.doc.style.css.dom
Class BaseCSSStyleSheet

java.lang.Object
  extended by info.informatica.doc.style.css.dom.BaseCSSStyleSheet
All Implemented Interfaces:
org.w3c.dom.css.CSSStyleSheet, org.w3c.dom.stylesheets.StyleSheet
Direct Known Subclasses:
DOM4JCSSStyleSheet, DOMCSSStyleSheet

public class BaseCSSStyleSheet
extends Object
implements org.w3c.dom.css.CSSStyleSheet

CSS Style Sheet Object Model implementation base class.

Author:
Carlos Amengual (amengual at informatica.info)

Field Summary
protected  CSSRuleArrayList cssRules
           
protected  int currentInsertionIndex
           
protected  String targetMedium
           
 
Constructor Summary
protected BaseCSSStyleSheet(CSSStyleSheetFactory factory, org.w3c.dom.stylesheets.MediaList media)
           
protected BaseCSSStyleSheet(CSSStyleSheetFactory factory, org.w3c.dom.stylesheets.MediaList media, org.w3c.dom.css.CSSRule ownerRule)
           
 
Method Summary
 void addRule(BaseCSSRule cssrule)
          Inserts a rule in the current insertion point (generally after the last rule).
 void addStyleSheet(BaseCSSStyleSheet sheet)
           
protected  ComputedCSSStyle computeStyle(ComputedCSSStyle style, SelectorMatcher matcher, ComputedCSSStyle inlineStyle, String pseudoElt)
          Compute the style for an element.
protected static org.w3c.css.sac.Parser createSACParser()
           
 void deleteRule(int index)
          Deletes a rule from the style sheet.
 org.w3c.dom.css.CSSRuleList getCssRules()
           
 boolean getDisabled()
           
 URL getDocumentBaseURL()
          Gets the base URL for the source document of this sheet
 String getHref()
           
 org.w3c.dom.stylesheets.MediaList getMedia()
           
 String getNamespaceURI()
          Gets the namespace URI to which this style applies.
 Node getOwnerNode()
           
 org.w3c.dom.css.CSSRule getOwnerRule()
           
 org.w3c.dom.stylesheets.StyleSheet getParentStyleSheet()
           
 CSSStyleSheetFactory getStyleSheetFactory()
           
 String getTargetMedium()
          Gets the target medium for this sheet.
 String getTitle()
          Gets the advisory title.
 String getType()
           
 int insertRule(String rule, int index)
          Used to insert a new rule into the style sheet.
 void parseCSSStyleSheet(org.w3c.css.sac.InputSource source)
          Parses a style sheet.
 void setDisabled(boolean disabled)
           
 void setHref(String href)
           
 void setNamespaceURI(String uri)
          Sets the namespace URI to which this style applies.
 void setParentStyleSheet(org.w3c.dom.stylesheets.StyleSheet parent)
           
 void setTargetMedium(String medium)
          Sets the medium that is expected by the user agent, and will be used for computed styles.
 void setTitle(String title)
          Sets the advisory title.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

cssRules

protected CSSRuleArrayList cssRules

currentInsertionIndex

protected int currentInsertionIndex

targetMedium

protected String targetMedium
Constructor Detail

BaseCSSStyleSheet

protected BaseCSSStyleSheet(CSSStyleSheetFactory factory,
                            org.w3c.dom.stylesheets.MediaList media,
                            org.w3c.dom.css.CSSRule ownerRule)

BaseCSSStyleSheet

protected BaseCSSStyleSheet(CSSStyleSheetFactory factory,
                            org.w3c.dom.stylesheets.MediaList media)
Method Detail

getStyleSheetFactory

public CSSStyleSheetFactory getStyleSheetFactory()

getOwnerRule

public org.w3c.dom.css.CSSRule getOwnerRule()
Specified by:
getOwnerRule in interface org.w3c.dom.css.CSSStyleSheet

getOwnerNode

public Node getOwnerNode()
Specified by:
getOwnerNode in interface org.w3c.dom.stylesheets.StyleSheet

getCssRules

public org.w3c.dom.css.CSSRuleList getCssRules()
Specified by:
getCssRules in interface org.w3c.dom.css.CSSStyleSheet

insertRule

public int insertRule(String rule,
                      int index)
               throws DOMException
Used to insert a new rule into the style sheet. The new rule now becomes part of the cascade.

Specified by:
insertRule in interface org.w3c.dom.css.CSSStyleSheet
Parameters:
rule - The parsable text representing the rule. For rule sets this contains both the selector and the style declaration. For at-rules, this specifies both the at-identifier and the rule content.
index - The index within the style sheet's rule list of the rule before which to insert the specified rule. If the specified index is equal to the length of the style sheet's rule collection, the rule will be added to the end of the style sheet.
Returns:
The index within the style sheet's rule collection of the newly inserted rule.
Throws:
DOMException - HIERARCHY_REQUEST_ERR: Raised if the rule cannot be inserted at the specified index e.g. if an @import rule is inserted after a standard rule set or other at-rule.
INDEX_SIZE_ERR: Raised if the specified index is not a valid insertion point.
NO_MODIFICATION_ALLOWED_ERR: Raised if this style sheet is readonly.
SYNTAX_ERR: Raised if the specified rule has a syntax error and is unparsable.

addRule

public void addRule(BaseCSSRule cssrule)
Inserts a rule in the current insertion point (generally after the last rule).

Parameters:
cssrule - the rule to be inserted.

deleteRule

public void deleteRule(int index)
                throws DOMException
Deletes a rule from the style sheet.

Specified by:
deleteRule in interface org.w3c.dom.css.CSSStyleSheet
Parameters:
index - The index within the style sheet's rule list of the rule to remove.
Throws:
DOMException - INDEX_SIZE_ERR: Raised if the specified index does not correspond to a rule in the style sheet's rule list.
NO_MODIFICATION_ALLOWED_ERR: Raised if this style sheet is readonly.

addStyleSheet

public void addStyleSheet(BaseCSSStyleSheet sheet)

getType

public String getType()
Specified by:
getType in interface org.w3c.dom.stylesheets.StyleSheet

getNamespaceURI

public String getNamespaceURI()
Gets the namespace URI to which this style applies.

Returns:
the namespace URI string.

setNamespaceURI

public void setNamespaceURI(String uri)
Sets the namespace URI to which this style applies.

Parameters:
uri - the namespace URI.

getDisabled

public boolean getDisabled()
Specified by:
getDisabled in interface org.w3c.dom.stylesheets.StyleSheet

setDisabled

public void setDisabled(boolean disabled)
Specified by:
setDisabled in interface org.w3c.dom.stylesheets.StyleSheet

getParentStyleSheet

public org.w3c.dom.stylesheets.StyleSheet getParentStyleSheet()
Specified by:
getParentStyleSheet in interface org.w3c.dom.stylesheets.StyleSheet

setParentStyleSheet

public void setParentStyleSheet(org.w3c.dom.stylesheets.StyleSheet parent)

getHref

public String getHref()
Specified by:
getHref in interface org.w3c.dom.stylesheets.StyleSheet

setHref

public void setHref(String href)

getDocumentBaseURL

public URL getDocumentBaseURL()
Gets the base URL for the source document of this sheet

Returns:
the base URL, or null if this style sheet is not embedded into a source document (i.e. a standalone sheet), or is not known.

getTitle

public String getTitle()
Gets the advisory title.

Specified by:
getTitle in interface org.w3c.dom.stylesheets.StyleSheet
Returns:
the title.

setTitle

public void setTitle(String title)
Sets the advisory title.

Parameters:
title - the title.

setTargetMedium

public void setTargetMedium(String medium)
                     throws CSSMediaException
Sets the medium that is expected by the user agent, and will be used for computed styles.

Must be one of the mediums in the media list returned by getMedia().

Parameters:
medium - the name of the medium, like 'screen' or 'print'.
Throws:
CSSMediaException

getTargetMedium

public String getTargetMedium()
Gets the target medium for this sheet.

Returns:
the taget medium, or null if has not been set.

getMedia

public org.w3c.dom.stylesheets.MediaList getMedia()
Specified by:
getMedia in interface org.w3c.dom.stylesheets.StyleSheet

toString

public String toString()
Overrides:
toString in class Object

computeStyle

protected ComputedCSSStyle computeStyle(ComputedCSSStyle style,
                                        SelectorMatcher matcher,
                                        ComputedCSSStyle inlineStyle,
                                        String pseudoElt)
Compute the style for an element.

Parameters:
style - a base, empty style to be filled with the computed style.
matcher - the selector matcher.
inlineStyle - the inline style for the element.
pseudoElt - the pseudo-element.
Returns:
the computed CSS style, or an empty style declaration if none applied or the sheet is disabled.

createSACParser

protected static org.w3c.css.sac.Parser createSACParser()
                                                 throws DOMException
Throws:
DOMException

parseCSSStyleSheet

public void parseCSSStyleSheet(org.w3c.css.sac.InputSource source)
                        throws DOMException,
                               IOException
Parses a style sheet. If the style sheet is not empty, the rules from the parsed source will be added at the end of the rule list.

Parameters:
source - the SAC input source.
Throws:
DOMException - if a DOM problem is found parsing the sheet.
org.w3c.css.sac.CSSException - if a non-DOM problem is found parsing the sheet.
IOException - if a problem is found reading the sheet.
See Also:
CSSStyleSheetFactory.createStyleSheet()


Copyright © 2011 informatica.info. All Rights Reserved.