Salome HOME
SIMAN Eclipse workspace first version
[tools/siman.git] / Workspace / Siman / src / org / splat / simer / FileFacade.java
diff --git a/Workspace/Siman/src/org/splat/simer/FileFacade.java b/Workspace/Siman/src/org/splat/simer/FileFacade.java
new file mode 100644 (file)
index 0000000..41daac8
--- /dev/null
@@ -0,0 +1,65 @@
+package org.splat.simer;
+
+import java.io.File;
+import java.text.DecimalFormat;
+import java.text.SimpleDateFormat;
+import java.util.ResourceBundle;
+
+import org.splat.som.ConvertsRelation;
+
+
+public class FileFacade {
+
+    private String  surl;     // URL of the file
+    private String  format;   // Extension of the file
+    private String  comment;  // Short description
+    private String  size;
+    private String  date;
+
+//  ==============================================================================================================================
+//  Constructor
+//  ==============================================================================================================================
+
+    public FileFacade (ConvertsRelation represented) {
+//  ------------------------------------------------
+      ResourceBundle   custom   = ResourceBundle.getBundle("som", ApplicationSettings.getCurrentLocale());
+      File             export   = represented.getTo().asFile();
+      String           path     = export.getPath();
+      String[]         table    = path.split("\\x2E");
+         DecimalFormat    tostring = new DecimalFormat(custom.getString("size.format"));     // Locale size display format
+         SimpleDateFormat convert  = new SimpleDateFormat(custom.getString("date.format"));  // Date display format
+
+      surl    = ApplicationSettings.getRepositoryURL() + path;
+      surl    = surl.replaceAll("'", "\\\\'");
+      format  = table[table.length-1].toUpperCase();
+         size    = tostring.format(export.length()/1000);
+         date    = convert.format(represented.getTo().getDate());
+      comment = represented.getDescription();
+      if (comment == null) comment = "";
+    }
+
+//  ==============================================================================================================================
+//  Getters
+//  ==============================================================================================================================
+
+    public String getDate () {
+//  ------------------------
+      return date;
+    }
+    public String getDescription () {
+//  -------------------------------
+      return comment;
+    }
+    public String getFormat () {
+//  -----------------------
+      return format;
+    }
+    public String getSize () {
+//  ------------------------
+      return size;
+    }
+    public String getURL () {
+//  -----------------------
+      return surl;
+    }
+}
\ No newline at end of file