javax.swing.text.html
Class MultiStyle

java.lang.Object
  extended by javax.swing.text.html.MultiStyle
All Implemented Interfaces:
AttributeSet, MutableAttributeSet, Style

public class MultiStyle
extends Object
implements Style

A Style implementation that is able to multiplex between several other Styles. This is used for CSS style resolving.


Nested Class Summary
 
Nested classes/interfaces inherited from interface javax.swing.text.AttributeSet
AttributeSet.CharacterAttribute, AttributeSet.ColorAttribute, AttributeSet.FontAttribute, AttributeSet.ParagraphAttribute
 
Field Summary
 
Fields inherited from interface javax.swing.text.AttributeSet
NameAttribute, ResolveAttribute
 
Constructor Summary
MultiStyle(String n, AttributeSet[] m)
          Creates a new instance.
 
Method Summary
 void addAttribute(Object name, Object value)
          Adds an attribute with the given name and value to the set.
 void addAttributes(AttributeSet atts)
          Adds all the attributes from attributes to this set.
 void addChangeListener(ChangeListener listener)
          Adds a ChangeListener object to the style.
 boolean containsAttribute(Object name, Object value)
          Returns true if this AttributeSet contains an attribute with the specified name and value, false otherwise.
 boolean containsAttributes(AttributeSet attributes)
          Returns true of this AttributeSet contains all of the specified attributes.
 AttributeSet copyAttributes()
          Creates and returns a copy of this AttributeSet.
 Object getAttribute(Object key)
          Returns the attribute with the specified key or null if no such attribute is defined in this AttributeSet and its resolving parents.
 int getAttributeCount()
          Returns the number of attributes that are stored locally in this AttributeSet.
 Enumeration getAttributeNames()
          Returns the names of the attributes that are stored in this AttributeSet.
 String getName()
          Returns the name of the style.
 AttributeSet getResolveParent()
          Returns the resolving parent of this AttributeSet.
 boolean isDefined(Object attrName)
          Returns true if an attribute with the specified name is defined locally in this AttributeSet, without resolving through the resolving parents.
 boolean isEqual(AttributeSet attr)
          Returns true if all of the attributes in attr are equal to the attributes in this AttributeSet, false otherwise.
 void removeAttribute(Object name)
          Removes the attribute with the specified name, if this attribute is defined.
 void removeAttributes(AttributeSet atts)
          Removes attributes from this set if they are found in the given set.
 void removeAttributes(Enumeration names)
          Removes the attributes listed in names.
 void removeChangeListener(ChangeListener listener)
          Removes a ChangeListener from to the style.
 void setResolveParent(AttributeSet parent)
          Sets the reolving parent for this set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.swing.text.AttributeSet
containsAttribute, containsAttributes, copyAttributes, getAttribute, getAttributeCount, getAttributeNames, getResolveParent, isDefined, isEqual
 

Constructor Detail

MultiStyle

public MultiStyle(String n,
                  AttributeSet[] m)
Creates a new instance.

Parameters:
n - the name
m - the styles to multiplex
Method Detail

getName

public String getName()
Returns the name of the style.

Specified by:
getName in interface Style
Returns:
the name of the style

addChangeListener

public void addChangeListener(ChangeListener listener)
Description copied from interface: Style
Adds a ChangeListener object to the style.

Specified by:
addChangeListener in interface Style
Parameters:
listener - the listener object to add

removeChangeListener

public void removeChangeListener(ChangeListener listener)
Description copied from interface: Style
Removes a ChangeListener from to the style.

Specified by:
removeChangeListener in interface Style
Parameters:
listener - the listener object to remove,

addAttribute

public void addAttribute(Object name,
                         Object value)
Description copied from interface: MutableAttributeSet
Adds an attribute with the given name and value to the set. If the set already contains an attribute with the given name, the attribute value is updated.

Specified by:
addAttribute in interface MutableAttributeSet
Parameters:
name - the attribute name (null not permitted).
value - the value (null not permitted).

addAttributes

public void addAttributes(AttributeSet atts)
Description copied from interface: MutableAttributeSet
Adds all the attributes from attributes to this set.

Specified by:
addAttributes in interface MutableAttributeSet
Parameters:
atts - the set of attributes to add (null not permitted).

removeAttribute

