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