1 /* |
|
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
3 * |
|
4 * This code is free software; you can redistribute it and/or modify it |
|
5 * under the terms of the GNU General Public License version 2 only, as |
|
6 * published by the Free Software Foundation. Oracle designates this |
|
7 * particular file as subject to the "Classpath" exception as provided |
|
8 * by Oracle in the LICENSE file that accompanied this code. |
|
9 * |
|
10 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13 * version 2 for more details (a copy is included in the LICENSE file that |
|
14 * accompanied this code). |
|
15 * |
|
16 * You should have received a copy of the GNU General Public License version |
|
17 * 2 along with this work; if not, write to the Free Software Foundation, |
|
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
19 * |
|
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
21 * or visit www.oracle.com if you need additional information or have any |
|
22 * questions. |
|
23 */ |
|
24 |
|
25 /* |
|
26 * This file is available under and governed by the GNU General Public |
|
27 * License version 2 only, as published by the Free Software Foundation. |
|
28 * However, the following notice accompanied the original version of this |
|
29 * file and, per its terms, should not be removed: |
|
30 * |
|
31 * Copyright (c) 2000 World Wide Web Consortium, |
|
32 * (Massachusetts Institute of Technology, Institut National de |
|
33 * Recherche en Informatique et en Automatique, Keio University). All |
|
34 * Rights Reserved. This program is distributed under the W3C's Software |
|
35 * Intellectual Property License. This program is distributed in the |
|
36 * hope that it will be useful, but WITHOUT ANY WARRANTY; without even |
|
37 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
38 * PURPOSE. |
|
39 * See W3C License http://www.w3.org/Consortium/Legal/ for more details. |
|
40 */ |
|
41 |
|
42 package org.w3c.dom.css; |
|
43 |
|
44 import org.w3c.dom.DOMException; |
|
45 |
|
46 /** |
|
47 * The <code>CSSPrimitiveValue</code> interface represents a single CSS value |
|
48 * . This interface may be used to determine the value of a specific style |
|
49 * property currently set in a block or to set a specific style property |
|
50 * explicitly within the block. An instance of this interface might be |
|
51 * obtained from the <code>getPropertyCSSValue</code> method of the |
|
52 * <code>CSSStyleDeclaration</code> interface. A |
|
53 * <code>CSSPrimitiveValue</code> object only occurs in a context of a CSS |
|
54 * property. |
|
55 * <p> Conversions are allowed between absolute values (from millimeters to |
|
56 * centimeters, from degrees to radians, and so on) but not between relative |
|
57 * values. (For example, a pixel value cannot be converted to a centimeter |
|
58 * value.) Percentage values can't be converted since they are relative to |
|
59 * the parent value (or another property value). There is one exception for |
|
60 * color percentage values: since a color percentage value is relative to |
|
61 * the range 0-255, a color percentage value can be converted to a number; |
|
62 * (see also the <code>RGBColor</code> interface). |
|
63 * <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>. |
|
64 * @since DOM Level 2 |
|
65 */ |
|
66 public interface CSSPrimitiveValue extends CSSValue { |
|
67 // UnitTypes |
|
68 /** |
|
69 * The value is not a recognized CSS2 value. The value can only be |
|
70 * obtained by using the <code>cssText</code> attribute. |
|
71 */ |
|
72 public static final short CSS_UNKNOWN = 0; |
|
73 /** |
|
74 * The value is a simple number. The value can be obtained by using the |
|
75 * <code>getFloatValue</code> method. |
|
76 */ |
|
77 public static final short CSS_NUMBER = 1; |
|
78 /** |
|
79 * The value is a percentage. The value can be obtained by using the |
|
80 * <code>getFloatValue</code> method. |
|
81 */ |
|
82 public static final short CSS_PERCENTAGE = 2; |
|
83 /** |
|
84 * The value is a length (ems). The value can be obtained by using the |
|
85 * <code>getFloatValue</code> method. |
|
86 */ |
|
87 public static final short CSS_EMS = 3; |
|
88 /** |
|
89 * The value is a length (exs). The value can be obtained by using the |
|
90 * <code>getFloatValue</code> method. |
|
91 */ |
|
92 public static final short CSS_EXS = 4; |
|
93 /** |
|
94 * The value is a length (px). The value can be obtained by using the |
|
95 * <code>getFloatValue</code> method. |
|
96 */ |
|
97 public static final short CSS_PX = 5; |
|
98 /** |
|
99 * The value is a length (cm). The value can be obtained by using the |
|
100 * <code>getFloatValue</code> method. |
|
101 */ |
|
102 public static final short CSS_CM = 6; |
|
103 /** |
|
104 * The value is a length (mm). The value can be obtained by using the |
|
105 * <code>getFloatValue</code> method. |
|
106 */ |
|
107 public static final short CSS_MM = 7; |
|
108 /** |
|
109 * The value is a length (in). The value can be obtained by using the |
|
110 * <code>getFloatValue</code> method. |
|
111 */ |
|
112 public static final short CSS_IN = 8; |
|
113 /** |
|
114 * The value is a length (pt). The value can be obtained by using the |
|
115 * <code>getFloatValue</code> method. |
|
116 */ |
|
117 public static final short CSS_PT = 9; |
|
118 /** |
|
119 * The value is a length (pc). The value can be obtained by using the |
|
120 * <code>getFloatValue</code> method. |
|
121 */ |
|
122 public static final short CSS_PC = 10; |
|
123 /** |
|
124 * The value is an angle (deg). The value can be obtained by using the |
|
125 * <code>getFloatValue</code> method. |
|
126 */ |
|
127 public static final short CSS_DEG = 11; |
|
128 /** |
|
129 * The value is an angle (rad). The value can be obtained by using the |
|
130 * <code>getFloatValue</code> method. |
|
131 */ |
|
132 public static final short CSS_RAD = 12; |
|
133 /** |
|
134 * The value is an angle (grad). The value can be obtained by using the |
|
135 * <code>getFloatValue</code> method. |
|
136 */ |
|
137 public static final short CSS_GRAD = 13; |
|
138 /** |
|
139 * The value is a time (ms). The value can be obtained by using the |
|
140 * <code>getFloatValue</code> method. |
|
141 */ |
|
142 public static final short CSS_MS = 14; |
|
143 /** |
|
144 * The value is a time (s). The value can be obtained by using the |
|
145 * <code>getFloatValue</code> method. |
|
146 */ |
|
147 public static final short CSS_S = 15; |
|
148 /** |
|
149 * The value is a frequency (Hz). The value can be obtained by using the |
|
150 * <code>getFloatValue</code> method. |
|
151 */ |
|
152 public static final short CSS_HZ = 16; |
|
153 /** |
|
154 * The value is a frequency (kHz). The value can be obtained by using the |
|
155 * <code>getFloatValue</code> method. |
|
156 */ |
|
157 public static final short CSS_KHZ = 17; |
|
158 /** |
|
159 * The value is a number with an unknown dimension. The value can be |
|
160 * obtained by using the <code>getFloatValue</code> method. |
|
161 */ |
|
162 public static final short CSS_DIMENSION = 18; |
|
163 /** |
|
164 * The value is a STRING. The value can be obtained by using the |
|
165 * <code>getStringValue</code> method. |
|
166 */ |
|
167 public static final short CSS_STRING = 19; |
|
168 /** |
|
169 * The value is a URI. The value can be obtained by using the |
|
170 * <code>getStringValue</code> method. |
|
171 */ |
|
172 public static final short CSS_URI = 20; |
|
173 /** |
|
174 * The value is an identifier. The value can be obtained by using the |
|
175 * <code>getStringValue</code> method. |
|
176 */ |
|
177 public static final short CSS_IDENT = 21; |
|
178 /** |
|
179 * The value is a attribute function. The value can be obtained by using |
|
180 * the <code>getStringValue</code> method. |
|
181 */ |
|
182 public static final short CSS_ATTR = 22; |
|
183 /** |
|
184 * The value is a counter or counters function. The value can be obtained |
|
185 * by using the <code>getCounterValue</code> method. |
|
186 */ |
|
187 public static final short CSS_COUNTER = 23; |
|
188 /** |
|
189 * The value is a rect function. The value can be obtained by using the |
|
190 * <code>getRectValue</code> method. |
|
191 */ |
|
192 public static final short CSS_RECT = 24; |
|
193 /** |
|
194 * The value is a RGB color. The value can be obtained by using the |
|
195 * <code>getRGBColorValue</code> method. |
|
196 */ |
|
197 public static final short CSS_RGBCOLOR = 25; |
|
198 |
|
199 /** |
|
200 * The type of the value as defined by the constants specified above. |
|
201 */ |
|
202 public short getPrimitiveType(); |
|
203 |
|
204 /** |
|
205 * A method to set the float value with a specified unit. If the property |
|
206 * attached with this value can not accept the specified unit or the |
|
207 * float value, the value will be unchanged and a |
|
208 * <code>DOMException</code> will be raised. |
|
209 * @param unitType A unit code as defined above. The unit code can only |
|
210 * be a float unit type (i.e. <code>CSS_NUMBER</code>, |
|
211 * <code>CSS_PERCENTAGE</code>, <code>CSS_EMS</code>, |
|
212 * <code>CSS_EXS</code>, <code>CSS_PX</code>, <code>CSS_CM</code>, |
|
213 * <code>CSS_MM</code>, <code>CSS_IN</code>, <code>CSS_PT</code>, |
|
214 * <code>CSS_PC</code>, <code>CSS_DEG</code>, <code>CSS_RAD</code>, |
|
215 * <code>CSS_GRAD</code>, <code>CSS_MS</code>, <code>CSS_S</code>, |
|
216 * <code>CSS_HZ</code>, <code>CSS_KHZ</code>, |
|
217 * <code>CSS_DIMENSION</code>). |
|
218 * @param floatValue The new float value. |
|
219 * @exception DOMException |
|
220 * INVALID_ACCESS_ERR: Raised if the attached property doesn't support |
|
221 * the float value or the unit type. |
|
222 * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
|
223 */ |
|
224 public void setFloatValue(short unitType, |
|
225 float floatValue) |
|
226 throws DOMException; |
|
227 |
|
228 /** |
|
229 * This method is used to get a float value in a specified unit. If this |
|
230 * CSS value doesn't contain a float value or can't be converted into |
|
231 * the specified unit, a <code>DOMException</code> is raised. |
|
232 * @param unitType A unit code to get the float value. The unit code can |
|
233 * only be a float unit type (i.e. <code>CSS_NUMBER</code>, |
|
234 * <code>CSS_PERCENTAGE</code>, <code>CSS_EMS</code>, |
|
235 * <code>CSS_EXS</code>, <code>CSS_PX</code>, <code>CSS_CM</code>, |
|
236 * <code>CSS_MM</code>, <code>CSS_IN</code>, <code>CSS_PT</code>, |
|
237 * <code>CSS_PC</code>, <code>CSS_DEG</code>, <code>CSS_RAD</code>, |
|
238 * <code>CSS_GRAD</code>, <code>CSS_MS</code>, <code>CSS_S</code>, |
|
239 * <code>CSS_HZ</code>, <code>CSS_KHZ</code>, |
|
240 * <code>CSS_DIMENSION</code>). |
|
241 * @return The float value in the specified unit. |
|
242 * @exception DOMException |
|
243 * INVALID_ACCESS_ERR: Raised if the CSS value doesn't contain a float |
|
244 * value or if the float value can't be converted into the specified |
|
245 * unit. |
|
246 */ |
|
247 public float getFloatValue(short unitType) |
|
248 throws DOMException; |
|
249 |
|
250 /** |
|
251 * A method to set the string value with the specified unit. If the |
|
252 * property attached to this value can't accept the specified unit or |
|
253 * the string value, the value will be unchanged and a |
|
254 * <code>DOMException</code> will be raised. |
|
255 * @param stringType A string code as defined above. The string code can |
|
256 * only be a string unit type (i.e. <code>CSS_STRING</code>, |
|
257 * <code>CSS_URI</code>, <code>CSS_IDENT</code>, and |
|
258 * <code>CSS_ATTR</code>). |
|
259 * @param stringValue The new string value. |
|
260 * @exception DOMException |
|
261 * INVALID_ACCESS_ERR: Raised if the CSS value doesn't contain a string |
|
262 * value or if the string value can't be converted into the specified |
|
263 * unit. |
|
264 * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly. |
|
265 */ |
|
266 public void setStringValue(short stringType, |
|
267 String stringValue) |
|
268 throws DOMException; |
|
269 |
|
270 /** |
|
271 * This method is used to get the string value. If the CSS value doesn't |
|
272 * contain a string value, a <code>DOMException</code> is raised. Some |
|
273 * properties (like 'font-family' or 'voice-family') convert a |
|
274 * whitespace separated list of idents to a string. |
|
275 * @return The string value in the current unit. The current |
|
276 * <code>primitiveType</code> can only be a string unit type (i.e. |
|
277 * <code>CSS_STRING</code>, <code>CSS_URI</code>, |
|
278 * <code>CSS_IDENT</code> and <code>CSS_ATTR</code>). |
|
279 * @exception DOMException |
|
280 * INVALID_ACCESS_ERR: Raised if the CSS value doesn't contain a string |
|
281 * value. |
|
282 */ |
|
283 public String getStringValue() |
|
284 throws DOMException; |
|
285 |
|
286 /** |
|
287 * This method is used to get the Counter value. If this CSS value |
|
288 * doesn't contain a counter value, a <code>DOMException</code> is |
|
289 * raised. Modification to the corresponding style property can be |
|
290 * achieved using the <code>Counter</code> interface. |
|
291 * @return The Counter value. |
|
292 * @exception DOMException |
|
293 * INVALID_ACCESS_ERR: Raised if the CSS value doesn't contain a |
|
294 * Counter value (e.g. this is not <code>CSS_COUNTER</code>). |
|
295 */ |
|
296 public Counter getCounterValue() |
|
297 throws DOMException; |
|
298 |
|
299 /** |
|
300 * This method is used to get the Rect value. If this CSS value doesn't |
|
301 * contain a rect value, a <code>DOMException</code> is raised. |
|
302 * Modification to the corresponding style property can be achieved |
|
303 * using the <code>Rect</code> interface. |
|
304 * @return The Rect value. |
|
305 * @exception DOMException |
|
306 * INVALID_ACCESS_ERR: Raised if the CSS value doesn't contain a Rect |
|
307 * value. (e.g. this is not <code>CSS_RECT</code>). |
|
308 */ |
|
309 public Rect getRectValue() |
|
310 throws DOMException; |
|
311 |
|
312 /** |
|
313 * This method is used to get the RGB color. If this CSS value doesn't |
|
314 * contain a RGB color value, a <code>DOMException</code> is raised. |
|
315 * Modification to the corresponding style property can be achieved |
|
316 * using the <code>RGBColor</code> interface. |
|
317 * @return the RGB color value. |
|
318 * @exception DOMException |
|
319 * INVALID_ACCESS_ERR: Raised if the attached property can't return a |
|
320 * RGB color value (e.g. this is not <code>CSS_RGBCOLOR</code>). |
|
321 */ |
|
322 public RGBColor getRGBColorValue() |
|
323 throws DOMException; |
|
324 |
|
325 } |
|