KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > infoglue > cms > webservices > elements > AbstractAttachment


1 /* ===============================================================================
2 *
3 * Part of the InfoGlue Content Management Platform (www.infoglue.org)
4 *
5 * ===============================================================================
6 *
7 * Copyright (C)
8 *
9 * This program is free software; you can redistribute it and/or modify it under
10 * the terms of the GNU General Public License version 2, as published by the
11 * Free Software Foundation. See the file LICENSE.html for more information.
12 *
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY, including the implied warranty of MERCHANTABILITY or FITNESS
15 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * this program; if not, write to the Free Software Foundation, Inc. / 59 Temple
19 * Place, Suite 330 / Boston, MA 02111-1307 / USA.
20 *
21 * ===============================================================================
22 */

23 package org.infoglue.cms.webservices.elements;
24
25 public abstract class AbstractAttachment implements Attachment
26 {
27     /**
28      *
29      */

30     private byte[] bytes;
31
32     /**
33      *
34      */

35     private String JavaDoc name;
36     /**
37      *
38      */

39     private String JavaDoc fileName;
40     /**
41      *
42      */

43     private String JavaDoc filePath;
44
45     /**
46      *
47      */

48     private String JavaDoc contentType;
49     
50     /**
51      *
52      */

53     protected AbstractAttachment()
54     {
55     }
56     
57     /**
58      *
59      */

60     protected AbstractAttachment(final String JavaDoc name, final String JavaDoc fileName, final String JavaDoc filePath, final String JavaDoc contentType, final byte[] bytes)
61     {
62         super();
63         this.name = name;
64         
65         if(fileName != null && !fileName.equals(""))
66             this.fileName = fileName;
67         else
68             this.fileName = "Unknown";
69         
70         if(filePath != null && !filePath.equals(""))
71             this.filePath = filePath;
72         else
73             this.filePath = "Unknown";
74         
75         this.contentType = contentType;
76         this.bytes = bytes;
77     }
78     
79     /**
80      *
81      */

82     public byte[] getBytes()
83     {
84         return bytes;
85     }
86
87     /**
88      *
89      */

90     public void setBytes(final byte[] bytes)
91     {
92         this.bytes = bytes;
93     }
94     
95     /**
96      *
97      */

98     public String JavaDoc getName()
99     {
100         return name;
101     }
102
103     /**
104      *
105      */

106     public void setName(final String JavaDoc name)
107     {
108         this.name = name;
109     }
110
111     /**
112      *
113      */

114     public int getSize()
115     {
116         return getBytes().length;
117     }
118
119     /**
120      *
121      */

122     public String JavaDoc getContentType()
123     {
124         return contentType;
125     }
126
127     /**
128      *
129      */

130     public void setContentType(final String JavaDoc contentType)
131     {
132         this.contentType = contentType;
133     }
134
135     /**
136      *
137      */

138     public String JavaDoc toString()
139     {
140         return "<" + getSize() + "," + getName() + "," + getContentType() + ">";
141     }
142
143     public String JavaDoc getFileName()
144     {
145         return fileName;
146     }
147
148     public void setFileName(String JavaDoc fileName)
149     {
150         this.fileName = fileName;
151     }
152
153     public String JavaDoc getFilePath()
154     {
155         return filePath;
156     }
157
158     public void setFilePath(String JavaDoc filePath)
159     {
160         this.filePath = filePath;
161     }
162 }
163
Popular Tags