de.enough.polish.preprocess.css.attributes
Class WrappedCssAttribute

java.lang.Object
  extended by de.enough.polish.preprocess.css.CssAttribute
      extended by de.enough.polish.preprocess.css.attributes.WrappedCssAttribute
All Implemented Interfaces:
Comparable

public class WrappedCssAttribute
extends CssAttribute

Wraps an existing CssAttribute under a new name.

Copyright Enough Software 2007

 history
        Nov 20, 2007 - rob creation
 

Author:
Robert Virkus, j2mepolish@enough.de

Field Summary
protected  CssAttribute parent
           
 
Fields inherited from class de.enough.polish.preprocess.css.CssAttribute
allowedValues, allowsCombinations, ANIMATION_PACKAGE, appliesTo, appliesToMap, defaultValue, description, group, id, isBaseAttribute, isCaseSensitive, mappingsByName, name, requiresMapping, shell, since, type
 
Constructor Summary
WrappedCssAttribute()
          Creates an empty css attribute
WrappedCssAttribute(CssAttribute parent, org.jdom.Element definition)
           
 
Method Summary
 void add(CssAttribute extension)
          Adds the mappings of the given capability to this one.
 int compareTo(Object o)
           
 String generateAnimationSourceCode(CssAnimationSetting cssAnimation, Style style, Environment environment)
          Generates source code for creating a CssAnimation
 String[] getAllowedValues()
           
 CssMapping[] getApplicableMappings(Class targetClass)
          Retrieves the mappings that are appliable to a given class.
 String getDefaultValue()
           
 String getDescription()
           
 CssMapping getMapping(String fromName)
           
 CssMapping getMappingByTo(String toName)
          Retrieves mapping by its name.
 CssMapping[] getMappings()
          Retrieves all mappings for this attribute.
 String getValue(String value, Environment environment)
          Checks and transforms the given CSS value for this attribute.
 int getValuePosition(String value)
          Retrieves the position of the given value in list of allowed values.
 boolean hasFixValues()
           
 Object instantiateDefault(Environment environment)
          Retrieves the default value for the attribute.
 Object instantiateValue(String sourceCode)
          Instantiates the referenced value.
 boolean isDefault(String value)
          Determines whether the given value is the same as the default value of this attribute.
 Object parseAndInstantiateValue(String valueStr, Environment environment)
          Parses and instantiates a value in the attribute.
 void setDefinition(org.jdom.Element definition)
          Creates a new CSS-attribute
 
Methods inherited from class de.enough.polish.preprocess.css.CssAttribute
appliesTo, createMapping, generateAnimationSourceCode, generateAnimationSourceCodeStart, getAppliesTo, getDeprecatedMessage, getGroup, getId, getName, getShell, getSince, getType, instantiate, instantiateBoolean, instantiateByte, instantiateChar, instantiateDouble, instantiateFloat, instantiateInt, instantiateLong, instantiateShort, isBaseAttribute, isDeprecated, isHidden, isImplicit, loadClass, resolveField, setId, setImplicitDefinition, setName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parent

protected CssAttribute parent
Constructor Detail

WrappedCssAttribute

public WrappedCssAttribute()
Creates an empty css attribute


WrappedCssAttribute

public WrappedCssAttribute(CssAttribute parent,
                           org.jdom.Element definition)
Parameters:
parent -
definition -
Method Detail

add

public void add(CssAttribute extension)
Description copied from class: CssAttribute
Adds the mappings of the given capability to this one. With this feature new mappings can be added in custom-css-attributes.xml

Overrides:
add in class CssAttribute
Parameters:
extension - the attribute containing further mappings

compareTo

public int compareTo(Object o)
Specified by:
compareTo in interface Comparable
Overrides:
compareTo in class CssAttribute

getAllowedValues

public String[] getAllowedValues()
Overrides:
getAllowedValues in class CssAttribute
Returns:
Returns the allowedValues.

getApplicableMappings

public CssMapping[] getApplicableMappings(Class targetClass)
Description copied from class: CssAttribute
Retrieves the mappings that are appliable to a given class.

Overrides:
getApplicableMappings in class CssAttribute
Parameters:
targetClass - the class to return mappings for
Returns:
an array of mappings

getDefaultValue

public String getDefaultValue()
Overrides:
getDefaultValue in class CssAttribute
Returns:
Returns the defaultValue.

getDescription

public String getDescription()
Overrides:
getDescription in class CssAttribute
Returns:
Returns the description.

getMapping

public CssMapping getMapping(String fromName)
Overrides:
getMapping in class CssAttribute

getMappingByTo

public CssMapping getMappingByTo(String toName)
Description copied from class: CssAttribute
Retrieves mapping by its name.

Overrides:
getMappingByTo in class CssAttribute
Parameters:
toName - the name to which the mapping is usally converted, e.g. a class name
Returns:
the mapping

getMappings

public CssMapping[] getMappings()
Description copied from class: CssAttribute
Retrieves all mappings for this attribute.

Overrides:
getMappings in class CssAttribute
Returns:
an array of mappings

getValue

public String getValue(String value,
                       Environment environment)
Description copied from class: CssAttribute
Checks and transforms the given CSS value for this attribute.

Overrides:
getValue in class CssAttribute
Parameters:
value - the attribute value
environment - the environment
Returns:
the transformed value or the same value if no transformation is required.

getValuePosition

public int getValuePosition(String value)
Description copied from class: CssAttribute
Retrieves the position of the given value in list of allowed values.

Overrides:
getValuePosition in class CssAttribute
Parameters:
value - the value
Returns:
the position, a value between 0 and the length of allowed values. When the value is invalid, -1 will be returned
See Also:
CssAttribute.hasFixValues()

hasFixValues

public boolean hasFixValues()
Overrides:
hasFixValues in class CssAttribute
Returns:
true when this CSS attribute has a fix list of allowed values

instantiateDefault

public Object instantiateDefault(Environment environment)
Description copied from class: CssAttribute
Retrieves the default value for the attribute.

Overrides:
instantiateDefault in class CssAttribute
Parameters:
environment - the environment
Returns:
the default value

instantiateValue

public Object instantiateValue(String sourceCode)
Description copied from class: CssAttribute
Instantiates the referenced value.

Overrides:
instantiateValue in class CssAttribute
Parameters:
sourceCode - the transformed value of this attribute
Returns:
the instantiated value (value as object instead of source code)

isDefault

public boolean isDefault(String value)
Description copied from class: CssAttribute
Determines whether the given value is the same as the default value of this attribute.

Overrides:
isDefault in class CssAttribute
Parameters:
value - the value defined by the user
Returns:
true when the given value is the default-value.

parseAndInstantiateValue

public Object parseAndInstantiateValue(String valueStr,
                                       Environment environment)
Description copied from class: CssAttribute
Parses and instantiates a value in the attribute.

Overrides:
parseAndInstantiateValue in class CssAttribute
Parameters:
valueStr - the value string to parse
environment - the enviroment
Returns:
the instantiated value

setDefinition

public void setDefinition(org.jdom.Element definition)
Description copied from class: CssAttribute
Creates a new CSS-attribute

Overrides:
setDefinition in class CssAttribute
Parameters:
definition - the XML definition of this attribute.

generateAnimationSourceCode

public String generateAnimationSourceCode(CssAnimationSetting cssAnimation,
                                          Style style,
                                          Environment environment)
Description copied from class: CssAttribute
Generates source code for creating a CssAnimation

Overrides:
generateAnimationSourceCode in class CssAttribute
Parameters:
cssAnimation - the settings of the animation
style - the parent style
environment - the environment
Returns:
source code that creates the animation