javax.swing.text.html
Class AccessibleHTML.ElementInfo

java.lang.Object
  extended byjavax.swing.text.html.AccessibleHTML.ElementInfo
Direct Known Subclasses:
AccessibleHTML.IconElementInfo, AccessibleHTML.TableElementInfo, AccessibleHTML.TableElementInfo.TableCellElementInfo, AccessibleHTML.TableElementInfo.TableRowElementInfo, AccessibleHTML.TextElementInfo
Enclosing class:
AccessibleHTML

private class AccessibleHTML.ElementInfo
extends Object

ElementInfo provides a slim down view of an Element. Each ElementInfo can have any number of child ElementInfos that are not necessarily direct children of the Element. As the Document changes various ElementInfos become invalidated. Before accessing a particular portion of an ElementInfo you should make sure it is valid by invoking validateIfNecessary, this will return true if successful, on the other hand a false return value indicates the ElementInfo is not valid and can never become valid again (usually the result of the Element the ElementInfo encapsulates being removed).


Field Summary
private  boolean canBeValid
          Indicates if the ElementInfo can become valid.
private  ArrayList children
          The children of this ElementInfo.
private  Element element
          The Element this ElementInfo is providing information for.
private  boolean isValid
          Indicates the validity of the ElementInfo.
private  AccessibleHTML.ElementInfo parent
          The parent ElementInfo, will be null for the root.
 
Constructor Summary
(package private) AccessibleHTML.ElementInfo(Element element)
          Creates the root ElementInfo.
(package private) AccessibleHTML.ElementInfo(Element element, AccessibleHTML.ElementInfo parent)
          Creates an ElementInfo representing element with the specified parent.
 
Method Summary
protected  void addChild(AccessibleHTML.ElementInfo child)
          Adds a new child to this ElementInfo.
protected  AttributeSet getAttributes()
          Returns the AttributeSet associated with the Element, this will return null if the ElementInfo can't be validated.
 Rectangle getBounds()
          Returns the Bounds for this ElementInfo, or null if the ElementInfo can't be validated.
 AccessibleHTML.ElementInfo getChild(int index)
          Returns the child ElementInfo at index, or null if index isn't a valid index.
 int getChildCount()
          Returns the number of children the ElementInfo contains.
private  int getClosestInfoIndex(int index)
           
 Element getElement()
          Returns the Element this ElementInfo represents.
 int getIndexInParent()
          Returns the index of the child in the parent, or -1 for the root or if the parent isn't valid.
protected  int getIntAttr(AttributeSet attrs, Object key, int deflt)
          Convenience method for getting an integer attribute from the passed in AttributeSet.
 AccessibleHTML.ElementInfo getParent()
          Returns the parent of this Element, or null for the root.
protected  View getView()
          Returns the View corresponding to this ElementInfo, or null if the ElementInfo can't be validated.
private  View getView(View parent, Element e, int start)
           
protected  AttributeSet getViewAttributes()
          Returns the AttributeSet associated with the View that is representing this Element, this will return null if the ElementInfo can't be validated.
 int indexOf(AccessibleHTML.ElementInfo child)
          Returns the index of the specified child, or -1 if child isn't a valid child.
protected  void invalidate(boolean first)
          Invalidates the ElementInfo.
protected  boolean isValid()
          Returns true if this ElementInfo is valid.
protected  void loadChildren(Element parent)
          Recreates the direct children of info.
private  void update(DocumentEvent e)
           
protected  void validate()
          Validates the receiver.
protected  boolean validateIfNecessary()
          Validates the ElementInfo if necessary.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

children

private ArrayList children
The children of this ElementInfo.


element

private Element element
The Element this ElementInfo is providing information for.


parent

private AccessibleHTML.ElementInfo parent
The parent ElementInfo, will be null for the root.


isValid

private boolean isValid
Indicates the validity of the ElementInfo.


canBeValid

private boolean canBeValid
Indicates if the ElementInfo can become valid.

Constructor Detail

AccessibleHTML.ElementInfo

AccessibleHTML.ElementInfo(Element element)
Creates the root ElementInfo.


AccessibleHTML.ElementInfo

AccessibleHTML.ElementInfo(Element element,
                           AccessibleHTML.ElementInfo parent)
Creates an ElementInfo representing element with the specified parent.

Method Detail

validate

protected void validate()
Validates the receiver. This recreates the children as well. This will be invoked within a readLock. If this is overriden it MUST invoke supers implementation first!


loadChildren

protected void loadChildren(Element parent)
Recreates the direct children of info.


getIndexInParent

public int getIndexInParent()
Returns the index of the child in the parent, or -1 for the root or if the parent isn't valid.


getElement

public Element getElement()
Returns the Element this ElementInfo represents.


getParent

public AccessibleHTML.ElementInfo getParent()
Returns the parent of this Element, or null for the root.


indexOf

public int indexOf(AccessibleHTML.ElementInfo child)
Returns the index of the specified child, or -1 if child isn't a valid child.


getChild

public AccessibleHTML.ElementInfo getChild(int index)
Returns the child ElementInfo at index, or null if index isn't a valid index.


getChildCount

public int getChildCount()
Returns the number of children the ElementInfo contains.


addChild

protected void addChild(AccessibleHTML.ElementInfo child)
Adds a new child to this ElementInfo.


getView

protected View getView()
Returns the View corresponding to this ElementInfo, or null if the ElementInfo can't be validated.


getBounds

public Rectangle getBounds()
Returns the Bounds for this ElementInfo, or null if the ElementInfo can't be validated.


isValid

protected boolean isValid()
Returns true if this ElementInfo is valid.


getAttributes

protected AttributeSet getAttributes()
Returns the AttributeSet associated with the Element, this will return null if the ElementInfo can't be validated.


getViewAttributes

protected AttributeSet getViewAttributes()
Returns the AttributeSet associated with the View that is representing this Element, this will return null if the ElementInfo can't be validated.


getIntAttr

protected int getIntAttr(AttributeSet attrs,
                         Object key,
                         int deflt)
Convenience method for getting an integer attribute from the passed in AttributeSet.


validateIfNecessary

protected boolean validateIfNecessary()
Validates the ElementInfo if necessary. Some ElementInfos may never be valid again. You should check isValid before using one. This will reload the children and invoke validate if the ElementInfo is invalid and can become valid again. This will return true if the receiver is valid.


invalidate

protected void invalidate(boolean first)
Invalidates the ElementInfo. Subclasses should override this if they need to reset state once invalid.


getView

private View getView(View parent,
                     Element e,
                     int start)

getClosestInfoIndex

private int getClosestInfoIndex(int index)

update

private void update(DocumentEvent e)