org.apache.batik.bridge.svg12

Class DefaultXBLManager

public class DefaultXBLManager extends Object implements XBLManager, XBLConstants

A full featured sXBL manager.
Nested Class Summary
protected classDefaultXBLManager.DefAttrListener
DOM attribute mutation listener for definition elements.
protected classDefaultXBLManager.DefinitionRecord
Record class for storing information about an XBL definition.
protected classDefaultXBLManager.DefNodeInsertedListener
DOM node inserted listener for definition elements.
protected classDefaultXBLManager.DefNodeRemovedListener
DOM node removed listener for definition elements.
protected classDefaultXBLManager.DocInsertedListener
DOM node inserted listener for the document.
protected classDefaultXBLManager.DocRemovedListener
DOM node removed listener for the document.
protected classDefaultXBLManager.DocSubtreeListener
DOM subtree mutation listener for the document.
protected classDefaultXBLManager.ImportAttrListener
DOM attribute mutation listener for import elements.
protected classDefaultXBLManager.ImportInsertedListener
DOM node inserted listener for imported XBL trees.
protected classDefaultXBLManager.ImportRecord
Record class for storing information about an XBL import.
protected classDefaultXBLManager.ImportRemovedListener
DOM node removed listener for imported XBL trees.
protected classDefaultXBLManager.ImportSubtreeListener
DOM subtree listener for imported XBL trees.
protected classDefaultXBLManager.RefAttrListener
DOM attribute mutation listener for referencing definition elements.
protected classDefaultXBLManager.TemplateMutationListener
DOM mutation listener for template elements.
protected classDefaultXBLManager.XblChildNodes
To iterate over the XBL child nodes.
protected classDefaultXBLManager.XblScopedChildNodes
To iterate over the scoped XBL child nodes.
protected classDefaultXBLManager.XBLRecord
XBL record.
Field Summary
protected EventListenerListbindingListenerList
Global event listener list for XBL binding related events.
protected MapcontentManagers
Map of shadow trees to content managers.
protected EventListenerListcontentSelectionChangedListenerList
Global event listener list for ContentSelectionChanged events.
protected BridgeContextctx
The BridgeContext.
protected DoublyIndexedTabledefinitionLists
Map of namespace URI/local name pairs to ordered sets of definition records.
protected DoublyIndexedTabledefinitions
Map of definition element/import element pairs to definition records.
protected DefaultXBLManager.DocInsertedListenerdocInsertedListener
DOM node inserted listener for the document.
protected DefaultXBLManager.DocRemovedListenerdocRemovedListener
DOM node removed listener for the document.
protected DefaultXBLManager.DocSubtreeListenerdocSubtreeListener
DOM subtree mutation listener for the document.
protected Documentdocument
The document.
protected DefaultXBLManager.ImportAttrListenerimportAttrListener
DOM attribute listener for import elements.
protected Mapimports
Map of import elements to import records.
protected booleanisProcessing
Whether XBL processing is currently taking place.
protected DefaultXBLManager.RefAttrListenerrefAttrListener
DOM attribute listener for referencing definition elements.
Constructor Summary
DefaultXBLManager(Document doc, BridgeContext ctx)
Creates a new DefaultXBLManager for the given document.
Method Summary
voidaddBindingListener(BindingListener l)
Adds the specified BindingListener to the global listener list.
voidaddContentSelectionChangedListener(ContentSelectionChangedListener l)
Adds the specified ContentSelectionChangedListener to the global listener list.
protected voidaddDefinition(String namespaceURI, String localName, XBLOMDefinitionElement def, Element imp)
Adds an xbl:definition element to the list of definitions that could possibly affect elements with the specified QName.
protected voidaddDefinitionElementListeners(XBLOMDefinitionElement def, DefaultXBLManager.ImportRecord ir)
Adds DOM mutation listeners to the given definition element.
protected voidaddDefinitionRef(Element defRef)
Adds a definition through its referring definition element (one with a 'ref' attribute).
protected voidaddImport(Element imp)
Imports bindings from another document.
protected voidaddImportedDefinitions(Element imp, Node n)
Adds the definitions in the given imported subtree.
protected voidaddTemplateElementListeners(XBLOMTemplateElement template, DefaultXBLManager.ImportRecord ir)
Adds DOM mutation listeners to the given template element.
protected voidbind(Element e)
Binds each bindable element in the given element's subtree.
protected XBLOMShadowTreeElementcloneTemplate(XBLOMTemplateElement template)
Clones a template element for use as a shadow tree.
static intcomputeBubbleLimit(Node from, Node to)
Determines the number of nodes events should bubble if the mouse pointer has moved from one element to another.
protected voiddispatchBindingChangedEvent(Element bindableElement, Element shadowTree)
Dispatches a BindingEvent the registered listeners.
protected voidfireShadowTreeEvent(BindableElement elt, String type, XBLShadowTreeElement e)
Fires a ShadowTreeEvent of the given type on this element.
protected DefaultXBLManager.DefinitionRecordgetActiveDefinition(String namespaceURI, String localName)
Returns the definition record of the active definition for namespace URI/local name pair.
ContentManagergetContentManager(Node n)
Returns the ContentManager that handles the shadow tree the given node resides in.
protected Object[]getContentSelectionChangedListeners()
Returns an array of the gloabl ContentSelectionChangedListeners.
protected DefaultXBLManager.XBLRecordgetRecord(Node n)
Returns the XBL record for the given node.
ElementgetXblBoundElement(Node n)
Get the bound element whose shadow tree a node resides in.
NodeListgetXblChildNodes(Node n)
Get the list of child nodes of a node in the fully flattened tree.
XBLOMContentElementgetXblContentElement(Node n)
Returns the content element that caused the given node to be present in the flattened tree.
NodeListgetXblDefinitions(Node n)
Get the xbl:definition elements currently binding an element.
NodegetXblFirstChild(Node n)
Get the first child node of a node in the fully flattened tree.
ElementgetXblFirstElementChild(Node n)
Get the first element child of a node in the fully flattened tree.
NodegetXblLastChild(Node n)
Get the last child node of a node in the fully flattened tree.
ElementgetXblLastElementChild(Node n)
Get the last element child of a node in the fully flattened tree.
ElementgetXblNextElementSibling(Node n)
Get the first element that follows a node in the xblParentNode's xblChildNodes list.
NodegetXblNextSibling(Node n)
Get the node which directly follows a node in the xblParentNode's xblChildNodes list.
NodegetXblParentNode(Node n)
Get the parent of a node in the fully flattened tree.
ElementgetXblPreviousElementSibling(Node n)
Get the first element that precedes the a node in the xblParentNode's xblChildNodes list.
NodegetXblPreviousSibling(Node n)
Get the node which directly precedes a node in the xblParentNode's xblChildNodes list.
NodeListgetXblScopedChildNodes(Node n)
Get the list of child nodes of a node in the fully flattened tree that are within the same shadow scope.
ElementgetXblShadowTree(Node n)
Get the shadow tree of a node.
voidinvalidateChildNodes(Node n)
Mark the xblChildNodes and xblScopedChildNodes variables as invalid.
protected booleanisActiveDefinition(XBLOMDefinitionElement def, Element imp)
Returns whether the given definition element is the active one for its element name.
booleanisProcessing()
Returns whether XBL processing is currently enabled.
protected voidrebind(String namespaceURI, String localName, Element e)
Rebinds each bindable element of the given name in the given element's subtree.
voidremoveBindingListener(BindingListener l)
Removes the specified BindingListener from the global listener list.
voidremoveContentSelectionChangedListener(ContentSelectionChangedListener l)
Removes the specified ContentSelectionChangedListener from the global listener list.
protected voidremoveDefinition(DefaultXBLManager.DefinitionRecord defRec)
Removes an xbl:definition element from the list of definitions that could possibly affect elements with the specified QName.
protected voidremoveDefinitionElementListeners(XBLOMDefinitionElement def, DefaultXBLManager.ImportRecord ir)
Removes DOM mutation listeners from the given definition element.
protected voidremoveDefinitionRef(Element defRef)
Removes a definition through its referring definition element (one with a 'ref' attribute).
protected voidremoveImport(Element imp)
Removes an import.
protected voidremoveTemplateElementListeners(XBLOMTemplateElement template, DefaultXBLManager.ImportRecord ir)
Removes DOM mutation listeners from the given template element.
protected voidsetActiveDefinition(BindableElement elt, DefaultXBLManager.DefinitionRecord defRec)
Sets the given definition as the active one for a particular bindable element.
protected voidsetXblShadowTree(BindableElement elt, XBLOMShadowTreeElement newShadow)
Sets the shadow tree for the given bindable element.
voidstartProcessing()
Starts XBL processing on the document.
voidstopProcessing()
Stops XBL processing on the document.
protected voidunbind(Element e)
Unbinds each bindable element in the given element's subtree.
protected voidupdateLinks(Node n)
Updates the xblPreviousSibling and xblNextSibling properties of the given XBL node.

