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   * @author Simon Lessard (latest modification by $Author: bommel $)
30   * @version $Revision: 1187701 $ $Date: 2011-10-22 12:21:54 +0000 (Sat, 22 Oct 2011) $
31   * 
32   * @since 2.0
33   */
34  public abstract class Resource
35  {
36      /**
37       * This constant is used as the key in the component attribute map of a composite component to 
38       * associate the component with its <code>Resource</code> instance.
39       */
40      public static final String COMPONENT_RESOURCE_KEY = "javax.faces.application.Resource.ComponentResource";
41  
42      private String _contentType;
43      private String _libraryName;
44      private String _resourceName;
45  
46      public String getContentType()
47      {
48          return _contentType;
49      }
50      
51      public abstract InputStream getInputStream() throws IOException;
52  
53      public String getLibraryName()
54      {
55          return _libraryName;
56      }
57      
58      public abstract String getRequestPath();
59  
60      public String getResourceName()
61      {
62          return _resourceName;
63      }
64      
65      public abstract Map<String, String> getResponseHeaders();
66      
67      public abstract URL getURL();
68  
69      public void setContentType(String contentType)
70      {
71          _contentType = contentType;
72      }
73  
74      public void setLibraryName(String libraryName)
75      {
76          _libraryName = libraryName;
77      }
78  
79      public void setResourceName(String resourceName)
80      {
81          if (resourceName == null)
82          {
83              throw new NullPointerException();
84          }
85          _resourceName = resourceName;
86      }
87      
88      @Override
89      public String toString()
90      {
91          return getRequestPath();
92      }
93      
94      public abstract boolean userAgentNeedsUpdate(FacesContext context);
95  }