Top Description Inners Fields Constructors Methods
com.sun.xml.xsom.impl.util

public Class SchemaTreeTraverser

extends Object
implements XSVisitor, XSSimpleTypeVisitor
Class Inheritance
All Implemented Interfaces
com.sun.xml.xsom.visitor.XSSimpleTypeVisitor, com.sun.xml.xsom.visitor.XSVisitor, com.sun.xml.xsom.visitor.XSContentTypeVisitor, com.sun.xml.xsom.visitor.XSTermVisitor
Annotations
@SuppressWarnings:exports
Imports
com.sun.xml.xsom.XSAnnotation, .XSAttGroupDecl, .XSAttributeDecl, .XSAttributeUse, .XSComplexType, .XSContentType, .XSElementDecl, .XSFacet, .XSIdentityConstraint, .XSListSimpleType, .XSModelGroup, .XSModelGroupDecl, .XSNotation, .XSParticle, .XSRestrictionSimpleType, .XSSchema, .XSSchemaSet, .XSSimpleType, .XSType, .XSUnionSimpleType, .XSWildcard, .XSXPath, com.sun.xml.xsom.impl.Const, com.sun.xml.xsom.visitor.XSSimpleTypeVisitor, .XSTermVisitor, .XSVisitor, org.xml.sax.Locator, javax.swing.Box, .Icon, .JLabel, .JPanel, .JTree, javax.swing.tree.DefaultMutableTreeNode, .DefaultTreeModel, .TreeCellRenderer, java.awt.Color, .Component, .FlowLayout, .Font, .Graphics, java.math.BigInteger, java.text.MessageFormat, java.util.Iterator

Generates approximated tree model for XML from a schema component. This is not intended to be a fully-fledged round-trippable tree model.

Usage of this class

  1. Create a new instance.
  2. Call visit(XSSchemaSet) function on your schema set.
  3. Retrieve the model using getModel().
Every node in the resulting tree is a SchemaTreeTraverser.SchemaTreeNode, and the model itself is SchemaTreeTraverser.SchemaTreeModel. You can use SchemaTreeTraverser.SchemaTreeCellRenderer as a cell renderer for your tree.
Author
Kirill Grouchnikov ([email protected])

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
SchemaTreeTraverser.SchemaRootNode

The root node of the schema hierarchy tree.

public static class
SchemaTreeTraverser.SchemaTreeCellRenderer

Sample cell renderer for the schema tree.

public static class
SchemaTreeTraverser.SchemaTreeModel

Tree model for schema hierarchy tree.

public static class
SchemaTreeTraverser.SchemaTreeNode

The node of the schema hierarchy tree.

Field Summary

Modifier and TypeField and Description
private SchemaTreeTraverser.SchemaTreeNode
currNode

The current node in the tree.

private SchemaTreeTraverser.SchemaTreeModel
model

The associated tree model.

Constructor Summary

AccessConstructor and Description
public
SchemaTreeTraverser()

Simple constructor.

Method Summary

Modifier and TypeMethod and Description
public void
public void
public void
public void
public void
private void
dump(XSAttributeDecl
Attribute declaration.
decl
,
String
Additional attributes.
additionalAtts
)

Creates node for attribute declaration with additional attributes.

private void
dumpComplexTypeAttribute(XSComplexType
Complex type.
type
)

Creates node for complex type.

public void
dumpRef(XSAttGroupDecl
Attribute group decalration reference.
decl
)

Creates node of attribute group decalration reference.

public void
private void
elementDecl(XSElementDecl
Element declaration.
decl
,
String
Additional attributes.
extraAtts
)

Creates node for element declaration with additional attributes.

public void
public void
public SchemaTreeTraverser.SchemaTreeModel

Returns:

Tree model of this traverser.
getModel
()

Retrieves the tree model of this traverser.

public void
public void
public void
private void
modelGroup(XSModelGroup
Model group.
group
,
String
Additional attributes.
extraAtts
)

Creates node for model group with additional attributes.

public void
public void
public void
public void
public void
public void
public void
public void
visit(XSSchemaSet
Root schema set.
s
)