Field Detail

bindingListenerList

protected EventListenerList bindingListenerList
Global event listener list for XBL binding related events.

contentManagers

protected Map contentManagers
Map of shadow trees to content managers.

contentSelectionChangedListenerList

protected EventListenerList contentSelectionChangedListenerList
Global event listener list for ContentSelectionChanged events.

ctx

protected BridgeContext ctx
The BridgeContext.

definitionLists

protected DoublyIndexedTable definitionLists
Map of namespace URI/local name pairs to ordered sets of definition records.

definitions

protected DoublyIndexedTable definitions
Map of definition element/import element pairs to definition records.

docInsertedListener

protected DefaultXBLManager.DocInsertedListener docInsertedListener
DOM node inserted listener for the document.

docRemovedListener

protected DefaultXBLManager.DocRemovedListener docRemovedListener
DOM node removed listener for the document.

docSubtreeListener

protected DefaultXBLManager.DocSubtreeListener docSubtreeListener
DOM subtree mutation listener for the document.

document

protected Document document
The document.

importAttrListener

protected DefaultXBLManager.ImportAttrListener importAttrListener
DOM attribute listener for import elements.

imports

protected Map imports
Map of import elements to import records.

isProcessing

protected boolean isProcessing
Whether XBL processing is currently taking place.

