KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ivata > groupware > business > drive > file > FileContentDO


1 /*
2  * Copyright (c) 2001 - 2005 ivata limited.
3  * All rights reserved.
4  * -----------------------------------------------------------------------------
5  * ivata groupware may be redistributed under the GNU General Public
6  * License as published by the Free Software Foundation;
7  * version 2 of the License.
8  *
9  * These programs are free software; you can redistribute them and/or
10  * modify them under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; version 2 of the License.
12  *
13  * These programs are distributed in the hope that they will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  *
17  * See the GNU General Public License in the file LICENSE.txt for more
18  * details.
19  *
20  * If you would like a copy of the GNU General Public License write to
21  *
22  * Free Software Foundation, Inc.
23  * 59 Temple Place - Suite 330
24  * Boston, MA 02111-1307, USA.
25  *
26  *
27  * To arrange commercial support and licensing, contact ivata at
28  * http://www.ivata.com/contact.jsp
29  * -----------------------------------------------------------------------------
30  * $Log: FileContentDO.java,v $
31  * Revision 1.3 2005/04/10 18:47:42 colinmacleod
32  * Changed i tag to em and b tag to strong.
33  *
34  * Revision 1.2 2005/04/09 17:20:00 colinmacleod
35  * Changed copyright text to GPL v2 explicitly.
36  *
37  * Revision 1.1.1.1 2005/03/10 17:51:13 colinmacleod
38  * Restructured ivata op around Hibernate/PicoContainer.
39  * Renamed ivata groupware.
40  *
41  * Revision 1.4 2004/07/13 20:00:13 colinmacleod
42  * Moved project to POJOs from EJBs.
43  * Applied PicoContainer to services layer (replacing session EJBs).
44  * Applied Hibernate to persistence layer (replacing entity EJBs).
45  *
46  * Revision 1.3 2004/03/21 21:16:26 colinmacleod
47  * Shortened name to ivata op.
48  *
49  * Revision 1.2 2004/02/01 22:07:30 colinmacleod
50  * Added full names to author tags
51  *
52  * Revision 1.1.1.1 2004/01/27 20:58:27 colinmacleod
53  * Moved ivata op to sourceforge.
54  *
55  * Revision 1.2 2003/10/15 14:05:21 colin
56  * fixing for XDoclet
57  *
58  * Revision 1.4 2003/02/25 14:38:13 colin
59  * implemented setModified methods on entity beans thro IvataEntityBean superclass
60  * -----------------------------------------------------------------------------
61  */

62 package com.ivata.groupware.business.drive.file;
63
64 import java.io.IOException JavaDoc;
65 import java.io.ObjectInputStream JavaDoc;
66 import java.io.ObjectOutputStream JavaDoc;
67 import java.io.Serializable JavaDoc;
68
69 import com.ivata.mask.util.SerializedByteArray;
70
71
72 /**
73  * <p>Encapsulates a file (content & mime type) for
74  * download purposes.</p>
75  *
76  * @since 2002-11-10
77  * @author Colin MacLeod
78  * <a HREF='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
79  * @version $Revision: 1.3 $
80  */

81 public class FileContentDO implements Serializable JavaDoc {
82     /**
83      * <p>The mime-type of the content.</p>
84      */

85     private String JavaDoc mimeType;
86
87     /**
88      * <p>Stores the content of the file, in a byte array which
89      * can be passed from server-side to client-side.</p>
90      */

91     private SerializedByteArray content;
92
93     /**
94      * <p>Intitialize the content and mime type for this DO.
95      * These class attributes are <em>immutable<em> - once they have been
96      * set by
97      * this constrctor, you can't change them.</p>
98      *
99      * @param content see {@link #getContent}.
100      * @param mimeType see {@link #getMimeType}.
101      *
102      * @roseuid 3E228C3701FD
103      */

104     public FileContentDO(SerializedByteArray content, String JavaDoc mimeType) {
105         this.content = content;
106         this.mimeType = mimeType;
107     }
108
109     /**
110      * <p>Serialize the object from the input stream provided.</p>
111      *
112      * @param ois the input stream to serialize the object from
113      * @throws IOException thrown by
114      * <code>ObjectInputStream.defaultReadObject()</code>.
115      * @throws ClassNotFoundException thrown by
116      * <code>ObjectInputStream.defaultReadObject()</code>.
117      *
118      * @roseuid 3E228C3701F7
119      */

120     private void readObject(final ObjectInputStream JavaDoc ois)
121         throws ClassNotFoundException JavaDoc, IOException JavaDoc {
122         ois.defaultReadObject();
123     }
124
125     /**
126      * <p>Serialize the object to the output stream provided.</p>
127      *
128      * @param oos the output stream to serialize the object to
129      * @throws IOException thrown by
130      * <code>ObjectOutputStream.defaultWriteObject()</code>
131      *
132      * @roseuid 3E228C3701F9
133      */

134     private void writeObject(final ObjectOutputStream JavaDoc oos) throws IOException JavaDoc {
135         oos.defaultWriteObject();
136     }
137
138     /**
139      * <p>Get the content of the file.</p>
140      *
141      * @return content of the in a byte array object which can be passed
142      * from
143      * server-side to client-side (is serialized).
144      *
145      * @roseuid 3E228C3701FB
146      */

147     public final SerializedByteArray getContent() {
148         return content;
149     }
150
151     /**
152      * <p>Get the mime type of the file content.</p>
153      *
154      * @return clear-text mime type of the file content.
155      *
156      * @roseuid 3E228C3701FC
157      */

158     public final java.lang.String JavaDoc getMimeType() {
159         return mimeType;
160     }
161 }
162
Popular Tags