Salome HOME
0fd141d2bdd4f0ae20543ed261ae943b4468630f
[tools/siman.git] / Workspace / Siman / src / org / splat / simer / FileFacade.java
1 package org.splat.simer;
2
3 import java.io.File;
4 import java.text.DecimalFormat;
5 import java.text.SimpleDateFormat;
6 import java.util.ResourceBundle;
7
8 import org.splat.dal.bo.som.ConvertsRelation;
9
10 public class FileFacade {
11
12         private String surl; // URL of the file
13         private final String format; // Extension of the file
14         private String comment; // Short description
15         private final String size;
16         private final String date;
17
18         // ==============================================================================================================================
19         // Constructor
20         // ==============================================================================================================================
21
22         public FileFacade(final ConvertsRelation represented,
23                         final ApplicationSettings applicationSettings) {
24                 ResourceBundle custom = ResourceBundle.getBundle("som",
25                                 applicationSettings.getCurrentLocale());
26                 File export = represented.getTo().asFile();
27                 String path = export.getPath();
28                 String[] table = path.split("\\x2E");
29                 DecimalFormat tostring = new DecimalFormat(custom
30                                 .getString("size.format")); // Locale size display format
31                 SimpleDateFormat convert = new SimpleDateFormat(custom
32                                 .getString("date.format")); // Date display format
33
34                 surl = applicationSettings.getRepositoryURL() + path;
35                 surl = surl.replaceAll("'", "\\\\'");
36                 format = table[table.length - 1].toUpperCase();
37                 size = tostring.format(export.length() / 1000);
38                 date = convert.format(represented.getTo().getDate());
39                 comment = represented.getDescription();
40                 if (comment == null) {
41                         comment = "";
42                 }
43         }
44
45         // ==============================================================================================================================
46         // Getters
47         // ==============================================================================================================================
48
49         public String getDate() {
50                 return date;
51         }
52
53         public String getDescription() {
54                 return comment;
55         }
56
57         public String getFormat() {
58                 return format;
59         }
60
61         public String getSize() {
62                 return size;
63         }
64
65         public String getURL() {
66                 return surl;
67         }
68 }