refAttrListener

protected DefaultXBLManager.RefAttrListener refAttrListener
DOM attribute listener for referencing definition elements.

Constructor Detail

DefaultXBLManager

public DefaultXBLManager(Document doc, BridgeContext ctx)
Creates a new DefaultXBLManager for the given document.

Method Detail

addBindingListener

public void addBindingListener(BindingListener l)
Adds the specified BindingListener to the global listener list.

addContentSelectionChangedListener

public void addContentSelectionChangedListener(ContentSelectionChangedListener l)
Adds the specified ContentSelectionChangedListener to the global listener list.

addDefinition

protected void addDefinition(String namespaceURI, String localName, XBLOMDefinitionElement def, Element imp)
Adds an xbl:definition element to the list of definitions that could possibly affect elements with the specified QName. This may or may not actually cause a new binding to come in to effect, as this new definition element may be added earlier in the document than another already in effect.

Parameters: namespaceURI the namespace URI of the bound elements localName the local name of the bound elements def the xbl:definition element imp the xbl:import or xbl;definition element through which this definition is being added, or null if the binding is in the original document

addDefinitionElementListeners

protected void addDefinitionElementListeners(XBLOMDefinitionElement def, DefaultXBLManager.ImportRecord ir)
Adds DOM mutation listeners to the given definition element.

addDefinitionRef

protected void addDefinitionRef(Element defRef)
Adds a definition through its referring definition element (one with a 'ref' attribute).

addImport

protected void addImport(Element imp)
Imports bindings from another document.

addImportedDefinitions

protected void addImportedDefinitions(Element imp, Node n)
Adds the definitions in the given imported subtree.

addTemplateElementListeners

protected void addTemplateElementListeners(XBLOMTemplateElement template, DefaultXBLManager.ImportRecord ir)
Adds DOM mutation listeners to the given template element.

bind

protected void bind(Element e)
Binds each bindable element in the given element's subtree.

cloneTemplate

protected XBLOMShadowTreeElement cloneTemplate(XBLOMTemplateElement template)
Clones a template element for use as a shadow tree.

computeBubbleLimit

public static int computeBubbleLimit(Node from, Node to)
Determines the number of nodes events should bubble if the mouse pointer has moved from one element to another.

Parameters: from the element from which the mouse pointer moved to the element to which the mouse pointer moved

dispatchBindingChangedEvent

protected void dispatchBindingChangedEvent(Element bindableElement, Element shadowTree)
Dispatches a BindingEvent the registered listeners.

Parameters: bindableElement the bindable element whose binding has changed shadowTree the new shadow tree of the bindable element

fireShadowTreeEvent

protected void fireShadowTreeEvent(BindableElement elt, String type, XBLShadowTreeElement e)
Fires a ShadowTreeEvent of the given type on this element.

getActiveDefinition

protected DefaultXBLManager.DefinitionRecord getActiveDefinition(String namespaceURI, String localName)
Returns the definition record of the active definition for namespace URI/local name pair.

getContentManager

public ContentManager getContentManager(Node n)
Returns the ContentManager that handles the shadow tree the given node resides in.

getContentSelectionChangedListeners

protected Object[] getContentSelectionChangedListeners()
Returns an array of the gloabl ContentSelectionChangedListeners.

