001: /*
002: * Copyright (c) 2000 World Wide Web Consortium,
003: * (Massachusetts Institute of Technology, Institut National de
004: * Recherche en Informatique et en Automatique, Keio University). All
005: * Rights Reserved. This program is distributed under the W3C's Software
006: * Intellectual Property License. This program is distributed in the
007: * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
008: * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
009: * PURPOSE.
010: * See W3C License http://www.w3.org/Consortium/Legal/ for more details.
011: */
012:
013: package org.w3c.dom.css;
014:
015: import org.w3c.dom.DOMException;
016:
017: /**
018: * The <code>CSSPrimitiveValue</code> interface represents a single CSS value
019: * . This interface may be used to determine the value of a specific style
020: * property currently set in a block or to set a specific style property
021: * explicitly within the block. An instance of this interface might be
022: * obtained from the <code>getPropertyCSSValue</code> method of the
023: * <code>CSSStyleDeclaration</code> interface. A
024: * <code>CSSPrimitiveValue</code> object only occurs in a context of a CSS
025: * property.
026: * <p> Conversions are allowed between absolute values (from millimeters to
027: * centimeters, from degrees to radians, and so on) but not between relative
028: * values. (For example, a pixel value cannot be converted to a centimeter
029: * value.) Percentage values can't be converted since they are relative to
030: * the parent value (or another property value). There is one exception for
031: * color percentage values: since a color percentage value is relative to
032: * the range 0-255, a color percentage value can be converted to a number;
033: * (see also the <code>RGBColor</code> interface).
034: * <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>.
035: * @since DOM Level 2
036: */
037: public interface CSSPrimitiveValue extends CSSValue {
038: // UnitTypes
039: /**
040: * The value is not a recognized CSS2 value. The value can only be
041: * obtained by using the <code>cssText</code> attribute.
042: */
043: public static final short CSS_UNKNOWN = 0;
044: /**
045: * The value is a simple number. The value can be obtained by using the
046: * <code>getFloatValue</code> method.
047: */
048: public static final short CSS_NUMBER = 1;
049: /**
050: * The value is a percentage. The value can be obtained by using the
051: * <code>getFloatValue</code> method.
052: */
053: public static final short CSS_PERCENTAGE = 2;
054: /**
055: * The value is a length (ems). The value can be obtained by using the
056: * <code>getFloatValue</code> method.
057: */
058: public static final short CSS_EMS = 3;
059: /**
060: * The value is a length (exs). The value can be obtained by using the
061: * <code>getFloatValue</code> method.
062: */
063: public static final short CSS_EXS = 4;
064: /**
065: * The value is a length (px). The value can be obtained by using the
066: * <code>getFloatValue</code> method.
067: */
068: public static final short CSS_PX = 5;
069: /**
070: * The value is a length (cm). The value can be obtained by using the
071: * <code>getFloatValue</code> method.
072: */
073: public static final short CSS_CM = 6;
074: /**
075: * The value is a length (mm). The value can be obtained by using the
076: * <code>getFloatValue</code> method.
077: */
078: public static final short CSS_MM = 7;
079: /**
080: * The value is a length (in). The value can be obtained by using the
081: * <code>getFloatValue</code> method.
082: */
083: public static final short CSS_IN = 8;
084: /**
085: * The value is a length (pt). The value can be obtained by using the
086: * <code>getFloatValue</code> method.
087: */
088: public static final short CSS_PT = 9;
089: /**
090: * The value is a length (pc). The value can be obtained by using the
091: * <code>getFloatValue</code> method.
092: */
093: public static final short CSS_PC = 10;
094: /**
095: * The value is an angle (deg). The value can be obtained by using the
096: * <code>getFloatValue</code> method.
097: */
098: public static final short CSS_DEG = 11;
099: /**
100: * The value is an angle (rad). The value can be obtained by using the
101: * <code>getFloatValue</code> method.
102: */
103: public static final short CSS_RAD = 12;
104: /**
105: * The value is an angle (grad). The value can be obtained by using the
106: * <code>getFloatValue</code> method.
107: */
108: public static final short CSS_GRAD = 13;
109: /**
110: * The value is a time (ms). The value can be obtained by using the
111: * <code>getFloatValue</code> method.
112: */
113: public static final short CSS_MS = 14;
114: /**
115: * The value is a time (s). The value can be obtained by using the
116: * <code>getFloatValue</code> method.
117: */
118: public static final short CSS_S = 15;
119: /**
120: * The value is a frequency (Hz). The value can be obtained by using the
121: * <code>getFloatValue</code> method.
122: */
123: public static final short CSS_HZ = 16;
124: /**
125: * The value is a frequency (kHz). The value can be obtained by using the
126: * <code>getFloatValue</code> method.
127: */
128: public static final short CSS_KHZ = 17;
129: /**
130: * The value is a number with an unknown dimension. The value can be
131: * obtained by using the <code>getFloatValue</code> method.
132: */
133: public static final short CSS_DIMENSION = 18;
134: /**
135: * The value is a STRING. The value can be obtained by using the
136: * <code>getStringValue</code> method.
137: */
138: public static final short CSS_STRING = 19;
139: /**
140: * The value is a URI. The value can be obtained by using the
141: * <code>getStringValue</code> method.
142: */
143: public static final short CSS_URI = 20;
144: /**
145: * The value is an identifier. The value can be obtained by using the
146: * <code>getStringValue</code> method.
147: */
148: public static final short CSS_IDENT = 21;
149: /**
150: * The value is a attribute function. The value can be obtained by using
151: * the <code>getStringValue</code> method.
152: */
153: public static final short CSS_ATTR = 22;
154: /**
155: * The value is a counter or counters function. The value can be obtained
156: * by using the <code>getCounterValue</code> method.
157: */
158: public static final short CSS_COUNTER = 23;
159: /**
160: * The value is a rect function. The value can be obtained by using the
161: * <code>getRectValue</code> method.
162: */
163: public static final short CSS_RECT = 24;
164: /**
165: * The value is a RGB color. The value can be obtained by using the
166: * <code>getRGBColorValue</code> method.
167: */
168: public static final short CSS_RGBCOLOR = 25;
169:
170: /**
171: * The type of the value as defined by the constants specified above.
172: */
173: public short getPrimitiveType();
174:
175: /**
176: * A method to set the float value with a specified unit. If the property
177: * attached with this value can not accept the specified unit or the
178: * float value, the value will be unchanged and a
179: * <code>DOMException</code> will be raised.
180: * @param unitType A unit code as defined above. The unit code can only
181: * be a float unit type (i.e. <code>CSS_NUMBER</code>,
182: * <code>CSS_PERCENTAGE</code>, <code>CSS_EMS</code>,
183: * <code>CSS_EXS</code>, <code>CSS_PX</code>, <code>CSS_CM</code>,
184: * <code>CSS_MM</code>, <code>CSS_IN</code>, <code>CSS_PT</code>,
185: * <code>CSS_PC</code>, <code>CSS_DEG</code>, <code>CSS_RAD</code>,
186: * <code>CSS_GRAD</code>, <code>CSS_MS</code>, <code>CSS_S</code>,
187: * <code>CSS_HZ</code>, <code>CSS_KHZ</code>,
188: * <code>CSS_DIMENSION</code>).
189: * @param floatValue The new float value.
190: * @exception DOMException
191: * INVALID_ACCESS_ERR: Raised if the attached property doesn't support
192: * the float value or the unit type.
193: * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly.
194: */
195: public void setFloatValue(short unitType, float floatValue)
196: throws DOMException;
197:
198: /**
199: * This method is used to get a float value in a specified unit. If this
200: * CSS value doesn't contain a float value or can't be converted into
201: * the specified unit, a <code>DOMException</code> is raised.
202: * @param unitType A unit code to get the float value. The unit code can
203: * only be a float unit type (i.e. <code>CSS_NUMBER</code>,
204: * <code>CSS_PERCENTAGE</code>, <code>CSS_EMS</code>,
205: * <code>CSS_EXS</code>, <code>CSS_PX</code>, <code>CSS_CM</code>,
206: * <code>CSS_MM</code>, <code>CSS_IN</code>, <code>CSS_PT</code>,
207: * <code>CSS_PC</code>, <code>CSS_DEG</code>, <code>CSS_RAD</code>,
208: * <code>CSS_GRAD</code>, <code>CSS_MS</code>, <code>CSS_S</code>,
209: * <code>CSS_HZ</code>, <code>CSS_KHZ</code>,
210: * <code>CSS_DIMENSION</code>).
211: * @return The float value in the specified unit.
212: * @exception DOMException
213: * INVALID_ACCESS_ERR: Raised if the CSS value doesn't contain a float
214: * value or if the float value can't be converted into the specified
215: * unit.
216: */
217: public float getFloatValue(short unitType) throws DOMException;
218:
219: /**
220: * A method to set the string value with the specified unit. If the
221: * property attached to this value can't accept the specified unit or
222: * the string value, the value will be unchanged and a
223: * <code>DOMException</code> will be raised.
224: * @param stringType A string code as defined above. The string code can
225: * only be a string unit type (i.e. <code>CSS_STRING</code>,
226: * <code>CSS_URI</code>, <code>CSS_IDENT</code>, and
227: * <code>CSS_ATTR</code>).
228: * @param stringValue The new string value.
229: * @exception DOMException
230: * INVALID_ACCESS_ERR: Raised if the CSS value doesn't contain a string
231: * value or if the string value can't be converted into the specified
232: * unit.
233: * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly.
234: */
235: public void setStringValue(short stringType, String stringValue)
236: throws DOMException;
237:
238: /**
239: * This method is used to get the string value. If the CSS value doesn't
240: * contain a string value, a <code>DOMException</code> is raised. Some
241: * properties (like 'font-family' or 'voice-family') convert a
242: * whitespace separated list of idents to a string.
243: * @return The string value in the current unit. The current
244: * <code>primitiveType</code> can only be a string unit type (i.e.
245: * <code>CSS_STRING</code>, <code>CSS_URI</code>,
246: * <code>CSS_IDENT</code> and <code>CSS_ATTR</code>).
247: * @exception DOMException
248: * INVALID_ACCESS_ERR: Raised if the CSS value doesn't contain a string
249: * value.
250: */
251: public String getStringValue() throws DOMException;
252:
253: /**
254: * This method is used to get the Counter value. If this CSS value
255: * doesn't contain a counter value, a <code>DOMException</code> is
256: * raised. Modification to the corresponding style property can be
257: * achieved using the <code>Counter</code> interface.
258: * @return The Counter value.
259: * @exception DOMException
260: * INVALID_ACCESS_ERR: Raised if the CSS value doesn't contain a
261: * Counter value (e.g. this is not <code>CSS_COUNTER</code>).
262: */
263: public Counter getCounterValue() throws DOMException;
264:
265: /**
266: * This method is used to get the Rect value. If this CSS value doesn't
267: * contain a rect value, a <code>DOMException</code> is raised.
268: * Modification to the corresponding style property can be achieved
269: * using the <code>Rect</code> interface.
270: * @return The Rect value.
271: * @exception DOMException
272: * INVALID_ACCESS_ERR: Raised if the CSS value doesn't contain a Rect
273: * value. (e.g. this is not <code>CSS_RECT</code>).
274: */
275: public Rect getRectValue() throws DOMException;
276:
277: /**
278: * This method is used to get the RGB color. If this CSS value doesn't
279: * contain a RGB color value, a <code>DOMException</code> is raised.
280: * Modification to the corresponding style property can be achieved
281: * using the <code>RGBColor</code> interface.
282: * @return the RGB color value.
283: * @exception DOMException
284: * INVALID_ACCESS_ERR: Raised if the attached property can't return a
285: * RGB color value (e.g. this is not <code>CSS_RGBCOLOR</code>).
286: */
287: public RGBColor getRGBColorValue() throws DOMException;
288:
289: }
|