X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Fjvcard%2Fresources%2FBundles.java;h=04b6f707d1dcaeb1935d036d7fcd2f3cf5ff6597;hb=e27d1404e9222796fb6097ab41cff873148b65c7;hp=00cd58ad23ad95c1cf1d126793c6d778e8203570;hpb=e119a1c1a924998b9315e46c96b1c750aab1deb9;p=jvcard.git
diff --git a/src/be/nikiroo/jvcard/resources/Bundles.java b/src/be/nikiroo/jvcard/resources/Bundles.java
index 00cd58a..04b6f70 100644
--- a/src/be/nikiroo/jvcard/resources/Bundles.java
+++ b/src/be/nikiroo/jvcard/resources/Bundles.java
@@ -17,6 +17,10 @@ import java.util.ResourceBundle;
*
*/
public class Bundles {
+ /**
+ * The configuration directory where we try to get the .properties
+ * in priority, or NULL to get the information from the compiled resources.
+ */
static private String confDir = getConfDir();
/**
@@ -69,6 +73,16 @@ public class Bundles {
Bundles.confDir = confDir;
}
+ /**
+ * Get the primary configuration directory to look for .properties
+ * files in.
+ *
+ * @return the directory
+ */
+ static public String getDirectory() {
+ return Bundles.confDir;
+ }
+
/**
* This class encapsulate a {@link ResourceBundle} in UTF-8. It only allows
* to retrieve values associated to an enumeration, and allows some
@@ -313,10 +327,36 @@ public class Bundles {
* in case of IO error
*/
protected void writeValue(Writer writer, E id) throws IOException {
- writer.write(id.name());
+ writeValue(writer, id.name(), getString(id));
+ }
+
+ /**
+ * Write the given data to the config file, i.e.,
+ * "MY_ID = my_curent_value" followed by a new line
+ *
+ * @param writer
+ * the {@link Writer} to write into
+ * @param id
+ * the id to write
+ * @param value
+ * the id's value
+ *
+ * @throws IOException
+ * in case of IO error
+ */
+ protected void writeValue(Writer writer, String id, String value)
+ throws IOException {
+ writer.write(id);
writer.write(" = ");
- writer.write(getString(id));
- writer.write("\n");
+
+ String[] lines = value.replaceAll("\\\t", "\\\\\\t").split("\n");
+ for (int i = 0; i < lines.length; i++) {
+ writer.write(lines[i]);
+ if (i < lines.length - 1) {
+ writer.write("\\n\\");
+ }
+ writer.write("\n");
+ }
}
/**