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 javax.faces.application;
20  
21  import java.io.IOException;
22  import java.io.InputStream;
23  import java.net.URL;
24  import java.util.Map;
25  
26  import javax.faces.context.FacesContext;
27  
28  /**
29   * @since 2.0
30   */
31  public abstract class Resource extends ViewResource
32  {
33      /**
34       * This constant is used as the key in the component attribute map of a composite component to 
35       * associate the component with its <code>Resource</code> instance.
36       */
37      public static final String COMPONENT_RESOURCE_KEY = "javax.faces.application.Resource.ComponentResource";
38  
39      private String _contentType;
40      private String _libraryName;
41      private String _resourceName;
42  
43      public String getContentType()
44      {
45          return _contentType;
46      }
47      
48      public abstract InputStream getInputStream() throws IOException;
49  
50      public String getLibraryName()
51      {
52          return _libraryName;
53      }
54      
55      public abstract String getRequestPath();
56  
57      public String getResourceName()
58      {
59          return _resourceName;
60      }
61      
62      public abstract Map<String, String> getResponseHeaders();
63      
64      public abstract URL getURL();
65  
66      public void setContentType(String contentType)
67      {
68          _contentType = contentType;
69      }
70  
71      public void setLibraryName(String libraryName)
72      {
73          _libraryName = libraryName;
74      }
75  
76      public void setResourceName(String resourceName)
77      {
78          if (resourceName == null)
79          {
80              throw new NullPointerException();
81          }
82          _resourceName = resourceName;
83      }
84      
85      @Override
86      public String toString()
87      {
88          return getRequestPath();
89      }
90      
91      public abstract boolean userAgentNeedsUpdate(FacesContext context);
92  }