001// *************************************************************************************************************************** 002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * 003// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * 004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * 005// * with the License. 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 distributed under the License is distributed on an * 010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * 011// * specific language governing permissions and limitations under the License. * 012// *************************************************************************************************************************** 013package org.apache.juneau.utils; 014 015import java.io.*; 016import java.util.*; 017 018/** 019 * Interface for finding classpath resources. 020 * 021 * <p> 022 * Essentially a wrapper around {@link Class#getResourceAsStream(String)}, but with support for looking up resources 023 * with localized names (e.g. <js>"myfile_ja_JP.txt"</js>). 024 * 025 * <p> 026 * The following predefined implementations are provided: 027 * <ul> 028 * <li>{@link ClasspathResourceFinderSimple} - Simple searching of classpath. 029 * <li>{@link ClasspathResourceFinderBasic} - Same as above, but looks in local JVM working directory if resource 030 * can't be found on classpath. 031 * <li>{@link ClasspathResourceFinderRecursive} - Same as above, except if the resource can't be found on the 032 * classpath relative to the base class, recursively searches up the parent class hierarchy. 033 * </ul> 034 * 035 * @deprecated Use {@link org.apache.juneau.cp.ResourceFinder}. 036 */ 037@Deprecated 038public interface ClasspathResourceFinder { 039 040 /** 041 * Represents "no" classpath resource finder. 042 */ 043 public static final class Null implements ClasspathResourceFinder { 044 @Override 045 public InputStream findResource(Class<?> baseClass, String name, Locale locale) throws IOException { 046 throw new NoSuchMethodError(); 047 } 048 } 049 050 /** 051 * Returns the contents of the resource with the specified name. 052 * 053 * @param baseClass 054 * The class to use to retrieve the resource. 055 * @param name The resource name. 056 * See {@link Class#getResource(String)} for format. 057 * @param locale 058 * The locale of the resource to retrieve. 059 * <br>If <jk>null</jk>, won't look for localized file names. 060 * @return The resolved resource contents, or <jk>null</jk> if the resource was not found. 061 * @throws IOException Thrown by underlying stream. 062 */ 063 InputStream findResource(Class<?> baseClass, String name, Locale locale) throws IOException; 064}