Visits the root schema set.

public void
private void
wildcard(XSWildcard
Wild card.
wc
,
String
Additional attributes.
extraAtts
)

Creates node for wild card with additional attributes.

public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

currNodeback to summary
private SchemaTreeTraverser.SchemaTreeNode currNode

The current node in the tree.

modelback to summary
private SchemaTreeTraverser.SchemaTreeModel model

The associated tree model.

Constructor Detail

SchemaTreeTraverserback to summary
public SchemaTreeTraverser()

Simple constructor.

Method Detail

annotationback to summary
public void annotation(XSAnnotation ann)

Implements com.sun.xml.xsom.visitor.XSVisitor.annotation.

attGroupDeclback to summary
public void attGroupDecl(XSAttGroupDecl decl)

Implements com.sun.xml.xsom.visitor.XSVisitor.attGroupDecl.

attributeDeclback to summary
public void attributeDecl(XSAttributeDecl decl)

Implements com.sun.xml.xsom.visitor.XSVisitor.attributeDecl.

attributeUseback to summary
public void attributeUse(XSAttributeUse use)

Implements com.sun.xml.xsom.visitor.XSVisitor.attributeUse.

complexTypeback to summary
public void complexType(XSComplexType type)

Implements com.sun.xml.xsom.visitor.XSVisitor.complexType.

dumpback to summary
private void dump(XSAttributeDecl decl, String additionalAtts)

Creates node for attribute declaration with additional attributes.

Parameters
decl:XSAttributeDecl

Attribute declaration.

additionalAtts:String

Additional attributes.

dumpComplexTypeAttributeback to summary
private void dumpComplexTypeAttribute(XSComplexType type)

Creates node for complex type.

Parameters
type:XSComplexType

Complex type.

dumpRefback to summary
public void dumpRef(XSAttGroupDecl decl)

Creates node of attribute group decalration reference.

Parameters
decl:XSAttGroupDecl

Attribute group decalration reference.

elementDeclback to summary
public void elementDecl(XSElementDecl decl)

Implements com.sun.xml.xsom.visitor.XSTermVisitor.elementDecl.

elementDeclback to summary
private void elementDecl(XSElementDecl decl, String extraAtts)

Creates node for element declaration with additional attributes.

Parameters
decl:XSElementDecl

Element declaration.

extraAtts:String

Additional attributes.

emptyback to summary
public void empty(XSContentType t)

Implements com.sun.xml.xsom.visitor.XSContentTypeVisitor.empty.

facetback to summary
public void facet(XSFacet facet)

Implements com.sun.xml.xsom.visitor.XSVisitor.facet.

getModelback to summary
public SchemaTreeTraverser.SchemaTreeModel getModel()

Retrieves the tree model of this traverser.

Returns:SchemaTreeTraverser.SchemaTreeModel

Tree model of this traverser.

identityConstraintback to summary
public void identityConstraint(XSIdentityConstraint ic)

Implements com.sun.xml.xsom.visitor.XSVisitor.identityConstraint.

listSimpleTypeback to summary
public void listSimpleType(XSListSimpleType type)

Implements com.sun.xml.xsom.visitor.XSSimpleTypeVisitor.listSimpleType.

modelGroupback to summary
public void modelGroup(XSModelGroup group)

Implements com.sun.xml.xsom.visitor.XSTermVisitor.modelGroup.

modelGroupback to summary
private void modelGroup(XSModelGroup group, String extraAtts)

Creates node for model group with additional attributes.

Parameters
group:XSModelGroup

Model group.

extraAtts:String

Additional attributes.

modelGroupDeclback to summary
public void modelGroupDecl(XSModelGroupDecl decl)

Implements com.sun.xml.xsom.visitor.XSTermVisitor.modelGroupDecl.

notationback to summary
public void notation(XSNotation notation)

Implements com.sun.xml.xsom.visitor.XSVisitor.notation.

particleback to summary
public void particle(XSParticle part)

Implements com.sun.xml.xsom.visitor.XSContentTypeVisitor.particle.

