]> SALOME platform Git repositories - tools/siman.git/blob - Workspace/Siman/src/org/splat/simer/FileFacade.java
Salome HOME
Siman codebase is refactored. Spring beans are introduced in the context.
[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 public class FileFacade {
12
13     private String  surl;     // URL of the file
14     private String  format;   // Extension of the file
15     private String  comment;  // Short description
16     private String  size;
17     private String  date;
18
19 //  ==============================================================================================================================
20 //  Constructor
21 //  ==============================================================================================================================
22
23     public FileFacade (ConvertsRelation represented) {
24 //  ------------------------------------------------
25       ResourceBundle   custom   = ResourceBundle.getBundle("som", 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.getString("size.format"));     // Locale size display format
30           SimpleDateFormat convert  = new SimpleDateFormat(custom.getString("date.format"));  // Date display format
31
32       surl    = ApplicationSettings.getRepositoryURL() + path;
33       surl    = surl.replaceAll("'", "\\\\'");
34       format  = table[table.length-1].toUpperCase();
35           size    = tostring.format(export.length()/1000);
36           date    = convert.format(represented.getTo().getDate());
37       comment = represented.getDescription();
38       if (comment == null) comment = "";
39     }
40
41 //  ==============================================================================================================================
42 //  Getters
43 //  ==============================================================================================================================
44
45     public String getDate () {
46 //  ------------------------
47       return date;
48     }
49     public String getDescription () {
50 //  -------------------------------
51       return comment;
52     }
53     public String getFormat () {
54 //  -----------------------
55       return format;
56     }
57     public String getSize () {
58 //  ------------------------
59       return size;
60     }
61     public String getURL () {
62 //  -----------------------
63       return surl;
64     }
65 }