001// Copyright 2004, 2005 The Apache Software Foundation
002//
003// Licensed under the Apache License, Version 2.0 (the "License");
004// you may not use this file except in compliance with the License.
005// You may obtain a copy of the License at
006//
007//     http://www.apache.org/licenses/LICENSE-2.0
008//
009// Unless required by applicable law or agreed to in writing, software
010// distributed under the License is distributed on an "AS IS" BASIS,
011// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012// See the License for the specific language governing permissions and
013// limitations under the License.
014
015package org.apache.hivemind.schema;
016
017import java.util.List;
018
019import org.apache.hivemind.Locatable;
020import org.apache.hivemind.internal.Module;
021import org.apache.hivemind.parse.AnnotationHolder;
022
023/**
024 * An object which may contain a model, used to identify the form of XML content allowed within some
025 * other, containing element.
026 * <p>
027 * This is very much provisional; in the future will be more control for validation (i.e,
028 * controlling the number of occurances), and support for analogs of W3C SChema sequence and choice.
029 * The excess flexibility here forces some validation into element objects (the objects created from
030 * the {@link org.apache.hivemind.schema.Rule}s within the
031 * {@link org.apache.hivemind.schema.ElementModel}s).
032 * 
033 * @author Howard Lewis Ship
034 */
035public interface Schema extends AnnotationHolder, Locatable
036{
037    /**
038     * Returns the (unqualified) id of this schema.
039     * 
040     * @since 1.1
041     */
042    public String getId();
043
044    /**
045     * Returns a List of {@link ElementModel}, identifing the elements which may be enclosed by the
046     * modeled element.
047     * <p>
048     * The returned list is unmodifiabled and may be empty, but won't be null.
049     */
050    public List getElementModel();
051
052    /**
053     * Returns true if Elements conforming to this Schema can be indexed using a key. For this to be
054     * true every {@link #getElementModel() top-level ElementModel} must define a non-null
055     * {@link ElementModel#getKeyAttribute() key attribute}.
056     * 
057     * @since 1.1
058     */
059    public boolean canInstancesBeKeyed();
060
061    /**
062     * Returns true if the schema is visible to the specified module, false otherwise.
063     * 
064     * @since 1.1
065     */
066    public boolean visibleToModule(String moduleId);
067    
068    /**
069     * 
070     * Return the Module in which the Schema was defined.
071     * 
072     * @since 1.1
073     * 
074     */
075    
076    public Module getDefiningModule();
077}