echopointng.stylesheet.propertypeer
Class AbstractCssPropertyPeer

java.lang.Object
  extended by echopointng.stylesheet.propertypeer.AbstractCssPropertyPeer
All Implemented Interfaces:
CssPropertyPeer
Direct Known Subclasses:
AlignmentPeer, BooleanPeer, BorderPeer, CharacterPeer, ColorPeer, ExtentPeer, FillImagePeer, FontPeer, ImageReferencePeer, InsetsPeer, LocalePeer, NumberPeer, StringPeer, TypefacePeer

public abstract class AbstractCssPropertyPeer
extends java.lang.Object
implements CssPropertyPeer

AbstractCssPropertyPeer is a base class for PropertyPeers


Constructor Summary
AbstractCssPropertyPeer()
           
 
Method Summary
protected abstract  boolean canConvert(CssObjectIntrospector ci, java.lang.String propertyValue)
          Is the propertyValue valid in its current form?
protected static java.lang.String getConstantFromMap(java.util.Map constantMap, int intValue)
           
protected static java.lang.String getConstantFromMap(java.util.Map constantMap, java.lang.Object equalsTo)
          Looks into a Map of constant values to object values and returns the key that matches the given object value
protected  java.lang.Object getConstantValue(CssObjectIntrospector ci, java.lang.Class conversionClass, java.lang.String propertyValue, int lineNo)
          Converts a property string value into a name class field constant of the supplied name.
protected abstract  java.lang.Class getConversionClass()
          What is an assignable conversion class for this peer
protected static int getInteger(java.lang.String propertyValue)
          Returns the int value of the given propertyValue string.
protected static int getIntFromMap(java.util.Map constantMap, java.lang.Object key)
          Can be called to return an int from a Map of Integer objects.
 java.lang.Object getJavaObject(java.lang.ClassLoader classLoader, java.lang.Class objectClass, java.lang.String propertyValue, int lineNo)
          This method is called to convert the CSS string value into a specific Java object.
protected abstract  java.lang.Object getObject(CssObjectIntrospector ci, java.lang.String propertyValue)
          Returns an instance of the converted property value.
protected static CssPropertyPeer getPeer(java.lang.Class peerClass)
           
protected  java.lang.String getString(CssObjectIntrospector ci, java.lang.Object object)
          Get a string representation of the object.
 java.lang.String getStyleString(java.lang.ClassLoader classLoader, java.lang.Class objectClass, java.lang.Object propertyValue)
          This is called to convert a current Java object into a CSS property value string.
protected static boolean isAssignableFrom(java.lang.Object value, java.lang.Class targetClass)
          Returns true if value Object is assignable to the target class.
protected static boolean isExtent(java.lang.String extentStr)
          Returns true of the specified string is an extent string
protected static boolean isInteger(java.lang.String propertyValue)
          Returns true if the propertyValue is a valid representation of a base 10 Integer value.
protected static boolean isNullString(java.lang.String propertyValue)
          Returns TRUE if the propertyValue is the null string
protected static Extent makeExtent(java.lang.String extentStr)
          Makes an Extent from a string
protected static java.lang.String[] tokenize(java.lang.String tokenStr, java.lang.String delims)
          Tokenizes a given string with the specified delimeters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractCssPropertyPeer

public AbstractCssPropertyPeer()
Method Detail

getJavaObject

public java.lang.Object getJavaObject(java.lang.ClassLoader classLoader,
                                      java.lang.Class objectClass,
                                      java.lang.String propertyValue,
                                      int lineNo)
                               throws CssInvalidValueException
Description copied from interface: CssPropertyPeer
This method is called to convert the CSS string value into a specific Java object.

Specified by:
getJavaObject in interface CssPropertyPeer
Parameters:
classLoader - - the class loader in use
objectClass - - the current object class in question
propertyValue - - the CSS value string
lineNo - - the line no within the parsed CSS input
Returns:
a specific Object of the correct type
Throws:
CssInvalidValueException - - if the value cannot be converted.
See Also:
CssPropertyPeer.getJavaObject(ClassLoader, Class, String, int)

getStyleString

public java.lang.String getStyleString(java.lang.ClassLoader classLoader,
                                       java.lang.Class objectClass,
                                       java.lang.Object propertyValue)