restrictionSimpleTypeback to summary
public void restrictionSimpleType(XSRestrictionSimpleType type)

Implements com.sun.xml.xsom.visitor.XSSimpleTypeVisitor.restrictionSimpleType.

schemaback to summary
public void schema(XSSchema s)

Implements com.sun.xml.xsom.visitor.XSVisitor.schema.

simpleTypeback to summary
public void simpleType(XSSimpleType type)

Implements com.sun.xml.xsom.visitor.XSContentTypeVisitor.simpleType.

unionSimpleTypeback to summary
public void unionSimpleType(XSUnionSimpleType type)

Implements com.sun.xml.xsom.visitor.XSSimpleTypeVisitor.unionSimpleType.

visitback to summary
public void visit(XSSchemaSet s)

Visits the root schema set.

Parameters
s:XSSchemaSet

Root schema set.

wildcardback to summary
public void wildcard(XSWildcard wc)

Implements com.sun.xml.xsom.visitor.XSTermVisitor.wildcard.

wildcardback to summary
private void wildcard(XSWildcard wc, String extraAtts)

Creates node for wild card with additional attributes.

Parameters
wc:XSWildcard

Wild card.

extraAtts:String

Additional attributes.

xpathback to summary
public void xpath(XSXPath xp)

Implements com.sun.xml.xsom.visitor.XSVisitor.xpath.

com.sun.xml.xsom.impl.util back to summary

public Class SchemaTreeTraverser.SchemaRootNode

extends SchemaTreeNode
Class Inheritance

The root node of the schema hierarchy tree.
Author
Kirill Grouchnikov

Field Summary

Modifier and TypeField and Description
private static final long

Constructor Summary

AccessConstructor and Description
public
SchemaRootNode()

A simple constructor.

Method Summary

Inherited from com.sun.xml.xsom.impl.util.SchemaTreeTraverser.SchemaTreeNode:
getCaptiongetFileNamegetLineNumbersetFileNamesetLineNumber

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides com.sun.xml.xsom.impl.util.SchemaTreeTraverser.SchemaTreeNode.serialVersionUID.

Constructor Detail

SchemaRootNodeback to summary
public SchemaRootNode()

A simple constructor.

com.sun.xml.xsom.impl.util back to summary

public Class SchemaTreeTraverser.SchemaTreeCellRenderer

extends JPanel
implements TreeCellRenderer
Class Inheritance
All Implemented Interfaces
javax.swing.tree.TreeCellRenderer

Sample cell renderer for the schema tree.
Author
Kirill Grouchnikov

Field Summary

Modifier and TypeField and Description
protected final JLabel
iconLabel

The icon label.

private boolean
isSelected

The selection indicator.

public final Font
nameFont

Default font for the text label.

protected final JLabel
nameLabel

The text label

public final Color
selectedBackground

Background color for selected cells (light brown).

public final Color
selectedForeground

Foreground color for selected cells, both text and border (dark brown).

private static final long

Constructor Summary

AccessConstructor and Description
public
SchemaTreeCellRenderer()

Simple constructor.

Method Summary

Modifier and TypeMethod and Description
public final Component
getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus)

Implements javax.swing.tree.TreeCellRenderer.getTreeCellRendererComponent.

Sets the value of the current tree cell to value.

public final void
paintComponent(Graphics g)

Overrides javax.swing.JComponent.paintComponent.

Calls the UI delegate's paint method, if the UI delegate is non-null.

protected final void
setValues(Icon
Icon to show.
icon
,
String
Text to show.
caption
,
boolean
Selection indicator. If true, the renderer will be shown with different background and border settings.
selected
)

Sets values for the icon and text of this renderer.

Inherited from javax.swing.JPanel:
getAccessibleContextgetUIgetUIClassIDparamStringsetUIupdateUI

Field Detail

iconLabelback to summary
protected final JLabel iconLabel

The icon label.

isSelectedback to summary
private boolean isSelected

The selection indicator.

nameFontback to summary
public final Font nameFont

Default font for the text label.

nameLabelback to summary
protected final JLabel nameLabel

The text label

selectedBackgroundback to summary
public final Color selectedBackground

