|
From: <de...@us...> - 2012-10-19 23:24:29
|
Revision: 7769
http://fudaa.svn.sourceforge.net/fudaa/?rev=7769&view=rev
Author: deniger
Date: 2012-10-19 23:24:23 +0000 (Fri, 19 Oct 2012)
Log Message:
-----------
Modified Paths:
--------------
trunk/framework/ctulu-common/src/main/java/org/fudaa/ctulu/CtuluLibFile.java
trunk/framework/ctulu-common/src/main/java/org/fudaa/ctulu/xml/XmlVersionFinder.java
Added Paths:
-----------
trunk/framework/ctulu-common/src/main/java/org/fudaa/ctulu/MessageFormatHelper.java
Modified: trunk/framework/ctulu-common/src/main/java/org/fudaa/ctulu/CtuluLibFile.java
===================================================================
--- trunk/framework/ctulu-common/src/main/java/org/fudaa/ctulu/CtuluLibFile.java 2012-10-19 23:23:53 UTC (rev 7768)
+++ trunk/framework/ctulu-common/src/main/java/org/fudaa/ctulu/CtuluLibFile.java 2012-10-19 23:24:23 UTC (rev 7769)
@@ -43,6 +43,8 @@
import com.memoire.fu.FuLog;
import java.io.BufferedOutputStream;
import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
import java.util.Collections;
import java.util.LinkedList;
import java.util.logging.Level;
@@ -672,6 +674,42 @@
}
/**
+ * @param pathInJar la pathInJar a lire
+ * @return le fichier ou une copie si necessaire
+ */
+ public static File getFileFromJar(final String pathInJar, File destFile) {
+ URI uri = null;
+ try {
+ final URL resource = CtuluLibFile.class.getResource(pathInJar);
+ assert resource != null;
+ uri = resource.toURI();
+ } catch (final URISyntaxException e) {
+ Logger.getLogger(CtuluLibFile.class.getName()).log(Level.SEVERE, "getFile " + pathInJar, e);
+ }
+ if (uri == null) {
+ return null;
+ }
+ File f = destFile;
+ FileOutputStream out = null;
+ InputStream in = null;
+ try {
+ if (f == null) {
+ f = File.createTempFile("fudaa", ".tmp");
+ }
+ out = new FileOutputStream(f);
+ in = uri.toURL().openStream();
+ CtuluLibFile.copyStream(in, out, true, true);
+ } catch (final IOException e) {
+ Logger.getLogger(CtuluLibFile.class.getName()).log(Level.SEVERE, "getFile " + pathInJar, e);
+ } finally {
+ CtuluLibFile.close(out);
+ CtuluLibFile.close(in);
+ }
+ assert f.exists();
+ return f;
+ }
+
+ /**
* @param _from le fichier a deplacer
* @param _to le fichier destination
* @return true si ok
Copied: trunk/framework/ctulu-common/src/main/java/org/fudaa/ctulu/MessageFormatHelper.java (from rev 7640, trunk/soft/fudaa-crue/crue-server/src/main/java/org/fudaa/dodico/crue/common/CrueMessageHelper.java)
===================================================================
--- trunk/framework/ctulu-common/src/main/java/org/fudaa/ctulu/MessageFormatHelper.java (rev 0)
+++ trunk/framework/ctulu-common/src/main/java/org/fudaa/ctulu/MessageFormatHelper.java 2012-10-19 23:24:23 UTC (rev 7769)
@@ -0,0 +1,33 @@
+/**
+ * Licence GPL
+ * Copyright Genesis
+ */
+package org.fudaa.ctulu;
+
+import java.text.MessageFormat;
+import java.util.ResourceBundle;
+
+/**
+ * @author deniger
+ */
+public final class MessageFormatHelper {
+
+ /**
+ * @param bundle
+ * @param s le message initial
+ * @param args les arguements a utiliser pour le message
+ * @return la chaine traduite
+ */
+ public static String getS(ResourceBundle bundle, final String s, Object... args) {
+ try {
+ String res = bundle.getString(s);
+ if (!CtuluLibArray.isEmpty(args)) { return new MessageFormat(res).format(args); }
+ return res;
+ } catch (Exception e) {
+
+ }
+ return s;
+
+ }
+
+}
Modified: trunk/framework/ctulu-common/src/main/java/org/fudaa/ctulu/xml/XmlVersionFinder.java
===================================================================
--- trunk/framework/ctulu-common/src/main/java/org/fudaa/ctulu/xml/XmlVersionFinder.java 2012-10-19 23:23:53 UTC (rev 7768)
+++ trunk/framework/ctulu-common/src/main/java/org/fudaa/ctulu/xml/XmlVersionFinder.java 2012-10-19 23:24:23 UTC (rev 7769)
@@ -11,6 +11,10 @@
import org.xml.sax.helpers.DefaultHandler;
public class XmlVersionFinder extends DefaultHandler {
+ /**
+ * entete xml a mettre devant chaque fichier.
+ */
+ public static final String ENTETE_XML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
String versionFound;
public static final String ENCODING = "UTF-8";
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|