View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.myfaces.trinidad.share.io;
20  
21  import java.io.IOException;
22  
23  
24  
25  /**
26   * NameResolvers are responsible for converting string names
27   * into InputStreamProviders, which encapsulate a remote file.
28   * Implementations exist that support using URLs, Files, Class
29   * resources, and the Servlet API to locate files, but other APIs
30   * may be substituted.
31   * <p>
32   * In some cases, the resolved target file may have need to
33   * locate support files of its own (like imported css files).  Since those support files should
34   * be looked for relative to the target file, NameResolver supports
35   * creating new relative NameResolvers.
36   * @version $Name:  $ ($Revision: adfrt/faces/adf-faces-impl/src/main/java/oracle/adfinternal/view/faces/share/io/NameResolver.java#0 $) $Date: 10-nov-2005.19:00:09 $
37   */
38  public interface NameResolver
39  {
40    /**
41     * Given a name, returns an InputStreamProvider.  This
42     * function should never return null - if the target
43     * cannot be resolved, throw an IOException.
44     * @param name the name of the target
45     */
46    public InputStreamProvider getProvider(String name) throws IOException;
47  
48    /**
49     * Return the new NameResolver that should be used to resolve
50     * names relative to a given name. For example, if a css file has an @import,
51     * you need to look for the imported file relative to the file. This function should never
52     * return null - if the target cannot be resolved, return a
53     * resolver that can only support absolute names.
54     * @param name the name of the target
55     */
56    public NameResolver        getResolver(String name);
57  }
58