01: /*
02: * Copyright 2000,2005 wingS development team.
03: *
04: * This file is part of wingS (http://wingsframework.org).
05: *
06: * wingS is free software; you can redistribute it and/or modify
07: * it under the terms of the GNU Lesser General Public License
08: * as published by the Free Software Foundation; either version 2.1
09: * of the License, or (at your option) any later version.
10: *
11: * Please see COPYING for the complete licence.
12: */
13: package org.wings.externalizer;
14:
15: import org.wings.Resource;
16: import org.wings.resource.HttpHeader;
17: import org.wings.resource.ResourceNotFoundException;
18: import org.wings.io.Device;
19:
20: import java.io.IOException;
21: import java.util.Collection;
22:
23: /**
24: * Externalizer for Resources.
25: */
26: public class ResourceExternalizer implements Externalizer<Resource> {
27:
28: private static final Class[] SUPPORTED_CLASSES = { Resource.class };
29:
30: public static final ResourceExternalizer SHARED_INSTANCE = new ResourceExternalizer();
31:
32: public String getId(Resource obj) {
33: return null;
34: }
35:
36: public String getExtension(Resource obj) {
37: return obj.getExtension();
38: }
39:
40: public String getMimeType(Resource obj) {
41: return obj.getMimeType();
42: }
43:
44: public int getLength(Resource obj) {
45: return obj.getLength();
46: }
47:
48: public boolean isFinal(Resource obj) {
49: return false;
50: }
51:
52: public void write(Object obj, Device out) throws IOException,
53: ResourceNotFoundException {
54: ((Resource) obj).write(out);
55: }
56:
57: public Class[] getSupportedClasses() {
58: return SUPPORTED_CLASSES;
59: }
60:
61: public String[] getSupportedMimeTypes() {
62: return null;
63: }
64:
65: public Collection<HttpHeader> getHeaders(Resource obj) {
66: return obj.getHeaders();
67: }
68:
69: }
|