org.wings.externalizer.DynamicResourceExternalizer Maven / Gradle / Ivy
The newest version!
/*
* Copyright 2000,2005 wingS development team.
*
* This file is part of wingS (http://wingsframework.org).
*
* wingS is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
*
* Please see COPYING for the complete licence.
*/
package org.wings.externalizer;
import org.wings.io.Device;
import org.wings.resource.DynamicResource;
import org.wings.resource.HttpHeader;
import org.wings.resource.ResourceNotFoundException;
import java.io.IOException;
import java.util.Collection;
/**
* @author Holger Engels
*/
public class DynamicResourceExternalizer implements Externalizer {
private static final Class[] SUPPORTED_CLASSES = {DynamicResource.class};
public static final DynamicResourceExternalizer SHARED_INSTANCE = new DynamicResourceExternalizer();
@Override
public String getId(DynamicResource obj) {
return null;
}
@Override
public String getExtension(DynamicResource obj) {
if (obj != null)
return obj.getExtension();
else
return "";
}
@Override
public String getMimeType(DynamicResource obj) {
if (obj != null) {
return obj.getMimeType();
} else
return "unknown";
}
@Override
public int getLength(DynamicResource obj) {
return -1;
}
@Override
public boolean isFinal(DynamicResource obj) {
return false;
}
public static String getEventEpoch(DynamicResource obj) {
return obj.getFrame().getEventEpoch();
}
@Override
public void write(Object obj, Device out) throws IOException, ResourceNotFoundException {
((DynamicResource)obj).write(out);
}
@Override
public Class[] getSupportedClasses() {
return SUPPORTED_CLASSES;
}
@Override
public String[] getSupportedMimeTypes() {
return null;
}
@Override
public Collection getHeaders(DynamicResource obj) {
if (obj != null)
return obj.getHeaders();
else
return null;
}
}