Path: blob/aarch64-shenandoah-jdk8u272-b10/jaxp/src/org/w3c/dom/css/CSSPrimitiveValue.java
86410 views
/*1* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.2*3* This code is free software; you can redistribute it and/or modify it4* under the terms of the GNU General Public License version 2 only, as5* published by the Free Software Foundation. Oracle designates this6* particular file as subject to the "Classpath" exception as provided7* by Oracle in the LICENSE file that accompanied this code.8*9* This code is distributed in the hope that it will be useful, but WITHOUT10* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or11* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License12* version 2 for more details (a copy is included in the LICENSE file that13* accompanied this code).14*15* You should have received a copy of the GNU General Public License version16* 2 along with this work; if not, write to the Free Software Foundation,17* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.18*19* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA20* or visit www.oracle.com if you need additional information or have any21* questions.22*/2324/*25* This file is available under and governed by the GNU General Public26* License version 2 only, as published by the Free Software Foundation.27* However, the following notice accompanied the original version of this28* file and, per its terms, should not be removed:29*30* Copyright (c) 2000 World Wide Web Consortium,31* (Massachusetts Institute of Technology, Institut National de32* Recherche en Informatique et en Automatique, Keio University). All33* Rights Reserved. This program is distributed under the W3C's Software34* Intellectual Property License. This program is distributed in the35* hope that it will be useful, but WITHOUT ANY WARRANTY; without even36* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR37* PURPOSE.38* See W3C License http://www.w3.org/Consortium/Legal/ for more details.39*/4041package org.w3c.dom.css;4243import org.w3c.dom.DOMException;4445/**46* The <code>CSSPrimitiveValue</code> interface represents a single CSS value47* . This interface may be used to determine the value of a specific style48* property currently set in a block or to set a specific style property49* explicitly within the block. An instance of this interface might be50* obtained from the <code>getPropertyCSSValue</code> method of the51* <code>CSSStyleDeclaration</code> interface. A52* <code>CSSPrimitiveValue</code> object only occurs in a context of a CSS53* property.54* <p> Conversions are allowed between absolute values (from millimeters to55* centimeters, from degrees to radians, and so on) but not between relative56* values. (For example, a pixel value cannot be converted to a centimeter57* value.) Percentage values can't be converted since they are relative to58* the parent value (or another property value). There is one exception for59* color percentage values: since a color percentage value is relative to60* the range 0-255, a color percentage value can be converted to a number;61* (see also the <code>RGBColor</code> interface).62* <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>.63* @since DOM Level 264*/65public interface CSSPrimitiveValue extends CSSValue {66// UnitTypes67/**68* The value is not a recognized CSS2 value. The value can only be69* obtained by using the <code>cssText</code> attribute.70*/71public static final short CSS_UNKNOWN = 0;72/**73* The value is a simple number. The value can be obtained by using the74* <code>getFloatValue</code> method.75*/76public static final short CSS_NUMBER = 1;77/**78* The value is a percentage. The value can be obtained by using the79* <code>getFloatValue</code> method.80*/81public static final short CSS_PERCENTAGE = 2;82/**83* The value is a length (ems). The value can be obtained by using the84* <code>getFloatValue</code> method.85*/86public static final short CSS_EMS = 3;87/**88* The value is a length (exs). The value can be obtained by using the89* <code>getFloatValue</code> method.90*/91public static final short CSS_EXS = 4;92/**93* The value is a length (px). The value can be obtained by using the94* <code>getFloatValue</code> method.95*/96public static final short CSS_PX = 5;97/**98* The value is a length (cm). The value can be obtained by using the99* <code>getFloatValue</code> method.100*/101public static final short CSS_CM = 6;102/**103* The value is a length (mm). The value can be obtained by using the104* <code>getFloatValue</code> method.105*/106public static final short CSS_MM = 7;107/**108* The value is a length (in). The value can be obtained by using the109* <code>getFloatValue</code> method.110*/111public static final short CSS_IN = 8;112/**113* The value is a length (pt). The value can be obtained by using the114* <code>getFloatValue</code> method.115*/116public static final short CSS_PT = 9;117/**118* The value is a length (pc). The value can be obtained by using the119* <code>getFloatValue</code> method.120*/121public static final short CSS_PC = 10;122/**123* The value is an angle (deg). The value can be obtained by using the124* <code>getFloatValue</code> method.125*/126public static final short CSS_DEG = 11;127/**128* The value is an angle (rad). The value can be obtained by using the129* <code>getFloatValue</code> method.130*/131public static final short CSS_RAD = 12;132/**133* The value is an angle (grad). The value can be obtained by using the134* <code>getFloatValue</code> method.135*/136public static final short CSS_GRAD = 13;137/**138* The value is a time (ms). The value can be obtained by using the139* <code>getFloatValue</code> method.140*/141public static final short CSS_MS = 14;142/**143* The value is a time (s). The value can be obtained by using the144* <code>getFloatValue</code> method.145*/146public static final short CSS_S = 15;147/**148* The value is a frequency (Hz). The value can be obtained by using the149* <code>getFloatValue</code> method.150*/151public static final short CSS_HZ = 16;152/**153* The value is a frequency (kHz). The value can be obtained by using the154* <code>getFloatValue</code> method.155*/156public static final short CSS_KHZ = 17;157/**158* The value is a number with an unknown dimension. The value can be159* obtained by using the <code>getFloatValue</code> method.160*/161public static final short CSS_DIMENSION = 18;162/**163* The value is a STRING. The value can be obtained by using the164* <code>getStringValue</code> method.165*/166public static final short CSS_STRING = 19;167/**168* The value is a URI. The value can be obtained by using the169* <code>getStringValue</code> method.170*/171public static final short CSS_URI = 20;172/**173* The value is an identifier. The value can be obtained by using the174* <code>getStringValue</code> method.175*/176public static final short CSS_IDENT = 21;177/**178* The value is a attribute function. The value can be obtained by using179* the <code>getStringValue</code> method.180*/181public static final short CSS_ATTR = 22;182/**183* The value is a counter or counters function. The value can be obtained184* by using the <code>getCounterValue</code> method.185*/186public static final short CSS_COUNTER = 23;187/**188* The value is a rect function. The value can be obtained by using the189* <code>getRectValue</code> method.190*/191public static final short CSS_RECT = 24;192/**193* The value is a RGB color. The value can be obtained by using the194* <code>getRGBColorValue</code> method.195*/196public static final short CSS_RGBCOLOR = 25;197198/**199* The type of the value as defined by the constants specified above.200*/201public short getPrimitiveType();202203/**204* A method to set the float value with a specified unit. If the property205* attached with this value can not accept the specified unit or the206* float value, the value will be unchanged and a207* <code>DOMException</code> will be raised.208* @param unitType A unit code as defined above. The unit code can only209* be a float unit type (i.e. <code>CSS_NUMBER</code>,210* <code>CSS_PERCENTAGE</code>, <code>CSS_EMS</code>,211* <code>CSS_EXS</code>, <code>CSS_PX</code>, <code>CSS_CM</code>,212* <code>CSS_MM</code>, <code>CSS_IN</code>, <code>CSS_PT</code>,213* <code>CSS_PC</code>, <code>CSS_DEG</code>, <code>CSS_RAD</code>,214* <code>CSS_GRAD</code>, <code>CSS_MS</code>, <code>CSS_S</code>,215* <code>CSS_HZ</code>, <code>CSS_KHZ</code>,216* <code>CSS_DIMENSION</code>).217* @param floatValue The new float value.218* @exception DOMException219* INVALID_ACCESS_ERR: Raised if the attached property doesn't support220* the float value or the unit type.221* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly.222*/223public void setFloatValue(short unitType,224float floatValue)225throws DOMException;226227/**228* This method is used to get a float value in a specified unit. If this229* CSS value doesn't contain a float value or can't be converted into230* the specified unit, a <code>DOMException</code> is raised.231* @param unitType A unit code to get the float value. The unit code can232* 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 DOMException242* INVALID_ACCESS_ERR: Raised if the CSS value doesn't contain a float243* value or if the float value can't be converted into the specified244* unit.245*/246public float getFloatValue(short unitType)247throws DOMException;248249/**250* A method to set the string value with the specified unit. If the251* property attached to this value can't accept the specified unit or252* the string value, the value will be unchanged and a253* <code>DOMException</code> will be raised.254* @param stringType A string code as defined above. The string code can255* only be a string unit type (i.e. <code>CSS_STRING</code>,256* <code>CSS_URI</code>, <code>CSS_IDENT</code>, and257* <code>CSS_ATTR</code>).258* @param stringValue The new string value.259* @exception DOMException260* INVALID_ACCESS_ERR: Raised if the CSS value doesn't contain a string261* value or if the string value can't be converted into the specified262* unit.263* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly.264*/265public void setStringValue(short stringType,266String stringValue)267throws DOMException;268269/**270* This method is used to get the string value. If the CSS value doesn't271* contain a string value, a <code>DOMException</code> is raised. Some272* properties (like 'font-family' or 'voice-family') convert a273* whitespace separated list of idents to a string.274* @return The string value in the current unit. The current275* <code>primitiveType</code> can only be a string unit type (i.e.276* <code>CSS_STRING</code>, <code>CSS_URI</code>,277* <code>CSS_IDENT</code> and <code>CSS_ATTR</code>).278* @exception DOMException279* INVALID_ACCESS_ERR: Raised if the CSS value doesn't contain a string280* value.281*/282public String getStringValue()283throws DOMException;284285/**286* This method is used to get the Counter value. If this CSS value287* doesn't contain a counter value, a <code>DOMException</code> is288* raised. Modification to the corresponding style property can be289* achieved using the <code>Counter</code> interface.290* @return The Counter value.291* @exception DOMException292* INVALID_ACCESS_ERR: Raised if the CSS value doesn't contain a293* Counter value (e.g. this is not <code>CSS_COUNTER</code>).294*/295public Counter getCounterValue()296throws DOMException;297298/**299* This method is used to get the Rect value. If this CSS value doesn't300* contain a rect value, a <code>DOMException</code> is raised.301* Modification to the corresponding style property can be achieved302* using the <code>Rect</code> interface.303* @return The Rect value.304* @exception DOMException305* INVALID_ACCESS_ERR: Raised if the CSS value doesn't contain a Rect306* value. (e.g. this is not <code>CSS_RECT</code>).307*/308public Rect getRectValue()309throws DOMException;310311/**312* This method is used to get the RGB color. If this CSS value doesn't313* contain a RGB color value, a <code>DOMException</code> is raised.314* Modification to the corresponding style property can be achieved315* using the <code>RGBColor</code> interface.316* @return the RGB color value.317* @exception DOMException318* INVALID_ACCESS_ERR: Raised if the attached property can't return a319* RGB color value (e.g. this is not <code>CSS_RGBCOLOR</code>).320*/321public RGBColor getRGBColorValue()322throws DOMException;323324}325326327