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

java.lang.Object
  extended by info.informatica.doc.style.css.dom.BaseCSSStyleDeclaration
All Implemented Interfaces:
Cloneable, org.w3c.dom.css.CSSStyleDeclaration
Direct Known Subclasses:
ComputedCSSStyle

public class BaseCSSStyleDeclaration
extends Object
implements org.w3c.dom.css.CSSStyleDeclaration, Cloneable

CSS Style Declaration.

Author:
Carlos Amengual (amengual at informatica.info)

Nested Class Summary
 class BaseCSSStyleDeclaration.StyleDeclarationDocumentHandler
           
 
Constructor Summary
  BaseCSSStyleDeclaration()
           
protected BaseCSSStyleDeclaration(BaseCSSStyleDeclaration copiedObject)
          Copy constructor.
 
Method Summary
 void addStyle(BaseCSSStyleDeclaration style)
          Add all the rules of the given style declaration to this one.
 BaseCSSStyleDeclaration clone()
           
protected  org.w3c.dom.css.CSSValue defaultPropertyValue(String propertyName)
          Computes the inital (default) value for the given property.
 org.w3c.dom.css.CSSPrimitiveValue getColor()
           
 org.w3c.dom.css.CSS2Properties getCSS2Properties()
           
 String getCssText()
          Retrieves the parseable textual representation of the declaration block (excluding the surrounding curly braces).
protected  org.w3c.dom.css.CSSValue getCSSValue(String propertyName)
           
