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