Background color for selected cells (light brown).

selectedForegroundback to summary
public final Color selectedForeground

Foreground color for selected cells, both text and border (dark brown).

serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.awt.Container.serialVersionUID.

Constructor Detail

SchemaTreeCellRendererback to summary
public SchemaTreeCellRenderer()

Simple constructor.

Method Detail

getTreeCellRendererComponentback to summary
public final Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus)

Implements javax.swing.tree.TreeCellRenderer.getTreeCellRendererComponent.

Doc from javax.swing.tree.TreeCellRenderer.getTreeCellRendererComponent.

Sets the value of the current tree cell to value. If selected is true, the cell will be drawn as if selected. If expanded is true the node is currently expanded and if leaf is true the node represents a leaf and if hasFocus is true the node currently has focus. tree is the JTree the receiver is being configured for. Returns the Component that the renderer uses to draw the value.

The TreeCellRenderer is also responsible for rendering the the cell representing the tree's current DnD drop location if it has one. If this renderer cares about rendering the DnD drop location, it should query the tree directly to see if the given row represents the drop location:

    JTree.DropLocation dropLocation = tree.getDropLocation();
    if (dropLocation != null
            && dropLocation.getChildIndex() == -1
            && tree.getRowForPath(dropLocation.getPath()) == row) {

        // this row represents the current drop location
        // so render it specially, perhaps with a different color
    }
paintComponentback to summary
public final void paintComponent(Graphics g)

Overrides javax.swing.JComponent.paintComponent.

Doc from javax.swing.JComponent.paintComponent.

Calls the UI delegate's paint method, if the UI delegate is non-null. We pass the delegate a copy of the Graphics object to protect the rest of the paint code from irrevocable changes (for example, Graphics.translate).

If you override this in a subclass you should not make permanent changes to the passed in Graphics. For example, you should not alter the clip Rectangle or modify the transform. If you need to do these operations you may find it easier to create a new Graphics from the passed in Graphics and manipulate it. Further, if you do not invoke super's implementation you must honor the opaque property, that is if this component is opaque, you must completely fill in the background in an opaque color. If you do not honor the opaque property you will likely see visual artifacts.

The passed in Graphics object might have a transform other than the identify transform installed on it. In this case, you might get unexpected results if you cumulatively apply another transform.

setValuesback to summary
protected final void setValues(Icon icon, String caption, boolean selected)

Sets values for the icon and text of this renderer.

Parameters
icon:Icon

Icon to show.

caption:String

Text to show.

selected:boolean

Selection indicator. If true, the renderer will be shown with different background and border settings.

com.sun.xml.xsom.impl.util back to summary

public final Class SchemaTreeTraverser.SchemaTreeModel

extends DefaultTreeModel
Class Inheritance

Tree model for schema hierarchy tree.
Author
Kirill Grouchnikov

Field Summary

Modifier and TypeField and Description
private static final long
Inherited from javax.swing.tree.DefaultTreeModel:
asksAllowsChildrenlistenerListroot

Constructor Summary

AccessConstructor and Description
private
SchemaTreeModel(SchemaTreeTraverser.SchemaRootNode
The root node.
root
)

A simple constructor.

Method Summary

Modifier and TypeMethod and Description
public void
public static SchemaTreeTraverser.SchemaTreeModel

Returns:

New empty tree model.
getInstance
()

A factory method for creating a new empty tree.

Inherited from javax.swing.tree.DefaultTreeModel:
addTreeModelListenerasksAllowsChildrenfireTreeNodesChangedfireTreeNodesInsertedfireTreeNodesRemovedfireTreeStructureChangedgetChildgetChildCountgetIndexOfChildgetListenersgetPathToRootgetPathToRootgetRootgetTreeModelListenersinsertNodeIntoisLeafnodeChangednodesChangednodeStructureChangednodesWereInsertednodesWereRemovedreloadreloadremoveNodeFromParentremoveTreeModelListenersetAsksAllowsChildrensetRootvalueForPathChanged

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

SchemaTreeModelback to summary
private SchemaTreeModel(SchemaTreeTraverser.SchemaRootNode root)

