KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opencms > defaults > master > CmsMasterMedia


1 /*
2 * File : $Source: /usr/local/cvs/opencms/src-modules/com/opencms/defaults/master/CmsMasterMedia.java,v $
3 * Date : $Date: 2005/06/27 23:22:25 $
4 * Version: $Revision: 1.2 $
5 *
6 * This library is part of OpenCms -
7 * the Open Source Content Mananagement System
8 *
9 * Copyright (C) 2001 The OpenCms Group
10 *
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either
14 * version 2.1 of the License, or (at your option) any later version.
15 *
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
20 *
21 * For further information about OpenCms, please see the
22 * OpenCms Website: http://www.opencms.org
23 *
24 * You should have received a copy of the GNU Lesser General Public
25 * License along with this library; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 */

28
29 package com.opencms.defaults.master;
30
31 import org.opencms.db.CmsDbUtil;
32 import org.opencms.util.CmsUUID;
33
34 /**
35  * An instance of this module describes a modulemedia entry in the database.
36  * It carries a set of data to read and write.
37  *
38  * @author A. Schouten $
39  * $Revision: 1.2 $
40  * $Date: 2005/06/27 23:22:25 $
41  *
42  * @deprecated Will not be supported past the OpenCms 6 release.
43  */

44 public class CmsMasterMedia {
45
46     /** Primary key for the media data */
47     private int m_id;
48
49     /** Foreign key to the media master */
50     private CmsUUID m_masterId;
51
52     /** The position of this media */
53     private int m_position;
54
55     /** The width of this media */
56     private int m_width;
57
58     /** The height of this media */
59     private int m_height;
60
61     /** The size of the media */
62     private int m_size;
63
64     /** The mimetype of the media */
65     private String JavaDoc m_mimetype;
66
67     /** The mediatype of the media */
68     private int m_type;
69
70     /** The title of the media */
71     private String JavaDoc m_title;
72
73     /** The filename of the media */
74     private String JavaDoc m_name;
75
76     /** A description for the media */
77     private String JavaDoc m_description;
78
79     /** The content of the media */
80     private byte[] m_media;
81
82     /** Constant fro media type */
83     public static final int C_MEDIA_TYPE_IMAGE = 0;
84
85     /** Constant fro media type */
86     public static final int C_MEDIA_TYPE_FILE = 1;
87
88     /** The default mimetype */
89     public static final String JavaDoc C_DEFAULT_MIMETYPE = "application/octet-stream";
90
91     //// constructors ////
92
/**
93      * Constructs a new instance with some default values.
94      */

95     public CmsMasterMedia() {
96         m_id = CmsDbUtil.UNKNOWN_ID;
97         m_masterId = CmsUUID.getNullUUID();
98         m_position = CmsDbUtil.UNKNOWN_ID;
99         m_width = CmsDbUtil.UNKNOWN_ID;
100         m_height = CmsDbUtil.UNKNOWN_ID;
101         m_size = CmsDbUtil.UNKNOWN_ID;
102         m_mimetype = C_DEFAULT_MIMETYPE;
103         m_type = CmsDbUtil.UNKNOWN_ID;
104         m_title = "";
105         m_name = "";
106         m_description ="";
107         m_media = new byte[0];
108     }
109
110     /**
111      * Constructs a new instance with some default values.
112      */

113     public CmsMasterMedia(int position, int width, int height, int size,
114                           String JavaDoc mimetype, int type, String JavaDoc title, String JavaDoc name,
115                           String JavaDoc description, byte[] media) {
116         this();
117         m_position = position;
118         m_width = width;
119         m_height = height;
120         m_size = size;
121         m_mimetype = mimetype;
122         m_type = type;
123         m_title = title;
124         m_name = name;
125         m_description = description;
126         m_media = media;
127     }
128
129     /**
130      * Constructs a new instance with some default values.
131      */

132     public CmsMasterMedia(int id, CmsUUID masterId, int position, int width,
133                           int height, int size, String JavaDoc mimetype, int type,
134                           String JavaDoc title, String JavaDoc name, String JavaDoc description,
135                           byte[] media) {
136         this(position, width, height, size, mimetype, type, title, name,
137              description, media);
138         m_id = id;
139         m_masterId = masterId;
140     }
141
142     //// get and set methods ////
143

144     public int getId() {
145         return m_id;
146     }
147
148     public CmsUUID getMasterId() {
149         return m_masterId;
150     }
151
152     public int getPosition() {
153         return m_position;
154     }
155
156     public int getWidth() {
157         return m_width;
158     }
159
160     public int getHeight() {
161         return m_height;
162     }
163
164     public int getSize() {
165         return m_size;
166     }
167
168     public String JavaDoc getMimetype() {
169         return m_mimetype;
170     }
171
172     public int getType() {
173         return m_type;
174     }
175
176     public String JavaDoc getTitle() {
177         return m_title;
178     }
179
180     public String JavaDoc getName() {
181         return m_name;
182     }
183
184     public String JavaDoc getDescription() {
185         return m_description;
186     }
187
188     public byte[] getMedia() {
189         return m_media;
190     }
191
192     /**
193      * Never set this on yourself!
194      * It will be computed by the mastermodule
195      */

196     public void setId(int id) {
197         m_id = id;
198     }
199
200     /**
201      * Never set this on yourself!
202      * It will be computed by the mastermodule
203      */

204     public void setMasterId(CmsUUID masterId) {
205         m_masterId = masterId;
206     }
207
208     public void setPosition(int pos) {
209         m_position = pos;
210     }
211
212     public void setWidth(int width) {
213         m_width = width;
214     }
215
216     public void setHeight(int height) {
217         m_height = height;
218     }
219
220     public void setSize(int size) {
221         m_size = size;
222     }
223
224     public void setMimetype(String JavaDoc mimetype) {
225         m_mimetype = mimetype;
226     }
227
228     public void setType(int type) {
229         m_type = type;
230     }
231
232     public void setTitle(String JavaDoc title) {
233         m_title = title;
234     }
235
236     public void setName(String JavaDoc name) {
237         m_name = name;
238     }
239
240     public void setDescription(String JavaDoc desc) {
241         m_description = desc;
242     }
243
244     public void setMedia(byte[] media) {
245         m_media = media;
246         // now set the size
247
setSize(m_media.length);
248     }
249
250     /**
251      * Returns a string representation of this instance.
252      * Can be used for debugging.
253      */

254     public String JavaDoc toString() {
255         StringBuffer JavaDoc retValue = new StringBuffer JavaDoc();
256         retValue
257             .append(getClass().getName() + "{")
258             .append("m_id:"+m_id+",")
259             .append("m_masterId:"+m_masterId+",")
260             .append("m_position:"+m_position+",")
261             .append("m_width:"+m_width+",")
262             .append("m_height:"+m_height+",")
263             .append("m_size:"+m_size+",")
264             .append("m_mimetype:"+m_mimetype+",")
265             .append("m_type:"+m_type+",")
266             .append("m_title:"+m_title+",")
267             .append("m_name:"+m_name+",")
268             .append("m_id:"+m_id+",")
269             .append("m_description:"+m_description+"}");
270         return retValue.toString();
271     }
272 }
Popular Tags