KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > w3c > dom > css > CSSStyleDeclaration


1 /*
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
9  * PURPOSE.
10  * See W3C License http://www.w3.org/Consortium/Legal/ for more details.
11  */

12
13 package org.w3c.dom.css;
14
15 import org.w3c.dom.DOMException JavaDoc;
16
17 /**
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
21  * within the block.
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>.
34  * @since DOM Level 2
35  */

36 public interface CSSStyleDeclaration {
37     /**
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
42      * of properties.
43      * @exception DOMException
44      * SYNTAX_ERR: Raised if the specified CSS string value has a syntax
45      * error and is unparsable.
46      * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this declaration is
47      * readonly or a property is readonly.
48      */

49     public String JavaDoc getCssText();
50     public void setCssText(String JavaDoc cssText)
51                        throws DOMException JavaDoc;
52
53     /**
54      * Used to retrieve the value of a CSS property if it has been explicitly
55      * set within this declaration block.
56      * @param propertyName The name of the CSS property. See the CSS property
57      * index.
58      * @return Returns the value of the property if it has been explicitly
59      * set for this declaration block. Returns the empty string if the
60      * property has not been set.
61      */

62     public String JavaDoc getPropertyValue(String JavaDoc propertyName);
63
64     /**
65      * Used to retrieve the object representation of the value of a CSS
66      * property if it has been explicitly set within this declaration block.
67      * This method returns <code>null</code> if the property is a shorthand
68      * property. Shorthand property values can only be accessed and modified
69      * as strings, using the <code>getPropertyValue</code> and
70      * <code>setProperty</code> methods.
71      * @param propertyName The name of the CSS property. See the CSS property
72      * index.
73      * @return Returns the value of the property if it has been explicitly
74      * set for this declaration block. Returns <code>null</code> if the
75      * property has not been set.
76      */

77     public CSSValue getPropertyCSSValue(String JavaDoc propertyName);
78
79     /**
80      * Used to remove a CSS property if it has been explicitly set within
81      * this declaration block.
82      * @param propertyName The name of the CSS property. See the CSS property
83      * index.
84      * @return Returns the value of the property if it has been explicitly
85      * set for this declaration block. Returns the empty string if the
86      * property has not been set or the property name does not correspond
87      * to a known CSS property.
88      * @exception DOMException
89      * NO_MODIFICATION_ALLOWED_ERR: Raised if this declaration is readonly
90      * or the property is readonly.
91      */

92     public String JavaDoc removeProperty(String JavaDoc propertyName)
93                                  throws DOMException JavaDoc;
94
95     /**
96      * Used to retrieve the priority of a CSS property (e.g. the
97      * <code>"important"</code> qualifier) if the property has been
98      * explicitly set in this declaration block.
99      * @param propertyName The name of the CSS property. See the CSS property
100      * index.
101      * @return A string representing the priority (e.g.
102      * <code>"important"</code>) if one exists. The empty string if none
103      * exists.
104      */

105     public String JavaDoc getPropertyPriority(String JavaDoc propertyName);
106
107     /**
108      * Used to set a property value and priority within this declaration
109      * block.
110      * @param propertyName The name of the CSS property. See the CSS property
111      * index.
112      * @param value The new value of the property.
113      * @param priority The new priority of the property (e.g.
114      * <code>"important"</code>).
115      * @exception DOMException
116      * SYNTAX_ERR: Raised if the specified value has a syntax error and is
117      * unparsable.
118      * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this declaration is
119      * readonly or the property is readonly.
120      */

121     public void setProperty(String JavaDoc propertyName,
122                             String JavaDoc value,
123                             String JavaDoc priority)
124                             throws DOMException JavaDoc;
125
126     /**
127      * The number of properties that have been explicitly set in this
128      * declaration block. The range of valid indices is 0 to length-1
129      * inclusive.
130      */

131     public int getLength();
132
133     /**
134      * Used to retrieve the properties that have been explicitly set in this
135      * declaration block. The order of the properties retrieved using this
136      * method does not have to be the order in which they were set. This
137      * method can be used to iterate over all properties in this declaration
138      * block.
139      * @param index Index of the property name to retrieve.
140      * @return The name of the property at this ordinal position. The empty
141      * string if no property exists at this position.
142      */

143     public String JavaDoc item(int index);
144
145     /**
146      * The CSS rule that contains this declaration block or <code>null</code>
147      * if this <code>CSSStyleDeclaration</code> is not attached to a
148      * <code>CSSRule</code>.
149      */

150     public CSSRule getParentRule();
151
152 }
153
Popular Tags