A simple constructor. Is made private to allow creating the root node first.

Parameters
root:SchemaTreeTraverser.SchemaRootNode

The root node.

Method Detail

addSchemaNodeback to summary
public void addSchemaNode(SchemaTreeTraverser.SchemaTreeNode node)
getInstanceback to summary
public static SchemaTreeTraverser.SchemaTreeModel getInstance()

A factory method for creating a new empty tree.

Returns:SchemaTreeTraverser.SchemaTreeModel

New empty tree model.

com.sun.xml.xsom.impl.util back to summary

public Class SchemaTreeTraverser.SchemaTreeNode

extends DefaultMutableTreeNode
Class Inheritance
Known Direct Subclasses
com.sun.xml.xsom.impl.util.SchemaTreeTraverser.SchemaRootNode

The node of the schema hierarchy tree.
Author
Kirill Grouchnikov

Field Summary

Modifier and TypeField and Description
private String
artifactName

The caption of the corresponding artifact.

private String
fileName

File name of the corresponding schema artifact.

private int
lineNumber

Line number of the corresponding schema artifact.

private static final long
Inherited from javax.swing.tree.DefaultMutableTreeNode:
allowsChildrenchildrenEMPTY_ENUMERATIONparentuserObject

Constructor Summary

AccessConstructor and Description
public
SchemaTreeNode(String
Artifact name.
artifactName
,
Locator
Artifact locator.
locator
)

Simple constructor.

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

The caption for this node.
getCaption
()

Returns the caption for this node.

public String
getFileName()

Returns: Returns the file name of the corresponding schema artifact.

public int
getLineNumber()

Returns: Returns the line number of the corresponding schema artifact.

public void
setFileName(String
The file name of the corresponding schema artifact to set.
fileName
)

public void
setLineNumber(int
The line number of the corresponding schema artifact to set.
lineNumber
)

Inherited from javax.swing.tree.DefaultMutableTreeNode:
addbreadthFirstEnumerationchildrenclonedepthFirstEnumerationgetAllowsChildrengetChildAftergetChildAtgetChildBeforegetChildCountgetDepthgetFirstChildgetFirstLeafgetIndexgetLastChildgetLastLeafgetLeafCountgetLevelgetNextLeafgetNextNodegetNextSiblinggetParentgetPathgetPathToRootgetPreviousLeafgetPreviousNodegetPreviousSiblinggetRootgetSharedAncestorgetSiblingCountgetUserObjectgetUserObjectPathinsertisLeafisNodeAncestorisNodeChildisNodeDescendantisNodeRelatedisNodeSiblingisRootpathFromAncestorEnumerationpostorderEnumerationpreorderEnumerationremoveremoveremoveAllChildrenremoveFromParentsetAllowsChildrensetParentsetUserObjecttoString

Field Detail

artifactNameback to summary
private String artifactName

The caption of the corresponding artifact.

fileNameback to summary
private String fileName

File name of the corresponding schema artifact.

lineNumberback to summary
private int lineNumber

Line number of the corresponding schema artifact.

serialVersionUIDback to summary
private static final long serialVersionUID

Hides javax.swing.tree.DefaultMutableTreeNode.serialVersionUID.

Constructor Detail

SchemaTreeNodeback to summary
public SchemaTreeNode(String artifactName, Locator locator)

Simple constructor.

Parameters
artifactName:String

Artifact name.

locator:Locator

Artifact locator.

Method Detail

getCaptionback to summary
public String getCaption()

Returns the caption for this node.

Returns:String

The caption for this node.

getFileNameback to summary
public String getFileName()
Returns:String

Returns the file name of the corresponding schema artifact.

getLineNumberback to summary
public int getLineNumber()
Returns:int

Returns the line number of the corresponding schema artifact.

setFileNameback to summary
public void setFileName(String fileName)
Parameters
fileName:String

The file name of the corresponding schema artifact to set.

setLineNumberback to summary
public void setLineNumber(int lineNumber)
Parameters
lineNumber:int

The line number of the corresponding schema artifact to set.