javax.swing.text.html
Class StyleSheet.ResolvedStyle

java.lang.Object
  extended byjavax.swing.text.html.MuxingAttributeSet
      extended byjavax.swing.text.html.StyleSheet.ResolvedStyle
All Implemented Interfaces:
AttributeSet, MutableAttributeSet, Serializable, Style
Enclosing class:
StyleSheet

static class StyleSheet.ResolvedStyle
extends MuxingAttributeSet
implements Serializable, Style

A subclass of MuxingAttributeSet that implements Style. Currently the MutableAttributeSet methods are unimplemented, that is they do nothing.


Nested Class Summary
 
Nested classes inherited from class javax.swing.text.AttributeSet
AttributeSet.CharacterAttribute, AttributeSet.ColorAttribute, AttributeSet.FontAttribute, AttributeSet.ParagraphAttribute
 
Field Summary
private  int extendedIndex
          Start index of styles coming from other StyleSheets.
(package private)  String name
          The name of the Style, which is the selector.
 
Fields inherited from interface javax.swing.text.AttributeSet
NameAttribute, ResolveAttribute
 
Constructor Summary
(package private) StyleSheet.ResolvedStyle(String name, AttributeSet[] attrs, int extendedIndex)
           
 
Method Summary
 void addAttribute(Object name, Object value)
          Creates a new attribute set similar to this one except that it contains an attribute with the given name and value.
 void addAttributes(AttributeSet attributes)
          Creates a new attribute set similar to this one except that it contains the given attributes and values.
 void addChangeListener(ChangeListener l)
          Adds a listener to track whenever an attribute has been changed.
(package private)  void addExtendedStyle(Style attr)
          Adds s as one of the AttributeSets to look up attributes in.
