nextapp.echo
Class Style

java.lang.Object
  extended by nextapp.echo.Style
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
SmartStyle

public class Style
extends java.lang.Object
implements java.io.Serializable

A representation of stylistic properties that may be applied to Components.

See Also:
Serialized Form

Constructor Summary
Style()
          Creates a new style object.
 
Method Summary
 java.lang.Object getAttribute(java.lang.String key)
          Returns the attribute associate with the given key as an object.
 java.util.Map getAttributesMap()
           
 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.
 boolean hasAttribute(java.lang.String key)
          Returns true if the specified key is associated with an attribute.
 boolean isImmutable()
          Returns true if this object has been made immutable.
 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 setImmutable()
          Sets this Style to be immutable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Style

public Style()
Creates a new style object.

Method Detail

getAttribute

public java.lang.Object getAttribute(java.lang.String key)
Returns the attribute associate with the given key as an object.

Parameters:
key - The name of the attribute to return.
Returns:
The value of the attribute.

getBooleanAttribute

public boolean getBooleanAttribute(java.lang.String key)
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.

Parameters:
key - The name of the attribute to return.
Returns:
The value of the attribute.
Throws:
NullPointerException - if the key is not present.
ClassCastException - if the attribute value is not a Boolean object.

getIntegerAttribute

public int getIntegerAttribute(java.lang.String key)
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.

Parameters:
key - The name of the attribute to return.
Returns:
The value of the attribute.
Throws:
NullPointerException - if the key is not present.
ClassCastException - if the attribute value is not an Integer object.

getStringAttribute

public java.lang.String getStringAttribute(java.lang.String key)
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.

Parameters:
key - The name of the attribute to return.
Returns:
The value of the attribute.
Throws:
ClassCastException - if the attribute value is not a String.

hasAttribute

public boolean hasAttribute(java.lang.String key)
Returns true if the specified key is associated with an attribute.

Parameters:
key - The key to analyze.
Returns:
True if the key maps to an attribute.

isImmutable

public boolean isImmutable()
Returns true if this object has been made immutable.

Returns:
True if this object has been made immutable.

setAttribute

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

Parameters:
key - The key to be set.
value - The new value of the key.
Throws:
java.lang.IllegalStateException - if the style is immutable.

setAttribute

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

Parameters:
key - The key to be set.
value - The new value of the key.
Throws:
java.lang.IllegalStateException - if the style is immutable.

setAttribute

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

Parameters:
key - The key to be set.
value - The new value of the key.
Throws:
java.lang.IllegalStateException - if the style is immutable.

setImmutable

public void setImmutable()
Sets this Style to be immutable. Any future attempts to set attributes will throw IllegalStateExceptions.


getAttributesMap

public java.util.Map getAttributesMap()