KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > wings > externalizer > DynamicResourceExternalizer


1 /*
2  * $Id: DynamicResourceExternalizer.java,v 1.4 2004/12/01 07:54:08 hengels Exp $
3  * Copyright 2000,2005 wingS development team.
4  *
5  * This file is part of wingS (http://www.j-wings.org).
6  *
7  * wingS is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU Lesser General Public License
9  * as published by the Free Software Foundation; either version 2.1
10  * of the License, or (at your option) any later version.
11  *
12  * Please see COPYING for the complete licence.
13  */

14 package org.wings.externalizer;
15
16 import org.wings.Renderable;
17 import org.wings.io.Device;
18 import org.wings.resource.DynamicResource;
19
20 import java.io.IOException JavaDoc;
21 import java.util.Collection JavaDoc;
22
23 /**
24  * @author <a HREF="mailto:engels@mercatis.de">Holger Engels</a>
25  * @version $Revision: 1.4 $
26  */

27 public class DynamicResourceExternalizer implements Externalizer {
28
29     private static final Class JavaDoc[] SUPPORTED_CLASSES = {DynamicResource.class};
30
31     public static final DynamicResourceExternalizer SHARED_INSTANCE = new DynamicResourceExternalizer();
32
33     public String JavaDoc getExtension(Object JavaDoc obj) {
34         if (obj != null)
35             return ((DynamicResource) obj).getExtension();
36         else
37             return "";
38     }
39
40     public String JavaDoc getMimeType(Object JavaDoc obj) {
41         if (obj != null)
42             return ((DynamicResource) obj).getMimeType();
43         else
44             return "unknown";
45     }
46
47     public int getLength(Object JavaDoc obj) {
48         return -1;
49     }
50
51     public boolean isFinal(Object JavaDoc obj) {
52         return true;
53     }
54
55     public String JavaDoc getEpoch(Object JavaDoc obj) {
56         return ((DynamicResource) obj).getEpoch();
57     }
58
59     public void write(Object JavaDoc obj, Device out)
60             throws IOException JavaDoc {
61         ((Renderable) obj).write(out);
62     }
63
64     public Class JavaDoc[] getSupportedClasses() {
65         return SUPPORTED_CLASSES;
66     }
67
68     public String JavaDoc[] getSupportedMimeTypes() {
69         return null;
70     }
71
72     public Collection JavaDoc getHeaders(Object JavaDoc obj) {
73         if (obj != null)
74             return ((DynamicResource) obj).getHeaders();
75         else
76             return null;
77     }
78 }
79
80
81
Popular Tags