protected  org.w3c.dom.css.CSSValue getDeclaredCSSValue(String propertyName)
           
 int getLength()
          The number of properties that have been explicitly set in this declaration block.
 org.w3c.dom.css.CSSRule getParentRule()
          Retrieves the CSS rule that contains this declaration block.
 org.w3c.dom.css.CSSValue getPropertyCSSValue(String propertyName)
          Used to retrieve the object representation of the value of a CSS property if it has been explicitly set within this declaration block.
 String getPropertyPriority(String propertyName)
          Used to retrieve the priority of a CSS property (e.g.
 String getPropertyValue(String propertyName)
          Used to retrieve the value of a CSS property if it has been explicitly set within this declaration block.
 StyleDatabase getStyleDatabase()
          Gets the style database which is used to compute the style.
 String item(int index)
          Used to retrieve the properties that have been set in this declaration block.
 void prioritySplit(BaseCSSStyleDeclaration importantDecl, BaseCSSStyleDeclaration normalDecl)
          Splits this style declaration in two: one for important properties only, and the other with normal properties.
 String removeProperty(String propertyName)
          Used to remove a CSS property if it has been explicitly set within this declaration block.
 void setCssText(String cssText)
          Parses the given value and resets all the properties in the declaration block, including the removal or addition of properties.
 void setProperty(String propertyName, org.w3c.css.sac.LexicalUnit value, String priority)
          Set a CSS property, based on lexixal value.
 void setProperty(String propertyName, String value, String priority)
          Used to set a property value and priority within this declaration block.
 void setStyleDatabase(StyleDatabase styleDb)
          Sets the style database used to compute the style.
protected  String setSubproperties(String propertyName, org.w3c.css.sac.LexicalUnit value, String priority)
          Set the subproperties of a shorthand, and returns its text representation.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BaseCSSStyleDeclaration

public BaseCSSStyleDeclaration()

BaseCSSStyleDeclaration

protected BaseCSSStyleDeclaration(BaseCSSStyleDeclaration copiedObject)
Copy constructor.

Parameters:
copiedObject - the DOMCSSStyleDeclaration to be copied.
Method Detail

getCssText

public String getCssText()
Retrieves the parseable textual representation of the declaration block (excluding the surrounding curly braces).

Specified by:
getCssText in interface org.w3c.dom.css.CSSStyleDeclaration
Returns:
the textual representation of the declaration block.
Throws:
DOMException - SYNTAX_ERR: Raised if the specified CSS string value has a syntax error and is unparsable.
NO_MODIFICATION_ALLOWED_ERR: Raised if this declaration is readonly or a property is readonly.

setCssText

public void setCssText(String cssText)
                throws DOMException
Parses the given value and resets all the properties in the declaration block, including the removal or addition of properties.

Specified by:
setCssText in interface org.w3c.dom.css.CSSStyleDeclaration
Parameters:
cssText - the text with the style declaration.
Throws:
DOMException - SYNTAX_ERR: Raised if the specified CSS string value has a syntax error and is unparsable.
NO_MODIFICATION_ALLOWED_ERR: Raised if this declaration is readonly or a property is readonly.
NOT_SUPPORTED_ERR: if the system was unable to instantiate parser.

getPropertyValue

public String getPropertyValue(String propertyName)
Used to retrieve the value of a CSS property if it has been explicitly set within this declaration block.

Specified by:
getPropertyValue in interface org.w3c.dom.css.CSSStyleDeclaration
Parameters:
propertyName - The name of the CSS property. See the CSS property index.
Returns:
Returns the value of the property if it has been explicitly set for this declaration block. Returns the empty string if the property has not been set.

getPropertyCSSValue

public org.w3c.dom.css.CSSValue getPropertyCSSValue(String propertyName)
Used to retrieve the object representation of the value of a CSS property if it has been explicitly set within this declaration block. This method returns null if the property is a shorthand property. Shorthand property values can only be accessed and modified as strings, using the getPropertyValue and setProperty methods.

Specified by:
getPropertyCSSValue in interface org.w3c.dom.css.CSSStyleDeclaration
Parameters:
propertyName - The name of the CSS property. See the CSS property index.
Returns:
Returns the value of the property if it has been explicitly set for this declaration block. Returns null if the property has not been set.

getCSSValue

protected org.w3c.dom.css.CSSValue getCSSValue(String propertyName)

getDeclaredCSSValue

protected org.w3c.dom.css.CSSValue getDeclaredCSSValue(String propertyName)

removeProperty

public String removeProperty(String propertyName)
                      throws DOMException
Used to remove a CSS property if it has been explicitly set within this declaration block.

Specified by:
removeProperty in interface org.w3c.dom.css.CSSStyleDeclaration
Parameters:
propertyName - name of the property to remove.
Returns:
Returns the value of the property if it has been explicitly set for this declaration block. Returns the empty string if the property has not been set or the property name does not correspond to a known CSS property.
Throws:
DOMException - if this declaration is readonly or the property is readonly. This implementation is not expected to throw the Exception.

getPropertyPriority

public String getPropertyPriority(String propertyName)
Used to retrieve the priority of a CSS property (e.g. the "important" qualifier) if the property has been explicitly set in this declaration block.

Specified by:
getPropertyPriority in interface org.w3c.dom.css.CSSStyleDeclaration
Parameters:
propertyName - The name of the CSS property. See the CSS property index.
Returns:
A string representing the priority (e.g. "important") if one exists. The empty string if none exists.

setProperty

public void setProperty(String propertyName,
                        org.w3c.css.sac.LexicalUnit value,
                        String priority)
                 throws DOMException
Set a CSS property, based on lexixal value.

Parameters:
propertyName - the name of the property.
value - the lexical value.
priority - the priority string.
Throws:
DOMException - if some error or inconsistency is found in the value.

setProperty

public void setProperty(String propertyName,
                        String value,
                        String priority)
                 throws DOMException
Used to set a property value and priority within this declaration block.

Specified by:
setProperty in interface org.w3c.dom.css.CSSStyleDeclaration
Parameters:
propertyName - The name of the CSS property. See the CSS property index.
value - The new value of the property.
priority - The new priority of the property (e.g. "important").
Throws:
DOMException - SYNTAX_ERR: Raised if the specified value has a syntax error and is unparsable.
NO_MODIFICATION_ALLOWED_ERR: Raised if this declaration is readonly or the property is readonly.

getLength

public int getLength()
The number of properties that have been explicitly set in this declaration block. The range of valid indices is 0 to length-1 inclusive.

Specified by:
getLength in interface org.w3c.dom.css.CSSStyleDeclaration

item

public String item(int index)
Used to retrieve the properties that have been set in this declaration block. The order of the properties retrieved using this method does not have to be the order in which they were set. This method can be used to iterate over all properties in this declaration block.

Specified by:
item in interface org.w3c.dom.css.CSSStyleDeclaration
Parameters:
index - the property index.
Returns:
the name of the property at this ordinal position, or the empty string if no property exists at this position.

getParentRule

public org.w3c.dom.css.CSSRule getParentRule()
Retrieves the CSS rule that contains this declaration block.

Specified by:
getParentRule in interface org.w3c.dom.css.CSSStyleDeclaration
Returns:
the CSS rule that contains this declaration block or null if this CSSStyleDeclaration is not attached to a CSSRule.

addStyle

public void addStyle(BaseCSSStyleDeclaration style)
Add all the rules of the given style declaration to this one.

Parameters:
style - the style declaration whose rules have to be added.

prioritySplit

public void prioritySplit(BaseCSSStyleDeclaration importantDecl,
                          BaseCSSStyleDeclaration normalDecl)
Splits this style declaration in two: one for important properties only, and the other with normal properties.

Parameters:
importantDecl -
normalDecl -

getStyleDatabase

public StyleDatabase getStyleDatabase()
Gets the style database which is used to compute the style.

Returns:
the style database.

setStyleDatabase

public void setStyleDatabase(StyleDatabase styleDb)
Sets the style database used to compute the style.

Parameters:
styleDb - the style database.

defaultPropertyValue

protected org.w3c.dom.css.CSSValue defaultPropertyValue(String propertyName)
Computes the inital (default) value for the given property.

Parameters:
propertyName - the name of the property.
Returns:
the initial value for the property, or null if none was found.

getColor

public org.w3c.dom.css.CSSPrimitiveValue getColor()

setSubproperties

protected String setSubproperties(String propertyName,
                                  org.w3c.css.sac.LexicalUnit value,
                                  String priority)
                           throws DOMException
Set the subproperties of a shorthand, and returns its text representation.

Parameters:
propertyName - the shorthand property name.
value - the shorthand property value.
priority - the shorthand property priority.
Returns:
the text representation of the shorthand, or null if propertyName is not a shorthand.
Throws:
DOMException

clone

public BaseCSSStyleDeclaration clone()
Overrides:
clone in class Object

getCSS2Properties

public org.w3c.dom.css.CSS2Properties getCSS2Properties()


Copyright © 2011 informatica.info. All Rights Reserved.