]> SALOME platform Git repositories - tools/siman.git/blob - Workspace/Siman/src/org/splat/simer/FileFacade.java
Salome HOME
Some PMD rules are satisfied.
[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 /**
11  * File representation class.
12  */
13 public class FileFacade {
14
15         private transient String _surl; // URL of the file
16         private transient final String _format; // Extension of the file
17         private transient String _comment; // Short description
18         private transient final String _size;
19         private transient final String _date;
20
21         // ==============================================================================================================================
22         // Constructor
23         // ==============================================================================================================================
24
25         public FileFacade(final ConvertsRelation represented,
26                         final ApplicationSettings applicationSettings) {
27                 ResourceBundle custom = ResourceBundle.getBundle("som",
28                                 applicationSettings.getCurrentLocale());
29                 File export = represented.getTo().asFile();
30                 String path = export.getPath();
31                 String[] table = path.split("\\x2E");
32                 DecimalFormat tostring = new DecimalFormat(custom
33                                 .getString("size.format")); // Locale size display format
34                 SimpleDateFormat convert = new SimpleDateFormat(custom
35                                 .getString("date.format"), applicationSettings
36                                 .getCurrentLocale()); // Date display format
37
38                 _surl = applicationSettings.getRepositoryURL() + path;
39                 _surl = _surl.replaceAll("'", "\\\\'");
40                 _format = table[table.length - 1].toUpperCase();
41                 _size = tostring.format(export.length() / 1000);
42                 _date = convert.format(represented.getTo().getDate());
43                 _comment = represented.getDescription();
44                 if (_comment == null) {
45                         _comment = "";
46                 }
47         }
48
49         // ==============================================================================================================================
50         // Getters
51         // ==============================================================================================================================
52
53         public String getDate() {
54                 return _date;
55         }
56
57         public String getDescription() {
58                 return _comment;
59         }
60
61         public String getFormat() {
62                 return _format;
63         }
64
65         public String getSize() {
66                 return _size;
67         }
68
69         public String getURL() {
70                 return _surl;
71         }
72 }