echopoint.stylesheet
Class SmartStyle

java.lang.Object
  extended by nextapp.echo.Style
      extended by echopoint.stylesheet.SmartStyle
All Implemented Interfaces:
java.io.Serializable

public class SmartStyle
extends Style

The SmartStyle class is a Style that knows which style attributes have been accessed when the applyStyle() method is called and can then use reflection to set any unaccessed style attributes into a Component.

All contained style attributes are marked as NOT accessed until such time as they are accessed via one of the getter methods. This is most likely done in the Component.applyStyle() method.

Any unaccessed style attributes can then be applied to the Component via bean introspection and reflection. This will look to see that the Component has a setter method of the right name (the style attribute name) and right type (the style attribute value type). If so then a reflection will will be performed to set the style attribute.

See Also:
Serialized Form

Constructor Summary
SmartStyle()
          Creates a new SmartStyle object.
 
Method Summary
 java.lang.Object getAttribute(java.lang.String key)
          Returns the attribute associate with the given key as an object.
 boolean getBooleanAttribute(java.lang.String key)
          Returns the attribute associated with the given key as a primitive boolean value.
 int getIntegerAttribute(java.lang.String key)
          Returns the attribute associated with the given key as a primitive integer value.
 java.lang.String getStringAttribute(java.lang.String key)
          Returns the attribute associated with the given key as a string.
 java.lang.String[] getUnAccessedAttributes()
          Returns an array of all style attribute names that have not ben accessed.
 void setAttribute(java.lang.String key, boolean value)
          Sets an attribute.
 void setAttribute(java.lang.String key, int value)
          Sets an attribute.
 void setAttribute(java.lang.String key, java.lang.Object value)
          Sets an attribute.
 void setUnAccessedAttributes(Component c)
          Will perform "relection set" on a Component for any attributes that have not be accessed for this style.
 
Methods inherited from class nextapp.echo.Style
getAttributesMap, hasAttribute, isImmutable, setImmutable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SmartStyle

public SmartStyle()
Creates a new SmartStyle object.

Method Detail

getAttribute

public java.lang.Object getAttribute(java.lang.String key)
Description copied from class: Style
Returns the attribute associate with the given key as an object.

Overrides:
getAttribute in class Style
Parameters:
key - The name of the attribute to return.
Returns:
The value of the attribute.
See Also:
Style.getAttribute(java.lang.String)

getBooleanAttribute

public boolean getBooleanAttribute(java.lang.String key)
Description copied from class: Style
Returns the attribute associated with the given key as a primitive boolean value. The key must map to a Boolean object for this method to execute successfully.

Overrides:
getBooleanAttribute in class Style
Parameters:
key - The name of the attribute to return.
Returns:
The value of the attribute.
See Also:
Style.getBooleanAttribute(java.lang.String)

getIntegerAttribute

public int getIntegerAttribute(java.lang.String key)
Description copied from class: Style
Returns the attribute associated with the given key as a primitive integer value. The key must map to a Integer object for this method to execute successfully.

Overrides:
getIntegerAttribute in class Style
Parameters:
key - The name of the attribute to return.
Returns:
The value of the attribute.
See Also:
Style.getIntegerAttribute(java.lang.String)

getStringAttribute

public java.lang.String getStringAttribute(java.lang.String key)
Description copied from class: Style
Returns the attribute associated with the given key as a string. This method is identical to getAttribute() with the exception that it casts the attribute to a String. If the key maps to an object other than a String, a ClassCastException will be thrown.

Overrides:
getStringAttribute in class Style
Parameters:
key - The name of the attribute to return.
Returns:
The value of the attribute.
See Also:
Style.getStringAttribute(java.lang.String)

setAttribute

public void setAttribute(java.lang.String key,
                         boolean value)
Description copied from class: Style
Sets an attribute. If the attribute already exists, it will be overwritten. The attribute will be stored as a Boolean object.

Overrides:
setAttribute in class Style
Parameters:
key - The key to be set.
value - The new value of the key.
See Also:
Style.setAttribute(java.lang.String, boolean)

setAttribute

public void setAttribute(java.lang.String key,
                         int value)
Description copied from class: Style
Sets an attribute. If the attribute already exists, it will be overwritten. The attribute will be stored as an Integer object.

Overrides:
setAttribute in class Style
Parameters:
key - The key to be set.
value - The new value of the key.
See Also:
Style.setAttribute(java.lang.String, int)

setAttribute

public void setAttribute(java.lang.String key,
                         java.lang.Object value)
Description copied from class: Style
Sets an attribute. If the attribute already exists, it will be overwritten.

Overrides:
setAttribute in class Style
Parameters:
key - The key to be set.
value - The new value of the key.
See Also:
Style.setAttribute(java.lang.String, java.lang.Object)

getUnAccessedAttributes

public java.lang.String[] getUnAccessedAttributes()
Returns an array of all style attribute names that have not ben accessed.

Returns:
String[] - an array of style attribute names.

setUnAccessedAttributes

public void setUnAccessedAttributes(Component c)
Will perform "relection set" on a Component for any attributes that have not be accessed for this style. This is designed to be called after the Component.applyStyle() method has been called.

Once this call completes, all style attributes that have been succesffuly set will be marked as accessed.

Parameters:
c - - the Component to perform reflection on