1 /* 2 * <license> 3 * Copyright (c) 2003-2004, Sun Microsystems, Inc. 4 * Copyright (c) 2022-2022, Web-Legacy 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions are met: 9 * 10 * * Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * * Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * * Neither the name of Sun Microsystems, Inc. nor the names of its 16 * contributors may be used to endorse or promote products derived from 17 * this software without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 * </license> 30 */ 31 32 package com.sun.tlddoc; 33 34 import java.io.IOException; 35 import java.io.InputStream; 36 import javax.xml.parsers.DocumentBuilder; 37 import javax.xml.transform.TransformerException; 38 import org.w3c.dom.Document; 39 import org.xml.sax.SAXException; 40 41 /** 42 * Base class for a tag library source. Different tag libraries will 43 * locate resources, such as tag files, in different ways. 44 * 45 * @author mroth 46 */ 47 public abstract class TagLibrary implements AutoCloseable { 48 49 /** 50 * Returns a String that the user would recognize as a location for this 51 * tag library. 52 * 53 * @return a String that the user would recognize as a location for this 54 * tag library 55 */ 56 public abstract String getPathDescription(); 57 58 /** 59 * Returns a Document of the effective tag library descriptor for this 60 * tag library. This might come from a file or be implicitly generated. 61 * 62 * @param documentBuilder {@code DocumentBuilder} to obtain DOM Document for 63 * creating an XML-document. 64 * 65 * @return created XML-Document 66 * 67 * @throws IOException if an I/O error has occurred 68 * @throws SAXException If any parse errors occur 69 * @throws TransformerException If an unrecoverable error occurs 70 * during the course of the transformation 71 */ 72 public abstract Document getTLDDocument( DocumentBuilder documentBuilder ) 73 throws IOException, SAXException, TransformerException; 74 75 /** 76 * Returns an input stream for the given resource, or {@code null} if the 77 * resource could not be found. 78 * 79 * @param path the path to the resource 80 * 81 * @return the input stream for the given resource or {@code null} if the 82 * resource could not be found 83 * 84 * @throws IOException if an I/O error has occurred 85 */ 86 public abstract InputStream getResource( String path ) 87 throws IOException; 88 89 /** 90 * {@inheritDoc} 91 */ 92 @Override 93 public abstract void close() throws IOException; 94 }