KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Id: ResourceExternalizer.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.Resource;
17 import org.wings.io.Device;
18
19 import java.io.IOException JavaDoc;
20 import java.util.Collection JavaDoc;
21
22 /**
23  * @author armin
24  * created at 24.02.2004 10:49:32
25  */

26 public class ResourceExternalizer implements Externalizer {
27
28     private static final Class JavaDoc[] SUPPORTED_CLASSES = {Resource.class};
29
30     public static final ResourceExternalizer SHARED_INSTANCE = new ResourceExternalizer();
31
32     public String JavaDoc getExtension(Object JavaDoc obj) {
33         return ((Resource) obj).getExtension();
34     }
35
36     public String JavaDoc getMimeType(Object JavaDoc obj) {
37         return ((Resource) obj).getMimeType();
38     }
39
40     public int getLength(Object JavaDoc obj) {
41         return ((Resource) obj).getLength();
42     }
43
44     public boolean isFinal(Object JavaDoc obj) {
45         return false;
46     }
47
48     public void write(Object JavaDoc obj, Device out)
49             throws IOException JavaDoc {
50         ((Resource) obj).write(out);
51     }
52
53     public Class JavaDoc[] getSupportedClasses() {
54         return SUPPORTED_CLASSES;
55     }
56
57     public String JavaDoc[] getSupportedMimeTypes() {
58         return null;
59     }
60
61     public Collection JavaDoc getHeaders(Object JavaDoc obj) {
62         return ((Resource) obj).getHeaders();
63     }
64
65 }
66
Popular Tags