org.ajax4jsf.framework.resource.StaticResource Maven / Gradle / Ivy
/**
* Licensed under the Common Development and Distribution License,
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.sun.com/cddl/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package org.ajax4jsf.framework.resource;
import java.io.InputStream;
import javax.faces.context.FacesContext;
/**
* @author [email protected] (latest modification by $Author: alexsmirnov $)
* @version $Revision: 1.4 $ $Date: 2006/09/20 15:09:37 $
*
*/
public class StaticResource extends InternetResourceBase {
private String path;
private byte[] resourceData = null;
/**
*
*/
public StaticResource() {
super();
// TODO Auto-generated constructor stub
}
public StaticResource(String path){
this.path = path;
setCacheable(true);
}
/* (non-Javadoc)
* @see org.ajax4jsf.framework.resource.InternetResourceBase#getResourceAsStream(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
*/
public InputStream getResourceAsStream(ResourceContext context) {
return context.getResourceAsStream(path);
}
/* (non-Javadoc)
* @see org.ajax4jsf.framework.resource.InternetResourceBase#isCacheable()
*/
public boolean isCacheable() {
// TODO Auto-generated method stub
return true;
}
public String getUri(FacesContext context, Object data) {
// perform all encodings, suitable for JSF specification.
String src = context.getApplication().getViewHandler().getResourceURL(context,path);
return context.getExternalContext().encodeResourceURL(src);
}
public void encode(FacesContext context, Object data) {
// TODO Auto-generated method stub
}
/**
* @return the path
*/
public String getPath() {
return path;
}
/**
* @param path the path to set
*/
public void setPath(String path) {
this.path = path;
}
}