2 * Copyright (c) 2000 World Wide Web Consortium,
3 * (Massachusetts Institute of Technology, Institut National de
4 * Recherche en Informatique et en Automatique, Keio University). All
5 * Rights Reserved. This program is distributed under the W3C's Software
6 * Intellectual Property License. This program is distributed in the
7 * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
8 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
10 * See W3C License http://www.w3.org/Consortium/Legal/ for more details.
13 package org.w3c.dom.css;
15 import org.w3c.dom.DOMException;
18 * The <code>CSSStyleDeclaration</code> interface represents a single CSS
19 * declaration block. This interface may be used to determine the style
20 * properties currently set in a block or to set style properties explicitly
22 * <p> While an implementation may not recognize all CSS properties within a
23 * CSS declaration block, it is expected to provide access to all specified
24 * properties in the style sheet through the <code>CSSStyleDeclaration</code>
25 * interface. Furthermore, implementations that support a specific level of
26 * CSS should correctly handle CSS shorthand properties for that level. For
27 * a further discussion of shorthand properties, see the
28 * <code>CSS2Properties</code> interface.
29 * <p> This interface is also used to provide a read-only access to the
30 * computed values of an element. See also the <code>ViewCSS</code>
31 * interface. The CSS Object Model doesn't provide an access to the
32 * specified or actual values of the CSS cascade.
33 * <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113'>Document Object Model (DOM) Level 2 Style Specification</a>.
36 public interface CSSStyleDeclaration {
38 * The parsable textual representation of the declaration block
39 * (excluding the surrounding curly braces). Setting this attribute will
40 * result in the parsing of the new value and resetting of all the
41 * properties in the declaration block including the removal or addition
44 public String getCssText();
46 * The parsable textual representation of the declaration block
47 * (excluding the surrounding curly braces). Setting this attribute will
48 * result in the parsing of the new value and resetting of all the
49 * properties in the declaration block including the removal or addition
51 * @exception DOMException
52 * SYNTAX_ERR: Raised if the specified CSS string value has a syntax
53 * error and is unparsable.
54 * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this declaration is
55 * readonly or a property is readonly.
57 public void setCssText(String cssText)
61 * Used to retrieve the value of a CSS property if it has been explicitly
62 * set within this declaration block.
63 * @param propertyName The name of the CSS property. See the CSS
65 * @return Returns the value of the property if it has been explicitly
66 * set for this declaration block. Returns the empty string if the
67 * property has not been set.
69 public String getPropertyValue(String propertyName);
72 * Used to retrieve the object representation of the value of a CSS
73 * property if it has been explicitly set within this declaration block.
74 * This method returns <code>null</code> if the property is a shorthand
75 * property. Shorthand property values can only be accessed and modified
76 * as strings, using the <code>getPropertyValue</code> and
77 * <code>setProperty</code> methods.
78 * @param propertyName The name of the CSS property. See the CSS
80 * @return Returns the value of the property if it has been explicitly
81 * set for this declaration block. Returns <code>null</code> if the
82 * property has not been set.
84 public CSSValue getPropertyCSSValue(String propertyName);
87 * Used to remove a CSS property if it has been explicitly set within
88 * this declaration block.
89 * @param propertyName The name of the CSS property. See the CSS
91 * @return Returns the value of the property if it has been explicitly
92 * set for this declaration block. Returns the empty string if the
93 * property has not been set or the property name does not correspond
94 * to a known CSS property.
95 * @exception DOMException
96 * NO_MODIFICATION_ALLOWED_ERR: Raised if this declaration is readonly
97 * or the property is readonly.
99 public String removeProperty(String propertyName)
103 * Used to retrieve the priority of a CSS property (e.g. the
104 * <code>"important"</code> qualifier) if the priority has been
105 * explicitly set in this declaration block.
106 * @param propertyName The name of the CSS property. See the CSS
108 * @return A string representing the priority (e.g.
109 * <code>"important"</code>) if the property has been explicitly set
110 * in this declaration block and has a priority specified. The empty
113 public String getPropertyPriority(String propertyName);
116 * Used to set a property value and priority within this declaration
117 * block. <code>setProperty</code> permits to modify a property or add a
118 * new one in the declaration block. Any call to this method may modify
119 * the order of properties in the <code>item</code> method.
120 * @param propertyName The name of the CSS property. See the CSS
122 * @param value The new value of the property.
123 * @param priority The new priority of the property (e.g.
124 * <code>"important"</code>) or the empty string if none.
125 * @exception DOMException
126 * SYNTAX_ERR: Raised if the specified value has a syntax error and is
128 * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this declaration is
129 * readonly or the property is readonly.
131 public void setProperty(String propertyName,
137 * The number of properties that have been explicitly set in this
138 * declaration block. The range of valid indices is 0 to length-1
141 public int getLength();
144 * Used to retrieve the properties that have been explicitly set in this
145 * declaration block. The order of the properties retrieved using this
146 * method does not have to be the order in which they were set. This
147 * method can be used to iterate over all properties in this declaration
149 * @param index Index of the property name to retrieve.
150 * @return The name of the property at this ordinal position. The empty
151 * string if no property exists at this position.
153 public String item(int index);
156 * The CSS rule that contains this declaration block or <code>null</code>
157 * if this <code>CSSStyleDeclaration</code> is not attached to a
158 * <code>CSSRule</code>.
160 public CSSRule getParentRule();