KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Id: Externalizer.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.io.Device;
17
18 import java.io.IOException JavaDoc;
19 import java.util.Collection JavaDoc;
20
21 /**
22  * Externalizer Interface
23  * <p/>
24  * The {@link ExternalizeManager} uses a Externalizer to deliver an
25  * external representation of a java object to the output device (usually
26  * an HTTP connection).
27  * A SFrame'es external representation would be HTML, an Images content the
28  * GIF-byte stream, for instance.
29  * <p/>
30  * <p>An Externalizer must be
31  * {@link ExternalizeManager#addExternalizer(Externalizer) registered} at the
32  * {@link ExternalizeManager} of the current
33  * {@link org.wings.session.Session Session} to work seamlessly.
34  * <p/>
35  * Each Externalizer supports one or more classes it is able to externalize.
36  *
37  * @author <a HREF="mailto:mreinsch@to.com">Michael Reinsch</a>
38  * @author <a HREF="mailto:haaf@mercatis.de">Armin Haaf</a>
39  * @version $Revision: 1.3 $
40  */

41 public interface Externalizer {
42     /**
43      * Returns the file extension of the given object. Some (old) browsers use
44      * this information instead of the mime type. This is especially necessary
45      * if delivering anything different than HTML.
46      */

47     String JavaDoc getExtension(Object JavaDoc obj);
48
49     /**
50      * returns the mime type of the given object.
51      */

52     String JavaDoc getMimeType(Object JavaDoc obj);
53
54     /**
55      * Returns the externalized length of this Object. This value is set as
56      * content length in the HttpServletResponse. If it return -1 no content
57      * length is set.
58      */

59     int getLength(Object JavaDoc obj);
60
61     /**
62      * Returns true if the object is final, false if transient. It is used to
63      * control the caching in the browser.
64      */

65     boolean isFinal(Object JavaDoc obj);
66
67     /**
68      * Writes the given object into the given Device.
69      */

70     void write(Object JavaDoc obj, Device out)
71             throws IOException JavaDoc;
72
73     /**
74      * Returns the supported classes. The {@link ExternalizeManager}
75      * chooses the Externalizer (if not specified as parameter) by objects
76      * class.
77      */

78     Class JavaDoc[] getSupportedClasses();
79
80     /**
81      * Returns the supported mime types. The {@link ExternalizeManager}
82      * chooses the Externalizer by mime type (if specified as parameter)
83      */

84     String JavaDoc[] getSupportedMimeTypes();
85
86     /**
87      * Get additional http-headers.
88      * Returns <tt>null</tt>, if there are no additional headers to be set.
89      *
90      * @param obj get headers for this object
91      * @return Set of {@link java.util.Map.Entry} (key-value pairs)
92      */

93     Collection JavaDoc getHeaders(Object JavaDoc obj);
94 }
95
96
97
Popular Tags