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.io.Device;
16: import org.wings.resource.DynamicResource;
17: import org.wings.resource.HttpHeader;
18: import org.wings.resource.ResourceNotFoundException;
19:
20: import java.io.IOException;
21: import java.util.Collection;
22:
23: /**
24: * @author <a href="mailto:engels@mercatis.de">Holger Engels</a>
25: */
26: public class DynamicResourceExternalizer implements
27: Externalizer<DynamicResource> {
28:
29: private static final Class[] SUPPORTED_CLASSES = { DynamicResource.class };
30:
31: public static final DynamicResourceExternalizer SHARED_INSTANCE = new DynamicResourceExternalizer();
32:
33: public String getId(DynamicResource obj) {
34: return null;
35: }
36:
37: public String getExtension(DynamicResource obj) {
38: if (obj != null)
39: return obj.getExtension();
40: else
41: return "";
42: }
43:
44: public String getMimeType(DynamicResource obj) {
45: if (obj != null) {
46: return obj.getMimeType();
47: } else
48: return "unknown";
49: }
50:
51: public int getLength(DynamicResource obj) {
52: return -1;
53: }
54:
55: public boolean isFinal(DynamicResource obj) {
56: return false;
57: }
58:
59: public String getEventEpoch(DynamicResource obj) {
60: return obj.getFrame().getEventEpoch();
61: }
62:
63: public void write(Object obj, Device out) throws IOException,
64: ResourceNotFoundException {
65: ((DynamicResource) obj).write(out);
66: }
67:
68: public Class[] getSupportedClasses() {
69: return SUPPORTED_CLASSES;
70: }
71:
72: public String[] getSupportedMimeTypes() {
73: return null;
74: }
75:
76: public Collection<HttpHeader> getHeaders(DynamicResource obj) {
77: if (obj != null)
78: return obj.getHeaders();
79: else
80: return null;
81: }
82: }
|