1 /*
   2  * reserved comment block
   3  * DO NOT REMOVE OR ALTER!
   4  */
   5 /*
   6  * Copyright 2000-2002,2004 The Apache Software Foundation.
   7  *
   8  * Licensed under the Apache License, Version 2.0 (the "License");
   9  * you may not use this file except in compliance with the License.
  10  * You may obtain a copy of the License at
  11  *
  12  *      http://www.apache.org/licenses/LICENSE-2.0
  13  *
  14  * Unless required by applicable law or agreed to in writing, software
  15  * distributed under the License is distributed on an "AS IS" BASIS,
  16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17  * See the License for the specific language governing permissions and
  18  * limitations under the License.
  19  */
  20 
  21 package com.sun.org.apache.xerces.internal.xni.grammars;
  22 
  23 import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException;
  24 import com.sun.org.apache.xerces.internal.xni.parser.XMLErrorHandler;
  25 import com.sun.org.apache.xerces.internal.xni.parser.XMLEntityResolver;
  26 import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
  27 import com.sun.org.apache.xerces.internal.xni.XNIException;
  28 
  29 import java.io.IOException;
  30 import java.util.Locale;
  31 
  32 /**
  33  * The intention of this interface is to provide a generic means
  34  * by which Grammar objects may be created without parsing instance
  35  * documents.  Implementations of this interface will know how to load
  36  * specific types of grammars (e.g., DTD's or schemas); a wrapper
  37  * will be provided for user applications to interact with these implementations.
  38  *
  39  * @author Neil Graham, IBM
  40  */
  41 
  42 public interface XMLGrammarLoader {
  43 
  44     /**
  45      * Returns a list of feature identifiers that are recognized by
  46      * this XMLGrammarLoader.  This method may return null if no features
  47      * are recognized.
  48      */
  49     public String[] getRecognizedFeatures();
  50 
  51     /**
  52      * Returns the state of a feature.
  53      *
  54      * @param featureId The feature identifier.
  55      *
  56      * @throws XMLConfigurationException Thrown on configuration error.
  57      */
  58     public boolean getFeature(String featureId)
  59             throws XMLConfigurationException;
  60 
  61     /**
  62      * Sets the state of a feature.
  63      *
  64      * @param featureId The feature identifier.
  65      * @param state     The state of the feature.
  66      *
  67      * @throws XMLConfigurationException Thrown when a feature is not
  68      *                  recognized or cannot be set.
  69      */
  70     public void setFeature(String featureId,
  71                 boolean state) throws XMLConfigurationException;
  72 
  73     /**
  74      * Returns a list of property identifiers that are recognized by
  75      * this XMLGrammarLoader.  This method may return null if no properties
  76      * are recognized.
  77      */
  78     public String[] getRecognizedProperties();
  79 
  80     /**
  81      * Returns the state of a property.
  82      *
  83      * @param propertyId The property identifier.
  84      *
  85      * @throws XMLConfigurationException Thrown on configuration error.
  86      */
  87     public Object getProperty(String propertyId)
  88             throws XMLConfigurationException;
  89 
  90     /**
  91      * Sets the state of a property.
  92      *
  93      * @param propertyId The property identifier.
  94      * @param state     The state of the property.
  95      *
  96      * @throws XMLConfigurationException Thrown when a property is not
  97      *                  recognized or cannot be set.
  98      */
  99     public void setProperty(String propertyId,
 100                 Object state) throws XMLConfigurationException;
 101 
 102     /**
 103      * Set the locale to use for messages.
 104      *
 105      * @param locale The locale object to use for localization of messages.
 106      *
 107      * @exception XNIException Thrown if the parser does not support the
 108      *                         specified locale.
 109      */
 110     public void setLocale(Locale locale);
 111 
 112     /** Return the Locale the XMLGrammarLoader is using. */
 113     public Locale getLocale();
 114 
 115     /**
 116      * Sets the error handler.
 117      *
 118      * @param errorHandler The error handler.
 119      */
 120     public void setErrorHandler(XMLErrorHandler errorHandler);
 121 
 122     /** Returns the registered error handler.  */
 123     public XMLErrorHandler getErrorHandler();
 124 
 125     /**
 126      * Sets the entity resolver.
 127      *
 128      * @param entityResolver The new entity resolver.
 129      */
 130     public void setEntityResolver(XMLEntityResolver entityResolver);
 131 
 132     /** Returns the registered entity resolver.  */
 133     public XMLEntityResolver getEntityResolver();
 134 
 135     /**
 136      * Returns a Grammar object by parsing the contents of the
 137      * entity pointed to by source.
 138      *
 139      * @param source        the location of the entity which forms
 140      *                          the starting point of the grammar to be constructed.
 141      * @throws IOException      When a problem is encountered reading the entity
 142      *          XNIException    When a condition arises (such as a FatalError) that requires parsing
 143      *                              of the entity be terminated.
 144      */
 145     public Grammar loadGrammar(XMLInputSource source)
 146         throws IOException, XNIException;
 147 } // XMLGrammarLoader