001: /*
002: * Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025:
026: package com.sun.xml.internal.xsom;
027:
028: import com.sun.xml.internal.xsom.parser.SchemaDocument;
029: import com.sun.xml.internal.xsom.visitor.XSFunction;
030: import com.sun.xml.internal.xsom.visitor.XSVisitor;
031: import org.xml.sax.Locator;
032:
033: import java.util.List;
034:
035: /**
036: * Base interface for all the schema components.
037: *
038: * @author
039: * Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
040: */
041: public interface XSComponent {
042: /** Gets the annotation associated to this component, if any. */
043: XSAnnotation getAnnotation();
044:
045: /**
046: * Gets the foreign attributes on this schema component.
047: *
048: * <p>
049: * In general, a schema component may match multiple elements
050: * in a schema document, and those elements can individually
051: * carry foreign attributes.
052: *
053: * <p>
054: * This method returns a list of {@link ForeignAttributes}, where
055: * each {@link ForeignAttributes} object represent foreign attributes
056: * on one element.
057: *
058: * @return
059: * can be an empty list but never be null.
060: */
061: List<? extends ForeignAttributes> getForeignAttributes();
062:
063: /**
064: * Gets the foreign attribute of the given name, or null if not found.
065: *
066: * <p>
067: * If multiple occurences of the same attribute is found,
068: * this method returns the first one.
069: *
070: * @see #getForeignAttributes()
071: */
072: String getForeignAttribute(String nsUri, String localName);
073:
074: /**
075: * Gets the locator that indicates the source location where
076: * this component is created from, or null if no information is
077: * available.
078: */
079: Locator getLocator();
080:
081: /**
082: * Gets a reference to the {@link XSSchema} object to which this component
083: * belongs.
084: * <p>
085: * In case of <code>XSEmpty</code> component, this method
086: * returns null since there is no owner component.
087: */
088: XSSchema getOwnerSchema();
089:
090: /**
091: * Gets the {@link SchemaDocument} that indicates which document this component
092: * was defined in.
093: *
094: * @return
095: * null for components that are built-in to XML Schema, such
096: * as anyType, or "empty" {@link XSContentType}. This method also
097: * returns null for {@link XSSchema}.
098: * For all other user-defined
099: * components this method returns non-null, even if they are local.
100: */
101: SchemaDocument getSourceDocument();
102:
103: /**
104: * Accepts a visitor.
105: */
106: void visit(XSVisitor visitor);
107:
108: /**
109: * Accepts a functor.
110: */
111: <T> T apply(XSFunction<T> function);
112: }
|