325N/A/*
325N/A * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
325N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
325N/A *
325N/A * This code is free software; you can redistribute it and/or modify it
325N/A * under the terms of the GNU General Public License version 2 only, as
325N/A * published by the Free Software Foundation. Oracle designates this
325N/A * particular file as subject to the "Classpath" exception as provided
325N/A * by Oracle in the LICENSE file that accompanied this code.
325N/A *
325N/A * This code is distributed in the hope that it will be useful, but WITHOUT
325N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
325N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
325N/A * version 2 for more details (a copy is included in the LICENSE file that
325N/A * accompanied this code).
325N/A *
325N/A * You should have received a copy of the GNU General Public License version
325N/A * 2 along with this work; if not, write to the Free Software Foundation,
325N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
325N/A *
325N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
325N/A * or visit www.oracle.com if you need additional information or have any
325N/A * questions.
325N/A */
325N/A
325N/Apackage com.sun.xml.internal.xsom;
325N/A
325N/Aimport com.sun.xml.internal.xsom.parser.SchemaDocument;
325N/Aimport com.sun.xml.internal.xsom.visitor.XSFunction;
325N/Aimport com.sun.xml.internal.xsom.visitor.XSVisitor;
325N/Aimport org.xml.sax.Locator;
325N/A
325N/Aimport javax.xml.namespace.NamespaceContext;
325N/Aimport java.util.List;
325N/Aimport java.util.Collection;
325N/A
325N/A/**
325N/A * Base interface for all the schema components.
325N/A *
325N/A * @author
325N/A * Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
325N/A */
325N/Apublic interface XSComponent
325N/A{
325N/A /** Gets the annotation associated to this component, if any. */
325N/A XSAnnotation getAnnotation();
325N/A
325N/A /**
325N/A * Works like {@link #getAnnotation()}, but allow a new empty {@link XSAnnotation} to be created
325N/A * if not exist.
325N/A *
325N/A * @param createIfNotExist
325N/A * true to create a new {@link XSAnnotation} if it doesn't exist already.
325N/A * false to make this method behavel like {@link #getAnnotation()}.
325N/A *
325N/A * @return
325N/A * null if <tt>createIfNotExist==false</tt> and annotation didn't exist.
325N/A * Otherwise non-null.
325N/A */
325N/A XSAnnotation getAnnotation(boolean createIfNotExist);
325N/A
325N/A /**
325N/A * Gets the foreign attributes on this schema component.
325N/A *
325N/A * <p>
325N/A * In general, a schema component may match multiple elements
325N/A * in a schema document, and those elements can individually
325N/A * carry foreign attributes.
325N/A *
325N/A * <p>
325N/A * This method returns a list of {@link ForeignAttributes}, where
325N/A * each {@link ForeignAttributes} object represent foreign attributes
325N/A * on one element.
325N/A *
325N/A * @return
325N/A * can be an empty list but never be null.
325N/A */
325N/A List<? extends ForeignAttributes> getForeignAttributes();
325N/A
325N/A /**
325N/A * Gets the foreign attribute of the given name, or null if not found.
325N/A *
325N/A * <p>
325N/A * If multiple occurences of the same attribute is found,
325N/A * this method returns the first one.
325N/A *
325N/A * @see #getForeignAttributes()
325N/A */
325N/A String getForeignAttribute(String nsUri, String localName);
325N/A
325N/A /**
325N/A * Gets the locator that indicates the source location where
325N/A * this component is created from, or null if no information is
325N/A * available.
325N/A */
325N/A Locator getLocator();
325N/A
325N/A /**
325N/A * Gets a reference to the {@link XSSchema} object to which this component
325N/A * belongs.
325N/A * <p>
325N/A * In case of <code>XSEmpty</code> component, this method
325N/A * returns null since there is no owner component.
325N/A */
325N/A XSSchema getOwnerSchema();
325N/A
325N/A /**
325N/A * Gets the root schema set that includes this component.
325N/A *
325N/A * <p>
325N/A * In case of <code>XSEmpty</code> component, this method
325N/A * returns null since there is no owner component.
325N/A */
325N/A XSSchemaSet getRoot();
325N/A
325N/A /**
325N/A * Gets the {@link SchemaDocument} that indicates which document this component
325N/A * was defined in.
325N/A *
325N/A * @return
325N/A * null for components that are built-in to XML Schema, such
325N/A * as anyType, or "empty" {@link XSContentType}. This method also
325N/A * returns null for {@link XSSchema}.
325N/A * For all other user-defined
325N/A * components this method returns non-null, even if they are local.
325N/A */
325N/A SchemaDocument getSourceDocument();
325N/A
325N/A /**
325N/A * Evaluates a schema component designator against this schema component
325N/A * and returns the resulting schema components.
325N/A *
325N/A * @throws IllegalArgumentException
325N/A * if SCD is syntactically incorrect.
325N/A *
325N/A * @param scd
325N/A * Schema component designator. See {@link SCD} for more details.
325N/A * @param nsContext
325N/A * The namespace context in which SCD is evaluated. Cannot be null.
325N/A * @return
325N/A * Can be empty but never null.
325N/A */
325N/A Collection<XSComponent> select(String scd, NamespaceContext nsContext);
325N/A
325N/A /**
325N/A * Evaluates a schema component designator against this schema component
325N/A * and returns the first resulting schema component.
325N/A *
325N/A * @throws IllegalArgumentException
325N/A * if SCD is syntactically incorrect.
325N/A *
325N/A * @param scd
325N/A * Schema component designator. See {@link SCD} for more details.
325N/A * @param nsContext
325N/A * The namespace context in which SCD is evaluated. Cannot be null.
325N/A * @return
325N/A * null if the SCD didn't match anything. If the SCD matched more than one node,
325N/A * the first one will be returned.
325N/A */
325N/A XSComponent selectSingle(String scd, NamespaceContext nsContext);
325N/A
325N/A /**
325N/A * Accepts a visitor.
325N/A */
325N/A void visit( XSVisitor visitor );
325N/A /**
325N/A * Accepts a functor.
325N/A */
325N/A <T> T apply( XSFunction<T> function );
325N/A}