Package cssutils :: Package css :: Module cssvalue :: Class CSSValue |
[hide private]
[frames] | no frames]

# Class CSSValue

source code

    object --+
             |
     util.Base --+
                 |
                CSSValue

Known Subclasses:
  - CSSPrimitiveValue
  - , CSSValueList

The CSSValue interface represents a simple or a complex value. A CSSValue object only occurs in a context of a CSS property

# Properties

cssText
  A string representation of the current value.
cssValueType
  A (readonly) code defining the type of the value.
seq: a list (cssutils)
  All parts of this style declaration including CSSComments
valid: boolean
  if the value is valid at all, False for e.g. color: #1
wellformed
  if this Property is syntactically ok
_value (INTERNAL!)
  value without any comments, used to validate

Nested Classes | [hide private]
Inherited from `util.Base` (private): `_prods`

Instance Methods | [hide private]
__init__(self, cssText=None, readonly=False, _propertyName=None) inits a new CSS Value | source code
_getValue(self) | source code
_setValue(self, value) overwritten by CSSValueList! | source code
_getCssText(self) | source code
_setCssText(self, cssText) DOMException on setting | source code
_getCssValueType(self) | source code
_getCssValueTypeString(self) | source code
_validate(self) validates value against _propertyName context if given | source code
_get_propertyName(self) | source code
_set_propertyName(self, _propertyName) | source code
__repr__(self) repr(x) | source code
__str__(self) str(x) | source code
Inherited from `util.Base` (private): `_adddefaultproductions`, `_checkReadonly`, `_nexttoken`, `_parse`, `_splitNamespacesOff`, `_stringtokenvalue`, `_tokenize2`, `_tokensupto2`, `_tokenvalue`, `_type`, `_uritokenvalue`, `_valuestr` Inherited from `object`: `__delattr__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__setattr__`

Static Methods | [hide private]
Inherited from `util.Base` (private): `_normalize`

Class Variables | [hide private]
| CSS_INHERIT = `0` The value is inherited and the cssText contains "inherit".
| CSS_PRIMITIVE_VALUE = `1` The value is a primitive value and an instance of the CSSPrimitiveValue interface can be obtained by using binding-specific casting methods on this instance of the CSSValue interface.
| CSS_VALUE_LIST = `2` The value is a CSSValue list and an instance of the CSSValueList interface can be obtained by using binding-specific casting methods on this instance of the CSSValue interface.
| CSS_CUSTOM = `3` The value is a custom value.
| _typestrings = ``[``'``CSS_INHERIT``'``,` `'``CSS_PRIMITIVE_VALUE``'``,` `'``CSS_VAL``...``
Inherited from `util.Base` (private): `_SHORTHANDPROPERTIES`, `_log`

Properties | [hide private]
| _value Actual cssText value of this CSSValue.
| cssText A string representation of the current value.
| cssValueType A (readonly) code defining the type of the value as defined above.
| cssValueTypeString cssutils: Name of cssValueType of this CSSValue (readonly).
| _propertyName cssutils: Property this values is validated against
Inherited from `object`: `__class__`

Method Details | [hide private]

### __init__(self, cssText=None, readonly=False, _propertyName=None) (Constructor) | source code
inits a new CSS Value cssText the parsable cssText of the value readonly defaults to False property used to validate this value in the context of a property Overrides: object.__init__

### _setCssText(self, cssText) | source code
    unary_operator
      : '-' | '+'
      ;
    operator
      : '/' S* | ',' S* | /* empty */
      ;
    expr
      : term [ operator term ]*
      ;
    term
      : unary_operator?
        [ NUMBER S* | PERCENTAGE S* | LENGTH S* | EMS S* | EXS S* | ANGLE S* |
          TIME S* | FREQ S* ]
      | STRING S* | IDENT S* | URI S* | hexcolor | function
      ;
    function
      : FUNCTION S* expr ')' S*
      ;
    /*
     * There is a constraint on the color that it must
     * have either 3 or 6 hex-digits (i.e., [0-9a-fA-F])
     * after the "#"; e.g., "#000" is OK, but "#abcd" is not.
     */
    hexcolor
      : HASH S*
      ;
DOMException on setting SYNTAX_ERR: (self) Raised if the specified CSS string value has a syntax error (according to the attached property) or is unparsable. TODO: INVALID_MODIFICATION_ERR: Raised if the specified CSS string value represents a different type of values than the values allowed by the CSS property. NO_MODIFICATION_ALLOWED_ERR: (self) Raised if this value is readonly.

### __repr__(self) (Representation operator) | source code
repr(x) Overrides: object.__repr__ (inherited documentation)

### __str__(self) (Informal representation operator) | source code
str(x) Overrides: object.__str__ (inherited documentation)

Class Variable Details | [hide private]

  ### _typestrings Value:
      ['CSS_INHERIT', 'CSS_PRIMITIVE_VALUE', 'CSS_VALUE_LIST', 'CSS_CUSTOM']

Property Details | [hide private]

### _value Actual cssText value of this CSSValue. Get Method: _getValue(self) Set Method: _setValue(self, value) - overwritten by CSSValueList!

### cssText A string representation of the current value. Get Method: _getCssText(self) Set Method: _setCssText(self, cssText) - DOMException on setting

### cssValueType A (readonly) code defining the type of the value as defined above. Get Method: _getCssValueType(self)

### cssValueTypeString cssutils: Name of cssValueType of this CSSValue (readonly). Get Method: _getCssValueTypeString(self)

### _propertyName cssutils: Property this values is validated against Get Method: _get_propertyName(self) Set Method: _set_propertyName(self, _propertyName)