blob: 4b702c3cb6ea22d206473bc6285738d22529adb1 [file] [log] [blame]
/*
* Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package com.sun.xml.internal.xsom;
import com.sun.xml.internal.xsom.parser.SchemaDocument;
import com.sun.xml.internal.xsom.visitor.XSFunction;
import com.sun.xml.internal.xsom.visitor.XSVisitor;
import org.xml.sax.Locator;
import java.util.List;
/**
* Base interface for all the schema components.
*
* @author
* Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
*/
public interface XSComponent
{
/** Gets the annotation associated to this component, if any. */
XSAnnotation getAnnotation();
/**
* Gets the foreign attributes on this schema component.
*
* <p>
* In general, a schema component may match multiple elements
* in a schema document, and those elements can individually
* carry foreign attributes.
*
* <p>
* This method returns a list of {@link ForeignAttributes}, where
* each {@link ForeignAttributes} object represent foreign attributes
* on one element.
*
* @return
* can be an empty list but never be null.
*/
List<? extends ForeignAttributes> getForeignAttributes();
/**
* Gets the foreign attribute of the given name, or null if not found.
*
* <p>
* If multiple occurences of the same attribute is found,
* this method returns the first one.
*
* @see #getForeignAttributes()
*/
String getForeignAttribute(String nsUri, String localName);
/**
* Gets the locator that indicates the source location where
* this component is created from, or null if no information is
* available.
*/
Locator getLocator();
/**
* Gets a reference to the {@link XSSchema} object to which this component
* belongs.
* <p>
* In case of <code>XSEmpty</code> component, this method
* returns null since there is no owner component.
*/
XSSchema getOwnerSchema();
/**
* Gets the {@link SchemaDocument} that indicates which document this component
* was defined in.
*
* @return
* null for components that are built-in to XML Schema, such
* as anyType, or "empty" {@link XSContentType}. This method also
* returns null for {@link XSSchema}.
* For all other user-defined
* components this method returns non-null, even if they are local.
*/
SchemaDocument getSourceDocument();
/**
* Accepts a visitor.
*/
void visit( XSVisitor visitor );
/**
* Accepts a functor.
*/
<T> T apply( XSFunction<T> function );
}