root / src / org / gss_project / gss / common / dto / FileBodyDTO.java @ 1206:292dec4eae08
History | View | Annotate | Download (4.2 kB)
1 |
/*
|
---|---|
2 |
* Copyright 2007, 2008, 2009 Electronic Business Systems Ltd.
|
3 |
*
|
4 |
* This file is part of GSS.
|
5 |
*
|
6 |
* GSS is free software: you can redistribute it and/or modify
|
7 |
* it under the terms of the GNU General Public License as published by
|
8 |
* the Free Software Foundation, either version 3 of the License, or
|
9 |
* (at your option) any later version.
|
10 |
*
|
11 |
* GSS is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with GSS. If not, see <http://www.gnu.org/licenses/>.
|
18 |
*/
|
19 |
package org.gss_project.gss.common.dto; |
20 |
|
21 |
import java.io.Serializable; |
22 |
|
23 |
import com.google.gwt.i18n.client.NumberFormat; |
24 |
|
25 |
|
26 |
/**
|
27 |
* @author kman
|
28 |
*
|
29 |
*/
|
30 |
public class FileBodyDTO implements Serializable{ |
31 |
private Long id; |
32 |
private Long fileHeaderId; |
33 |
private int version; |
34 |
private String mimeType; |
35 |
|
36 |
private String originalFilename; |
37 |
private String originalFilenameEncoded; |
38 |
|
39 |
private long fileSize; |
40 |
private AuditInfoDTO auditInfo;
|
41 |
|
42 |
/**
|
43 |
* Retrieve the auditInfo.
|
44 |
*
|
45 |
* @return the auditInfo
|
46 |
*/
|
47 |
public AuditInfoDTO getAuditInfo() {
|
48 |
return auditInfo;
|
49 |
} |
50 |
|
51 |
/**
|
52 |
* Modify the auditInfo.
|
53 |
*
|
54 |
* @param anAuditInfo the auditInfo to set
|
55 |
*/
|
56 |
public void setAuditInfo(AuditInfoDTO anAuditInfo) { |
57 |
auditInfo = anAuditInfo; |
58 |
} |
59 |
|
60 |
/**
|
61 |
* Retrieve the originalFilenameEncoded.
|
62 |
*
|
63 |
* @return the originalFilenameEncoded
|
64 |
*/
|
65 |
public String getOriginalFilenameEncoded() { |
66 |
return originalFilenameEncoded;
|
67 |
} |
68 |
|
69 |
/**
|
70 |
* Modify the originalFilenameEncoded.
|
71 |
*
|
72 |
* @param anOriginalFilenameEncoded the originalFilenameEncoded to set
|
73 |
*/
|
74 |
public void setOriginalFilenameEncoded(String anOriginalFilenameEncoded) { |
75 |
originalFilenameEncoded = anOriginalFilenameEncoded; |
76 |
} |
77 |
|
78 |
/**
|
79 |
* Retrieve the id.
|
80 |
*
|
81 |
* @return the id
|
82 |
*/
|
83 |
public Long getId() { |
84 |
return id;
|
85 |
} |
86 |
|
87 |
/**
|
88 |
* Modify the id.
|
89 |
*
|
90 |
* @param anId the id to set
|
91 |
*/
|
92 |
public void setId(Long anId) { |
93 |
id = anId; |
94 |
} |
95 |
|
96 |
/**
|
97 |
* Retrieve the fileHeaderId.
|
98 |
*
|
99 |
* @return the fileHeaderId
|
100 |
*/
|
101 |
public Long getFileHeaderId() { |
102 |
return fileHeaderId;
|
103 |
} |
104 |
|
105 |
/**
|
106 |
* Modify the fileHeaderId.
|
107 |
*
|
108 |
* @param aFileHeaderId the fileHeaderId to set
|
109 |
*/
|
110 |
public void setFileHeaderId(Long aFileHeaderId) { |
111 |
fileHeaderId = aFileHeaderId; |
112 |
} |
113 |
|
114 |
/**
|
115 |
* Retrieve the version.
|
116 |
*
|
117 |
* @return the version
|
118 |
*/
|
119 |
public int getVersion() { |
120 |
return version;
|
121 |
} |
122 |
|
123 |
/**
|
124 |
* Modify the version.
|
125 |
*
|
126 |
* @param aVersion the version to set
|
127 |
*/
|
128 |
public void setVersion(int aVersion) { |
129 |
version = aVersion; |
130 |
} |
131 |
|
132 |
/**
|
133 |
* Retrieve the mimeType.
|
134 |
*
|
135 |
* @return the mimeType
|
136 |
*/
|
137 |
public String getMimeType() { |
138 |
return mimeType;
|
139 |
} |
140 |
|
141 |
/**
|
142 |
* Modify the mimeType.
|
143 |
*
|
144 |
* @param aMimeType the mimeType to set
|
145 |
*/
|
146 |
public void setMimeType(String aMimeType) { |
147 |
mimeType = aMimeType; |
148 |
} |
149 |
|
150 |
/**
|
151 |
* Retrieve the originalFilename.
|
152 |
*
|
153 |
* @return the originalFilename
|
154 |
*/
|
155 |
public String getOriginalFilename() { |
156 |
return originalFilename;
|
157 |
} |
158 |
|
159 |
/**
|
160 |
* Modify the originalFilename.
|
161 |
*
|
162 |
* @param anOriginalFilename the originalFilename to set
|
163 |
*/
|
164 |
public void setOriginalFilename(String anOriginalFilename) { |
165 |
originalFilename = anOriginalFilename; |
166 |
} |
167 |
|
168 |
/**
|
169 |
* Retrieve the fileSize.
|
170 |
*
|
171 |
* @return the fileSize
|
172 |
*/
|
173 |
public long getFileSize() { |
174 |
return fileSize;
|
175 |
} |
176 |
|
177 |
/**
|
178 |
* Modify the fileSize.
|
179 |
*
|
180 |
* @param aFileSize the fileSize to set
|
181 |
*/
|
182 |
public void setFileSize(long aFileSize) { |
183 |
fileSize = aFileSize; |
184 |
} |
185 |
|
186 |
/**
|
187 |
* Return the file size in a humanly readable form, using SI units to denote
|
188 |
* size information, e.g. 1 KB = 1000 B (bytes).
|
189 |
*
|
190 |
* @return the fileSize
|
191 |
*/
|
192 |
public String getFileSizeAsString() { |
193 |
if (fileSize < 1024) |
194 |
return String.valueOf(fileSize) + " B"; |
195 |
else if (fileSize <= 1024*1024) |
196 |
return getSize(fileSize, 1024D) + " KB"; |
197 |
else if (fileSize <= 1024*1024*1024) |
198 |
return getSize(fileSize,(1024D*1024D)) + " MB"; |
199 |
return getSize(fileSize , (1024D*1024D*1024D)) + " GB"; |
200 |
} |
201 |
|
202 |
private String getSize(Long size, Double division) { |
203 |
Double res = Double.valueOf(size.toString())/division; |
204 |
NumberFormat nf = NumberFormat.getFormat("######.###"); |
205 |
return nf.format(res);
|
206 |
} |
207 |
|
208 |
} |