Description copied from interface: CssPropertyPeer
This is called to convert a current Java object into a CSS property value string.

Specified by:
getStyleString in interface CssPropertyPeer
Parameters:
classLoader - - the class loader in use
objectClass - - the current object class in question
propertyValue - - the CSS value string
Returns:
a string in the right Css property value string format
See Also:
getStyleString(java.lang.ClassLoader, java.lang.Class, java.lang.Object)

getConversionClass

protected abstract java.lang.Class getConversionClass()
What is an assignable conversion class for this peer

Returns:
- a conversion class

canConvert

protected abstract boolean canConvert(CssObjectIntrospector ci,
                                      java.lang.String propertyValue)
Is the propertyValue valid in its current form?

Parameters:
ci - - The component Intropector
propertyValue - - the value to inspect
Returns:
true if its a valid, convertable value

getObject

protected abstract java.lang.Object getObject(CssObjectIntrospector ci,
                                              java.lang.String propertyValue)
Returns an instance of the converted property value. canConvert() will have been called before this is called and hence no sanity checks need be performed again.

Parameters:
ci - - a object intropector for you to use
propertyValue - - the value to convert into an object
Returns:
the converted value

getString

protected java.lang.String getString(CssObjectIntrospector ci,
                                     java.lang.Object object)
Get a string representation of the object. This default implementation returns String.valueOf(object) or "null";

Parameters:
ci - - the CssObjectIntrospector available
object - - the object to get a string representation of.
Returns:
- the string representation

getConstantValue

protected java.lang.Object getConstantValue(CssObjectIntrospector ci,
                                            java.lang.Class conversionClass,
                                            java.lang.String propertyValue,
                                            int lineNo)
                                     throws CssInvalidValueException
Converts a property string value into a name class field constant of the supplied name.

Parameters:
ci - - the componen
conversionClass -
propertyValue -
lineNo -
Returns:
a string contant into a value
Throws:
CssInvalidValueException

isAssignableFrom

protected static boolean isAssignableFrom(java.lang.Object value,
                                          java.lang.Class targetClass)
Returns true if value Object is assignable to the target class. If the value is null, then it is always assignable.

Parameters:
value - - the object to test
targetClass - - the target assignable class
Returns:
true if its assignable or false

isNullString

protected static boolean isNullString(java.lang.String propertyValue)
Returns TRUE if the propertyValue is the null string


isInteger

protected static boolean isInteger(java.lang.String propertyValue)
Returns true if the propertyValue is a valid representation of a base 10 Integer value.


getInteger

protected static int getInteger(java.lang.String propertyValue)
Returns the int value of the given propertyValue string. The IsInteger method should be called to check the value beforehand.


getConstantFromMap

protected static java.lang.String getConstantFromMap(java.util.Map constantMap,
                                                     java.lang.Object equalsTo)
Looks into a Map of constant values to object values and returns the key that matches the given object value

Parameters:
constantMap - - the Map is assumed to have String keys
equalsTo - - the object to perform .equals() on
Returns:
the key or a String.valueOf(equalsTo)

getConstantFromMap

protected static java.lang.String getConstantFromMap(java.util.Map constantMap,
                                                     int intValue)
See Also:
getConstantFromMap(Map, Object)

getIntFromMap

protected static int getIntFromMap(java.util.Map constantMap,
                                   java.lang.Object key)
Can be called to return an int from a Map of Integer objects. You will want to be pretty sure the key is in there or BANG!

Parameters:
constantMap - - the Map to look in
key - - the lookup key
Returns:
and int for that key

tokenize

protected static java.lang.String[] tokenize(java.lang.String tokenStr,
                                             java.lang.String delims)
Tokenizes a given string with the specified delimeters.

Parameters:
tokenStr - - the string to tokenize
delims - - the delimeters to use
Returns:
an array of string tokens

isExtent

protected static boolean isExtent(java.lang.String extentStr)
Returns true of the specified string is an extent string


makeExtent

protected static Extent makeExtent(java.lang.String extentStr)
Makes an Extent from a string


getPeer

protected static CssPropertyPeer getPeer(java.lang.Class peerClass)