public void removeAttribute(Object name)
Description copied from interface: MutableAttributeSet
Removes the attribute with the specified name, if this attribute is defined. This method will only remove an attribute from this set, not from the resolving parent.

Specified by:
removeAttribute in interface MutableAttributeSet
Parameters:
name - the attribute name (null not permitted).

removeAttributes

public void removeAttributes(Enumeration names)
Description copied from interface: MutableAttributeSet
Removes the attributes listed in names.

Specified by:
removeAttributes in interface MutableAttributeSet
Parameters:
names - the attribute names (null not permitted).

removeAttributes

public void removeAttributes(AttributeSet atts)
Description copied from interface: MutableAttributeSet
Removes attributes from this set if they are found in the given set. Only attributes whose key AND value are removed. Removes attributes only from this set, not from the resolving parent. Since the resolving parent is stored as an attribute, if attributes has the same resolving parent as this set, the parent will be removed from this set.

Specified by:
removeAttributes in interface MutableAttributeSet
Parameters:
atts - the attributes (null not permitted).

setResolveParent

public void setResolveParent(AttributeSet parent)
Description copied from interface: MutableAttributeSet
Sets the reolving parent for this set. When looking up an attribute, if it is not found in this set, then the resolving parent is also used for the lookup.

Specified by:
setResolveParent in interface MutableAttributeSet
Parameters:
parent - the parent attribute set (null not permitted).

containsAttribute

public boolean containsAttribute(Object name,
                                 Object value)
Description copied from interface: AttributeSet
Returns true if this AttributeSet contains an attribute with the specified name and value, false otherwise.

Specified by:
containsAttribute in interface AttributeSet
Parameters:
name - the name of the requested attribute
value - the value of the requested attribute
Returns:
true if this AttributeSet contains an attribute with the specified name and value, false otherwise

containsAttributes

public boolean containsAttributes(AttributeSet attributes)
Description copied from interface: AttributeSet
Returns true of this AttributeSet contains all of the specified attributes.

Specified by:
containsAttributes in interface AttributeSet
Parameters:
attributes - the requested attributes
Returns:
true of this AttributeSet contains all of the specified attributes

copyAttributes

public AttributeSet copyAttributes()
Description copied from interface: AttributeSet
Creates and returns a copy of this AttributeSet.

Specified by:
copyAttributes in interface AttributeSet
Returns:
a copy of this AttributeSet

getAttribute

public Object getAttribute(Object key)
Description copied from interface: AttributeSet
Returns the attribute with the specified key or null if no such attribute is defined in this AttributeSet and its resolving parents.

Specified by:
getAttribute in interface AttributeSet
Parameters:
key - the key of the attribute that is looked up
Returns:
the attribute with the specified key or null if no such attribute is defined in this AttributeSet and its resolving parents

getAttributeCount

public int getAttributeCount()
Description copied from interface: AttributeSet
Returns the number of attributes that are stored locally in this AttributeSet.

Specified by:
getAttributeCount in interface AttributeSet
Returns:
the number of attributes that are stored locally in this AttributeSet

getAttributeNames

public Enumeration getAttributeNames()
Description copied from interface: AttributeSet
Returns the names of the attributes that are stored in this AttributeSet.

Specified by:
getAttributeNames in interface AttributeSet
Returns:
the names of the attributes that are stored in this AttributeSet

getResolveParent

public AttributeSet getResolveParent()
Description copied from interface: AttributeSet
Returns the resolving parent of this AttributeSet. If a key is not stored locally, then a AttributeSet.getAttribute(Object) request is resolved up in the resolving parent of this AttributeSet.

Specified by:
getResolveParent in interface AttributeSet
Returns:
the resolving parent of this AttributeSet

isDefined

public boolean isDefined(Object attrName)
Description copied from interface: AttributeSet
Returns true if an attribute with the specified name is defined locally in this AttributeSet, without resolving through the resolving parents.

Specified by:
isDefined in interface AttributeSet
Returns:
true if an attribute with the specified name is defined locally in this AttributeSet

isEqual

public boolean isEqual(AttributeSet attr)
Description copied from interface: AttributeSet
Returns true if all of the attributes in attr are equal to the attributes in this AttributeSet, false otherwise.

Specified by:
isEqual in interface AttributeSet
Parameters:
attr - the attributes to be compared to this
Returns:
true if all of the attributes in attr are equal to the attributes in this AttributeSet, false otherwise