001 /*
002 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
003 *
004 * This code is free software; you can redistribute it and/or modify it
005 * under the terms of the GNU General Public License version 2 only, as
006 * published by the Free Software Foundation. Sun designates this
007 * particular file as subject to the "Classpath" exception as provided
008 * by Sun in the LICENSE file that accompanied this code.
009 *
010 * This code is distributed in the hope that it will be useful, but WITHOUT
011 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
012 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
013 * version 2 for more details (a copy is included in the LICENSE file that
014 * accompanied this code).
015 *
016 * You should have received a copy of the GNU General Public License version
017 * 2 along with this work; if not, write to the Free Software Foundation,
018 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
019 *
020 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
021 * CA 95054 USA or visit www.sun.com if you need additional information or
022 * have any questions.
023 */
024
025 /*
026 * This file is available under and governed by the GNU General Public
027 * License version 2 only, as published by the Free Software Foundation.
028 * However, the following notice accompanied the original version of this
029 * file and, per its terms, should not be removed:
030 *
031 * Copyright (c) 2000 World Wide Web Consortium,
032 * (Massachusetts Institute of Technology, Institut National de
033 * Recherche en Informatique et en Automatique, Keio University). All
034 * Rights Reserved. This program is distributed under the W3C's Software
035 * Intellectual Property License. This program is distributed in the
036 * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
037 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
038 * PURPOSE.
039 * See W3C License http://www.w3.org/Consortium/Legal/ for more details.
040 */
041
042 package org.w3c.dom.css;
043
044 import org.w3c.dom.DOMException;
045
046 /**
047 * The <code>CSSPrimitiveValue</code> interface represents a single CSS value
048 * . This interface may be used to determine the value of a specific style
049 * property currently set in a block or to set a specific style property
050 * explicitly within the block. An instance of this interface might be
051 * obtained from the <code>getPropertyCSSValue</code> method of the
052 * <code>CSSStyleDeclaration</code> interface. A
053 * <code>CSSPrimitiveValue</code> object only occurs in a context of a CSS
054 * property.
055 * <p> Conversions are allowed between absolute values (from millimeters to
056 * centimeters, from degrees to radians, and so on) but not between relative
057 * values. (For example, a pixel value cannot be converted to a centimeter
058 * value.) Percentage values can't be converted since they are relative to
059 * the parent value (or another property value). There is one exception for
060 * color percentage values: since a color percentage value is relative to
061 * the range 0-255, a color percentage value can be converted to a number;
062 * (see also the <code>RGBColor</code> interface).
063 * <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>.
064 * @since DOM Level 2
065 */
066 public interface CSSPrimitiveValue extends CSSValue {
067 // UnitTypes
068 /**
069 * The value is not a recognized CSS2 value. The value can only be
070 * obtained by using the <code>cssText</code> attribute.
071 */
072 public static final short CSS_UNKNOWN = 0;
073 /**
074 * The value is a simple number. The value can be obtained by using the
075 * <code>getFloatValue</code> method.
076 */
077 public static final short CSS_NUMBER = 1;
078 /**
079 * The value is a percentage. The value can be obtained by using the
080 * <code>getFloatValue</code> method.
081 */
082 public static final short CSS_PERCENTAGE = 2;
083 /**
084 * The value is a length (ems). The value can be obtained by using the
085 * <code>getFloatValue</code> method.
086 */
087 public static final short CSS_EMS = 3;
088 /**
089 * The value is a length (exs). The value can be obtained by using the
090 * <code>getFloatValue</code> method.
091 */
092 public static final short CSS_EXS = 4;
093 /**
094 * The value is a length (px). The value can be obtained by using the
095 * <code>getFloatValue</code> method.
096 */
097 public static final short CSS_PX = 5;
098 /**
099 * 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, float floatValue)
225 throws DOMException;
226
227 /**
228 * This method is used to get a float value in a specified unit. If this
229 * CSS value doesn't contain a float value or can't be converted into
230 * the specified unit, a <code>DOMException</code> is raised.
231 * @param unitType A unit code to get the float value. The unit code can
232 * only be a float unit type (i.e. <code>CSS_NUMBER</code>,
233 * <code>CSS_PERCENTAGE</code>, <code>CSS_EMS</code>,
234 * <code>CSS_EXS</code>, <code>CSS_PX</code>, <code>CSS_CM</code>,
235 * <code>CSS_MM</code>, <code>CSS_IN</code>, <code>CSS_PT</code>,
236 * <code>CSS_PC</code>, <code>CSS_DEG</code>, <code>CSS_RAD</code>,
237 * <code>CSS_GRAD</code>, <code>CSS_MS</code>, <code>CSS_S</code>,
238 * <code>CSS_HZ</code>, <code>CSS_KHZ</code>,
239 * <code>CSS_DIMENSION</code>).
240 * @return The float value in the specified unit.
241 * @exception DOMException
242 * INVALID_ACCESS_ERR: Raised if the CSS value doesn't contain a float
243 * value or if the float value can't be converted into the specified
244 * unit.
245 */
246 public float getFloatValue(short unitType) throws DOMException;
247
248 /**
249 * A method to set the string value with the specified unit. If the
250 * property attached to this value can't accept the specified unit or
251 * the string value, the value will be unchanged and a
252 * <code>DOMException</code> will be raised.
253 * @param stringType A string code as defined above. The string code can
254 * only be a string unit type (i.e. <code>CSS_STRING</code>,
255 * <code>CSS_URI</code>, <code>CSS_IDENT</code>, and
256 * <code>CSS_ATTR</code>).
257 * @param stringValue The new string value.
258 * @exception DOMException
259 * INVALID_ACCESS_ERR: Raised if the CSS value doesn't contain a string
260 * value or if the string value can't be converted into the specified
261 * unit.
262 * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly.
263 */
264 public void setStringValue(short stringType, String stringValue)
265 throws DOMException;
266
267 /**
268 * This method is used to get the string value. If the CSS value doesn't
269 * contain a string value, a <code>DOMException</code> is raised. Some
270 * properties (like 'font-family' or 'voice-family') convert a
271 * whitespace separated list of idents to a string.
272 * @return The string value in the current unit. The current
273 * <code>primitiveType</code> can only be a string unit type (i.e.
274 * <code>CSS_STRING</code>, <code>CSS_URI</code>,
275 * <code>CSS_IDENT</code> and <code>CSS_ATTR</code>).
276 * @exception DOMException
277 * INVALID_ACCESS_ERR: Raised if the CSS value doesn't contain a string
278 * value.
279 */
280 public String getStringValue() throws DOMException;
281
282 /**
283 * This method is used to get the Counter value. If this CSS value
284 * doesn't contain a counter value, a <code>DOMException</code> is
285 * raised. Modification to the corresponding style property can be
286 * achieved using the <code>Counter</code> interface.
287 * @return The Counter value.
288 * @exception DOMException
289 * INVALID_ACCESS_ERR: Raised if the CSS value doesn't contain a
290 * Counter value (e.g. this is not <code>CSS_COUNTER</code>).
291 */
292 public Counter getCounterValue() throws DOMException;
293
294 /**
295 * This method is used to get the Rect value. If this CSS value doesn't
296 * contain a rect value, a <code>DOMException</code> is raised.
297 * Modification to the corresponding style property can be achieved
298 * using the <code>Rect</code> interface.
299 * @return The Rect value.
300 * @exception DOMException
301 * INVALID_ACCESS_ERR: Raised if the CSS value doesn't contain a Rect
302 * value. (e.g. this is not <code>CSS_RECT</code>).
303 */
304 public Rect getRectValue() throws DOMException;
305
306 /**
307 * This method is used to get the RGB color. If this CSS value doesn't
308 * contain a RGB color value, a <code>DOMException</code> is raised.
309 * Modification to the corresponding style property can be achieved
310 * using the <code>RGBColor</code> interface.
311 * @return the RGB color value.
312 * @exception DOMException
313 * INVALID_ACCESS_ERR: Raised if the attached property can't return a
314 * RGB color value (e.g. this is not <code>CSS_RGBCOLOR</code>).
315 */
316 public RGBColor getRGBColorValue() throws DOMException;
317
318 }
|