KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Id: StaticResourceExternalizer.java,v 1.3 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.StaticResource;
18 import org.wings.io.Device;
19
20 import java.io.IOException JavaDoc;
21 import java.util.Collection JavaDoc;
22
23 /**
24  * @author <a HREF="mailto:haaf@mercatis.de">Armin Haaf</a>
25  * @author <a HREF="mailto:mreinsch@to.com">Michael Reinsch</a>
26  * @version $Revision: 1.3 $
27  */

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