(package private)  int boundedIndexOf(String string, char search, int start, int end)
          Similiar to String.indexOf, but allows an upper bound (this is slower in that it will still check string starting at start.
 boolean containsAttribute(Object name, Object value)
          Checks whether a given attribute name/value is defined.
 boolean containsAttributes(AttributeSet attrs)
          Checks whether the attribute set contains all of the given attributes.
 AttributeSet copyAttributes()
          Copies a set of attributes.
 Object getAttribute(Object key)
          Gets the value of an attribute.
 int getAttributeCount()
          Gets the number of attributes that are defined.
 Enumeration getAttributeNames()
          Gets the names of all attributes.
protected  AttributeSet[] getAttributes()
          Returns the AttributeSets multiplexing too.
 ChangeListener[] getChangeListeners()
           
 String getName()
          Fetches the name of the style.
 AttributeSet getResolveParent()
          Returns null, subclasses may wish to do something more intelligent with this.
protected  void insertAttributeSetAt(AttributeSet as, int index)
          Inserts as at index.
(package private)  void insertExtendedStyleAt(Style attr, int index)
          Adds s as one of the Attributesets to look up attributes in.
(package private)  void insertStyle(Style style, int specificity)
          Inserts a Style into the receiver so that the styles the receiver represents are still ordered by specificity.
 boolean isDefined(Object key)
          Checks whether a given attribute is defined.
 boolean isEqual(AttributeSet attr)
          Checks whether two attribute sets are equal.
protected  boolean matches(String selector)
          Returns true if the receiver matches selector, where a match is defined by the CSS rule matching.
(package private)  boolean matches(String selector, int sCurrent, int sLast, int thisCurrent, int thisLast)
          Returns true if the substring of the receiver, in the range thisCurrent, thisLast matches the substring of selector in the ranme sCurrent to sLast based on CSS selector matching.
 void removeAttribute(Object name)
          Removes an attribute with the given name.
 void removeAttributes(AttributeSet attributes)
          Removes a set of attributes with the given name.
 void removeAttributes(Enumeration names)
          Removes an attribute set with the given names.
protected  void removeAttributeSetAt(int index)
          Removes the AttributeSet at index.
 void removeChangeListener(ChangeListener l)
          Removes a listener that was tracking attribute changes.
(package private)  void removeExtendedStyleAt(int index)
          Removes the style at index + extendedIndex.
(package private)  void removeStyle(Style style)
          Removes a previously added style.
protected  void setAttributes(AttributeSet[] attrs)
          Directly sets the AttributeSets that comprise this MuxingAttributeSet.
 void setResolveParent(AttributeSet parent)
          Sets the resolving parent.
 
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
 

Field Detail

name

String name
The name of the Style, which is the selector. This will NEVER change!


extendedIndex

private int extendedIndex
Start index of styles coming from other StyleSheets.

Constructor Detail

StyleSheet.ResolvedStyle

StyleSheet.ResolvedStyle(String name,
                         AttributeSet[] attrs,
                         int extendedIndex)
Method Detail

insertStyle

void insertStyle(Style style,
                 int specificity)
Inserts a Style into the receiver so that the styles the receiver represents are still ordered by specificity. style will be added before any extended styles, that is before extendedIndex.


removeStyle

void removeStyle(Style style)
Removes a previously added style. This will do nothing if style is not referenced by the receiver.


insertExtendedStyleAt

void insertExtendedStyleAt(Style attr,
                           int index)
Adds s as one of the Attributesets to look up attributes in.


addExtendedStyle

void addExtendedStyle(Style attr)
Adds s as one of the AttributeSets to look up attributes in. It will be the AttributeSet last checked.


removeExtendedStyleAt

void removeExtendedStyleAt(int index)
Removes the style at index + extendedIndex.


matches

protected boolean matches(String selector)
Returns true if the receiver matches selector, where a match is defined by the CSS rule matching. Each simple selector must be separated by a single space.


matches

boolean matches(String selector,
                int sCurrent,
                int sLast,
                int thisCurrent,
                int thisLast)
Returns true if the substring of the receiver, in the range thisCurrent, thisLast matches the substring of selector in the ranme sCurrent to sLast based on CSS selector matching.


boundedIndexOf

int boundedIndexOf(String string,
                   char search,
                   int start,
                   int end)
Similiar to String.indexOf, but allows an upper bound (this is slower in that it will still check string starting at start.


addAttribute

public void addAttribute(Object name,
                         Object value)
Description copied from interface: MutableAttributeSet
Creates a new attribute set similar to this one except that it contains an attribute with the given name and value. The object must be immutable, or not mutated by any client.

Specified by:
addAttribute in interface MutableAttributeSet
Parameters:
name - the name
value - the value

addAttributes

public void addAttributes(AttributeSet attributes)
Description copied from interface: MutableAttributeSet
Creates a new attribute set similar to this one except that it contains the given attributes and values.

Specified by:
addAttributes in interface MutableAttributeSet
Parameters:
attributes - the set of attributes

removeAttribute

public void removeAttribute(Object name)
Description copied from interface: MutableAttributeSet
Removes an attribute with the given name.

Specified by:
removeAttribute in interface MutableAttributeSet
Parameters:
name - the attribute name

removeAttributes

public void removeAttributes(Enumeration names)
Description copied from interface: MutableAttributeSet
Removes an attribute set with the given names.

Specified by:
removeAttributes in interface MutableAttributeSet
Parameters:
names - the set of names

removeAttributes

public void removeAttributes(AttributeSet attributes)
Description copied from interface: MutableAttributeSet
Removes a set of attributes with the given name.

Specified by:
removeAttributes in interface MutableAttributeSet
Parameters:
attributes - the set of attributes

setResolveParent

public void setResolveParent(AttributeSet parent)
Description copied from interface: MutableAttributeSet
Sets the resolving parent. This is the set of attributes to resolve through if an attribute isn't defined locally.

Specified by:
setResolveParent in interface MutableAttributeSet
Parameters:
parent - the parent

getName

public String getName()
Description copied from interface: Style
Fetches the name of the style. A style is not required to be named, so null is returned if there is no name associated with the style.

Specified by:
getName in interface Style
Returns:
the name

addChangeListener

public void addChangeListener(ChangeListener l)
Description copied from interface: Style
Adds a listener to track whenever an attribute has been changed.

Specified by:
addChangeListener in interface Style
Parameters:
l - the change listener

removeChangeListener

public void removeChangeListener(ChangeListener l)
Description copied from interface: Style
Removes a listener that was tracking attribute changes.

Specified by:
removeChangeListener in interface Style
Parameters:
l - the change listener

getChangeListeners

public ChangeListener[] getChangeListeners()

setAttributes

protected void setAttributes(AttributeSet[] attrs)
Directly sets the AttributeSets that comprise this MuxingAttributeSet.


getAttributes

protected AttributeSet[] getAttributes()
Returns the AttributeSets multiplexing too. When the AttributeSets need to be referenced, this should be called.


insertAttributeSetAt

protected void insertAttributeSetAt(AttributeSet as,
                                    int index)
Inserts as at index. This assumes the value of index is between 0 and attrs.length, inclusive.


removeAttributeSetAt

protected void removeAttributeSetAt(int index)
Removes the AttributeSet at index. This assumes the value of index is greater than or equal to 0, and less than attrs.length.


getAttributeCount

public int getAttributeCount()
Gets the number of attributes that are defined.

Specified by:
getAttributeCount in interface AttributeSet
Returns:
the number of attributes
See Also:
AttributeSet.getAttributeCount()

isDefined

public boolean isDefined(Object key)
Checks whether a given attribute is defined. This will convert the key over to CSS if the key is a StyleConstants key that has a CSS mapping.

Specified by:
isDefined in interface AttributeSet
Parameters:
key - the attribute key
Returns:
true if the attribute is defined
See Also:
AttributeSet.isDefined(java.lang.Object)

isEqual

public boolean isEqual(AttributeSet attr)
Checks whether two attribute sets are equal.

Specified by:
isEqual in interface AttributeSet
Parameters:
attr - the attribute set to check against
Returns:
true if the same
See Also:
AttributeSet.isEqual(javax.swing.text.AttributeSet)

copyAttributes

public AttributeSet copyAttributes()
Copies a set of attributes.

Specified by:
copyAttributes in interface AttributeSet
Returns:
the copy
See Also:
AttributeSet.copyAttributes()

getAttribute

public Object getAttribute(Object key)
Gets the value of an attribute. If the requested attribute is a StyleConstants attribute that has a CSS mapping, the request will be converted.

Specified by:
getAttribute in interface AttributeSet
Parameters:
key - the attribute name
Returns:
the attribute value
See Also:
AttributeSet.getAttribute(java.lang.Object)

getAttributeNames

public Enumeration getAttributeNames()
Gets the names of all attributes.

Specified by:
getAttributeNames in interface AttributeSet
Returns:
the attribute names
See Also:
AttributeSet.getAttributeNames()

containsAttribute

public boolean containsAttribute(Object name,
                                 Object value)
Checks whether a given attribute name/value is defined.

Specified by:
containsAttribute in interface AttributeSet
Parameters:
name - the attribute name
value - the attribute value
Returns:
true if the name/value is defined
See Also:
AttributeSet.containsAttribute(java.lang.Object, java.lang.Object)

containsAttributes

public boolean containsAttributes(AttributeSet attrs)
Checks whether the attribute set contains all of the given attributes.

Specified by:
containsAttributes in interface AttributeSet
Parameters:
attrs - the attributes to check
Returns:
true if the element contains all the attributes
See Also:
AttributeSet.containsAttributes(javax.swing.text.AttributeSet)

getResolveParent

public AttributeSet getResolveParent()
Returns null, subclasses may wish to do something more intelligent with this.

Specified by:
getResolveParent in interface AttributeSet
Returns:
the parent