getRecord

protected DefaultXBLManager.XBLRecord getRecord(Node n)
Returns the XBL record for the given node.

getXblBoundElement

public Element getXblBoundElement(Node n)
Get the bound element whose shadow tree a node resides in.

getXblChildNodes

public NodeList getXblChildNodes(Node n)
Get the list of child nodes of a node in the fully flattened tree.

getXblContentElement

public XBLOMContentElement getXblContentElement(Node n)
Returns the content element that caused the given node to be present in the flattened tree.

getXblDefinitions

public NodeList getXblDefinitions(Node n)
Get the xbl:definition elements currently binding an element.

getXblFirstChild

public Node getXblFirstChild(Node n)
Get the first child node of a node in the fully flattened tree.

getXblFirstElementChild

public Element getXblFirstElementChild(Node n)
Get the first element child of a node in the fully flattened tree.

getXblLastChild

public Node getXblLastChild(Node n)
Get the last child node of a node in the fully flattened tree.

getXblLastElementChild

public Element getXblLastElementChild(Node n)
Get the last element child of a node in the fully flattened tree.

getXblNextElementSibling

public Element getXblNextElementSibling(Node n)
Get the first element that follows a node in the xblParentNode's xblChildNodes list.

getXblNextSibling

public Node getXblNextSibling(Node n)
Get the node which directly follows a node in the xblParentNode's xblChildNodes list.

getXblParentNode

public Node getXblParentNode(Node n)
Get the parent of a node in the fully flattened tree.

getXblPreviousElementSibling

public Element getXblPreviousElementSibling(Node n)
Get the first element that precedes the a node in the xblParentNode's xblChildNodes list.

getXblPreviousSibling

public Node getXblPreviousSibling(Node n)
Get the node which directly precedes a node in the xblParentNode's xblChildNodes list.

getXblScopedChildNodes

public NodeList getXblScopedChildNodes(Node n)
Get the list of child nodes of a node in the fully flattened tree that are within the same shadow scope.

getXblShadowTree

public Element getXblShadowTree(Node n)
Get the shadow tree of a node.

invalidateChildNodes

public void invalidateChildNodes(Node n)
Mark the xblChildNodes and xblScopedChildNodes variables as invalid.

isActiveDefinition

protected boolean isActiveDefinition(XBLOMDefinitionElement def, Element imp)
Returns whether the given definition element is the active one for its element name.

isProcessing

public boolean isProcessing()
Returns whether XBL processing is currently enabled.

rebind

protected void rebind(String namespaceURI, String localName, Element e)
Rebinds each bindable element of the given name in the given element's subtree.

removeBindingListener

public void removeBindingListener(BindingListener l)
Removes the specified BindingListener from the global listener list.

removeContentSelectionChangedListener

public void removeContentSelectionChangedListener(ContentSelectionChangedListener l)
Removes the specified ContentSelectionChangedListener from the global listener list.

removeDefinition

protected void removeDefinition(DefaultXBLManager.DefinitionRecord defRec)
Removes an xbl:definition element from the list of definitions that could possibly affect elements with the specified QName. This will only cause a new binding to come in to effect if it is currently active.

removeDefinitionElementListeners

protected void removeDefinitionElementListeners(XBLOMDefinitionElement def, DefaultXBLManager.ImportRecord ir)
Removes DOM mutation listeners from the given definition element.

removeDefinitionRef

protected void removeDefinitionRef(Element defRef)
Removes a definition through its referring definition element (one with a 'ref' attribute).

removeImport

protected void removeImport(Element imp)
Removes an import.

removeTemplateElementListeners

protected void removeTemplateElementListeners(XBLOMTemplateElement template, DefaultXBLManager.ImportRecord ir)
Removes DOM mutation listeners from the given template element.

setActiveDefinition

protected void setActiveDefinition(BindableElement elt, DefaultXBLManager.DefinitionRecord defRec)
Sets the given definition as the active one for a particular bindable element.

setXblShadowTree

protected void setXblShadowTree(BindableElement elt, XBLOMShadowTreeElement newShadow)
Sets the shadow tree for the given bindable element.

startProcessing

public void startProcessing()
Starts XBL processing on the document.

stopProcessing

public void stopProcessing()
Stops XBL processing on the document.

unbind

protected void unbind(Element e)
Unbinds each bindable element in the given element's subtree.

updateLinks

protected void updateLinks(Node n)
Updates the xblPreviousSibling and xblNextSibling properties of the given XBL node.
Copyright B) 2008 Apache Software Foundation. All Rights Reserved.