1. /*
  2. * The Apache Software License, Version 1.1
  3. *
  4. *
  5. * Copyright (c) 2000-2002 The Apache Software Foundation.
  6. * All rights reserved.
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions
  10. * are met:
  11. *
  12. * 1. Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. *
  15. * 2. Redistributions in binary form must reproduce the above copyright
  16. * notice, this list of conditions and the following disclaimer in
  17. * the documentation and/or other materials provided with the
  18. * distribution.
  19. *
  20. * 3. The end-user documentation included with the redistribution,
  21. * if any, must include the following acknowledgment:
  22. * "This product includes software developed by the
  23. * Apache Software Foundation (http://www.apache.org/)."
  24. * Alternately, this acknowledgment may appear in the software itself,
  25. * if and wherever such third-party acknowledgments normally appear.
  26. *
  27. * 4. The names "Xerces" and "Apache Software Foundation" must
  28. * not be used to endorse or promote products derived from this
  29. * software without prior written permission. For written
  30. * permission, please contact apache@apache.org.
  31. *
  32. * 5. Products derived from this software may not be called "Apache",
  33. * nor may "Apache" appear in their name, without prior written
  34. * permission of the Apache Software Foundation.
  35. *
  36. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  37. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  38. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  39. * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  40. * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  41. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  42. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  43. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  44. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  45. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  46. * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  47. * SUCH DAMAGE.
  48. * ====================================================================
  49. *
  50. * This software consists of voluntary contributions made by many
  51. * individuals on behalf of the Apache Software Foundation and was
  52. * originally based on software copyright (c) 1999, International
  53. * Business Machines, Inc., http://www.apache.org. For more
  54. * information on the Apache Software Foundation, please see
  55. * <http://www.apache.org/>.
  56. */
  57. package com.sun.org.apache.xerces.internal.xni.grammars;
  58. import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException;
  59. import com.sun.org.apache.xerces.internal.xni.parser.XMLErrorHandler;
  60. import com.sun.org.apache.xerces.internal.xni.parser.XMLEntityResolver;
  61. import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
  62. import com.sun.org.apache.xerces.internal.xni.XNIException;
  63. import java.io.IOException;
  64. import java.util.Locale;
  65. /**
  66. * The intention of this interface is to provide a generic means
  67. * by which Grammar objects may be created without parsing instance
  68. * documents. Implementations of this interface will know how to load
  69. * specific types of grammars (e.g., DTD's or schemas); a wrapper
  70. * will be provided for user applications to interact with these implementations.
  71. *
  72. * @author Neil Graham, IBM
  73. * @version $Id: XMLGrammarLoader.java,v 1.1 2002/05/23 16:46:01 neilg Exp $
  74. */
  75. public interface XMLGrammarLoader {
  76. /**
  77. * Returns a list of feature identifiers that are recognized by
  78. * this XMLGrammarLoader. This method may return null if no features
  79. * are recognized.
  80. */
  81. public String[] getRecognizedFeatures();
  82. /**
  83. * Returns the state of a feature.
  84. *
  85. * @param featureId The feature identifier.
  86. *
  87. * @throws XMLConfigurationException Thrown on configuration error.
  88. */
  89. public boolean getFeature(String featureId)
  90. throws XMLConfigurationException;
  91. /**
  92. * Sets the state of a feature.
  93. *
  94. * @param featureId The feature identifier.
  95. * @param state The state of the feature.
  96. *
  97. * @throws XMLConfigurationException Thrown when a feature is not
  98. * recognized or cannot be set.
  99. */
  100. public void setFeature(String featureId,
  101. boolean state) throws XMLConfigurationException;
  102. /**
  103. * Returns a list of property identifiers that are recognized by
  104. * this XMLGrammarLoader. This method may return null if no properties
  105. * are recognized.
  106. */
  107. public String[] getRecognizedProperties();
  108. /**
  109. * Returns the state of a property.
  110. *
  111. * @param propertyId The property identifier.
  112. *
  113. * @throws XMLConfigurationException Thrown on configuration error.
  114. */
  115. public Object getProperty(String propertyId)
  116. throws XMLConfigurationException;
  117. /**
  118. * Sets the state of a property.
  119. *
  120. * @param propertyId The property identifier.
  121. * @param state The state of the property.
  122. *
  123. * @throws XMLConfigurationException Thrown when a property is not
  124. * recognized or cannot be set.
  125. */
  126. public void setProperty(String propertyId,
  127. Object state) throws XMLConfigurationException;
  128. /**
  129. * Set the locale to use for messages.
  130. *
  131. * @param locale The locale object to use for localization of messages.
  132. *
  133. * @exception XNIException Thrown if the parser does not support the
  134. * specified locale.
  135. */
  136. public void setLocale(Locale locale);
  137. /** Return the Locale the XMLGrammarLoader is using. */
  138. public Locale getLocale();
  139. /**
  140. * Sets the error handler.
  141. *
  142. * @param errorHandler The error handler.
  143. */
  144. public void setErrorHandler(XMLErrorHandler errorHandler);
  145. /** Returns the registered error handler. */
  146. public XMLErrorHandler getErrorHandler();
  147. /**
  148. * Sets the entity resolver.
  149. *
  150. * @param entityResolver The new entity resolver.
  151. */
  152. public void setEntityResolver(XMLEntityResolver entityResolver);
  153. /** Returns the registered entity resolver. */
  154. public XMLEntityResolver getEntityResolver();
  155. /**
  156. * Returns a Grammar object by parsing the contents of the
  157. * entity pointed to by source.
  158. *
  159. * @param source the location of the entity which forms
  160. * the starting point of the grammar to be constructed.
  161. * @throws IOException When a problem is encountered reading the entity
  162. * XNIException When a condition arises (such as a FatalError) that requires parsing
  163. * of the entity be terminated.
  164. */
  165. public Grammar loadGrammar(XMLInputSource source)
  166. throws IOException, XNIException;
  167. } // XMLGrammarLoader