/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* Generates approximated tree model for XML from a schema component. This is
* not intended to be a fully-fledged round-trippable tree model.
*
* <h2>Usage of this class</h2>
*
* <ol> <li>Create a new instance.</li> <li>Call {@link
* #visit(com.sun.xml.internal.xsom.XSSchemaSet)} function on your schema set.>/li>
* <li>Retrieve the model using {@link #getModel()}. </li></ol>
*
* Every node in the resulting tree is a {@link SchemaTreeTraverser.SchemaTreeNode},
* and the model itself is {@link SchemaTreeTraverser.SchemaTreeModel}. You can
* use {@link SchemaTreeTraverser.SchemaTreeCellRenderer} as a cell renderer for
* your tree.
*
* @author Kirill Grouchnikov (kirillcool@yahoo.com)
*/
/**
* The associated tree model.
*/
/**
* The current node in the tree.
*/
/**
* Tree model for schema hierarchy tree.
*
* @author Kirill Grouchnikov
*/
/**
* A simple constructor. Is made private to allow creating the root node
* first.
*
* @param root The root node.
*/
super(root);
}
/**
* A factory method for creating a new empty tree.
*
* @return New empty tree model.
*/
return new SchemaTreeModel(root);
}
}
}
/**
* The node of the schema hierarchy tree.
*
* @author Kirill Grouchnikov
*/
/**
* File name of the corresponding schema artifact.
*/
/**
* Line number of the corresponding schema artifact.
*/
private int lineNumber;
/**
* The caption of the corresponding artifact.
*/
/**
* Simple constructor.
*
* @param artifactName Artifact name.
* @param locator Artifact locator.
*/
this.artifactName = artifactName;
}
else {
// strip leading protocol
}
}
}
/**
* Returns the caption for <code>this</code> node.
*
* @return The caption for <code>this</code> node.
*/
return this.artifactName;
}
/**
* @return Returns the file name of the corresponding schema artifact.
*/
return fileName;
}
/**
* @param fileName The file name of the corresponding schema artifact to
* set.
*/
}
/**
* @return Returns the line number of the corresponding schema
* artifact.
*/
public int getLineNumber() {
return lineNumber;
}
/**
* @param lineNumber The line number of the corresponding schema
* artifact to set.
*/
this.lineNumber = lineNumber;
}
}
/**
* The root node of the schema hierarchy tree.
*
* @author Kirill Grouchnikov
*/
/**
* A simple constructor.
*/
public SchemaRootNode() {
super("Schema set", null);
}
}
/**
* Sample cell renderer for the schema tree.
*
* @author Kirill Grouchnikov
*/
/**
* The icon label.
*/
/**
* The text label
*/
/**
* The selection indicator.
*/
private boolean isSelected;
/**
* Background color for selected cells (light brown).
*/
/**
* Foreground color for selected cells, both text and border (dark
* brown).
*/
/**
* Default font for the text label.
*/
/**
* Simple constructor.
*/
public SchemaTreeCellRenderer() {
// add some space
this.isSelected = false;
this.setOpaque(false);
}
/*
* (non-Javadoc)
*
* @see javax.swing.JComponent#paintComponent(java.awt.Graphics)
*/
if (this.isSelected) {
}
super.paintComponent(g);
}
/**
* Sets values for the icon and text of <code>this</code> renderer.
*
* @param icon Icon to show.
* @param caption Text to show.
* @param selected Selection indicator. If <code>true</code>, the
* renderer will be shown with different background and
* border settings.
*/
boolean selected) {
this.isSelected = selected;
if (selected) {
}
else {
}
}
/* (non-Javadoc)
* @see javax.swing.tree.TreeCellRenderer#getTreeCellRendererComponent(javax.swing.JTree, java.lang.Object, boolean, boolean, boolean, int, boolean)
*/
boolean hasFocus) {
if (value instanceof SchemaTreeNode) {
return this;
}
throw new IllegalStateException("Unknown node");
}
}
/**
* Simple constructor.
*/
public SchemaTreeTraverser() {
}
/**
* Retrieves the tree model of <code>this</code> traverser.
*
* @return Tree model of <code>this</code> traverser.
*/
return model;
}
/**
* Visits the root schema set.
*
* @param s Root schema set.
*/
}
}
/* (non-Javadoc)
* @see com.sun.xml.internal.xsom.visitor.XSVisitor#schema(com.sun.xml.internal.xsom.XSSchema)
*/
// QUICK HACK: don't print the built-in components
return;
}
}
}
}
}
}
}
}
/* (non-Javadoc)
* @see com.sun.xml.internal.xsom.visitor.XSVisitor#attGroupDecl(com.sun.xml.internal.xsom.XSAttGroupDecl)
*/
}
}
}
/**
* Creates node of attribute group decalration reference.
*
* @param decl Attribute group decalration reference.
*/
.getLocator());
}
/* (non-Javadoc)
* @see com.sun.xml.internal.xsom.visitor.XSVisitor#attributeUse(com.sun.xml.internal.xsom.XSAttributeUse)
*/
if (use.isRequired()) {
additionalAtts += " use=\"required\"";
}
}
}
// this is anonymous attribute use
}
else {
// reference to a global one
"Attribute ref \"'{'{0}'}'{1}{2}\"", new Object[]{
}
}
/* (non-Javadoc)
* @see com.sun.xml.internal.xsom.visitor.XSVisitor#attributeDecl(com.sun.xml.internal.xsom.XSAttributeDecl)
*/
}
/**
* Creates node for attribute declaration with additional attributes.
*
* @param decl Attribute declaration.
* @param additionalAtts Additional attributes.
*/
new Object[]{
" type=\"'{'{0}'}'{1}\"", new Object[]{
}
}
/* (non-Javadoc)
* @see com.sun.xml.internal.xsom.visitor.XSContentTypeVisitor#simpleType(com.sun.xml.internal.xsom.XSSimpleType)
*/
}
/* (non-Javadoc)
* @see com.sun.xml.internal.xsom.visitor.XSSimpleTypeVisitor#listSimpleType(com.sun.xml.internal.xsom.XSListSimpleType)
*/
.getLocator());
}
else {
// global type
.getLocator());
}
}
/* (non-Javadoc)
* @see com.sun.xml.internal.xsom.visitor.XSSimpleTypeVisitor#unionSimpleType(com.sun.xml.internal.xsom.XSUnionSimpleType)
*/
for (int i = 0; i < len; i++) {
new Object[]{
}
}
+ ref + "\"");
for (int i = 0; i < len; i++) {
}
}
}
/* (non-Javadoc)
* @see com.sun.xml.internal.xsom.visitor.XSSimpleTypeVisitor#restrictionSimpleType(com.sun.xml.internal.xsom.XSRestrictionSimpleType)
*/
// don't print anySimpleType
throw new InternalError();
}
throw new InternalError();
}
return;
}
}
}
}
/* (non-Javadoc)
* @see com.sun.xml.internal.xsom.visitor.XSVisitor#facet(com.sun.xml.internal.xsom.XSFacet)
*/
facet.getLocator());
}
/* (non-Javadoc)
* @see com.sun.xml.internal.xsom.visitor.XSVisitor#notation(com.sun.xml.internal.xsom.XSNotation)
*/
"Notation name='\"0}\" public =\"{1}\" system=\"{2}\"",
}
/* (non-Javadoc)
* @see com.sun.xml.internal.xsom.visitor.XSVisitor#complexType(com.sun.xml.internal.xsom.XSComplexType)
*/
.getLocator());
// TODO: wildcard
// simple content
.getContentType().getLocator());
// restriction
"Restriction base=\"<{0}>{1}\"", new Object[]{
.getLocator());
}
else {
// extension
"Extension base=\"<{0}>{1}\"", new Object[]{
.getLocator());
// check if have redefine tag
baseType.getTargetNamespace()) ==
0)
"redefine", type
.getLocator());
this.currNode = newNodeRedefine;
this.currNode =
}
}
}
else {
// complex content
// restriction
"Restriction base=\"<{0}>{1}\"", new Object[]{
baseType.getLocator());
}
else {
// extension
"Extension base=\"'{'{0}'}'{1}\"", new Object[]{
baseType.getLocator());
// check if have redefine tag
baseType.getTargetNamespace()) ==
0)
"redefine", type
.getLocator());
this.currNode = newNodeRedefine;
this.currNode =
}
}
}
}
/**
* Creates node for complex type.
*
* @param type Complex type.
*/
}
}
}
/* (non-Javadoc)
* @see com.sun.xml.internal.xsom.visitor.XSTermVisitor#elementDecl(com.sun.xml.internal.xsom.XSElementDecl)
*/
}
/**
* Creates node for element declaration with additional attributes.
*
* @param decl Element declaration.
* @param extraAtts Additional attributes.
*/
// TODO: various other attributes
new Object[]{
}
}
}
/* (non-Javadoc)
* @see com.sun.xml.internal.xsom.visitor.XSTermVisitor#modelGroupDecl(com.sun.xml.internal.xsom.XSModelGroupDecl)
*/
decl.getLocator());
}
/* (non-Javadoc)
* @see com.sun.xml.internal.xsom.visitor.XSTermVisitor#modelGroup(com.sun.xml.internal.xsom.XSModelGroup)
*/
}
/**
* Creates node for model group with additional attributes.
*
* @param group Model group.
* @param extraAtts Additional attributes.
*/
group.getLocator());
for (int i = 0; i < len; i++) {
}
}
/* (non-Javadoc)
* @see com.sun.xml.internal.xsom.visitor.XSContentTypeVisitor#particle(com.sun.xml.internal.xsom.XSParticle)
*/
BigInteger i;
i = part.getMaxOccurs();
}
else {
}
}
i = part.getMinOccurs();
}
}
else {
// reference
.format("Element ref=\"'{'{0}'}'{1}\"{2}",
decl.getLocator());
}
}
// reference
}
}
}
});
}
/* (non-Javadoc)
* @see com.sun.xml.internal.xsom.visitor.XSTermVisitor#wildcard(com.sun.xml.internal.xsom.XSWildcard)
*/
}
/**
* Creates node for wild card with additional attributes.
*
* @param wc Wild card.
* @param extraAtts Additional attributes.
*/
// TODO
}
/* (non-Javadoc)
* @see com.sun.xml.internal.xsom.visitor.XSVisitor#annotation(com.sun.xml.internal.xsom.XSAnnotation)
*/
// TODO: it would be nice even if we just put <xs:documentation>
}
/* (non-Javadoc)
* @see com.sun.xml.internal.xsom.visitor.XSContentTypeVisitor#empty(com.sun.xml.internal.xsom.XSContentType)
*/
}
/* (non-Javadoc)
* @see com.sun.xml.internal.xsom.visitor.XSVisitor#identityConstraint(com.sun.xml.internal.xsom.XSIdentityConstraint)
*/
}
/* (non-Javadoc)
* @see com.sun.xml.internal.xsom.visitor.XSVisitor#xpath(com.sun.xml.internal.xsom.XSXPath)
*/
}
}