[cal10n-dev] [GIT] Compiler assisted localization library branch, master, updated. v_0.7.3-1-g2b19a47

added by portage for gitosis-gentoo git-noreply at pixie.qos.ch
Mon Jul 5 19:18:30 CEST 2010


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Compiler assisted localization library".

The branch, master has been updated
       via  2b19a47037479020fc3879a930818fd6fdc48e6c (commit)
      from  6478ef3ce63a829a512e44cd25a09a5ab3fe2f34 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=cal10n.git;a=commit;h=2b19a47037479020fc3879a930818fd6fdc48e6c
http://github.com/ceki/cal10n/commit/2b19a47037479020fc3879a930818fd6fdc48e6c

commit 2b19a47037479020fc3879a930818fd6fdc48e6c
Author: Ceki Gulcu <ceki at qos.ch>
Date:   Mon Jul 5 19:14:25 2010 +0200

    - fixed cal-19
    - preparing release 0.7.4

diff --git a/cal10n-api/pom.xml b/cal10n-api/pom.xml
index 43cedd1..9c858fc 100644
--- a/cal10n-api/pom.xml
+++ b/cal10n-api/pom.xml
@@ -5,7 +5,7 @@
   <parent>
     <groupId>ch.qos.cal10n</groupId>
     <artifactId>cal10n-parent</artifactId>
-    <version>0.7.3</version>
+    <version>0.7.4</version>
   </parent>
 
   <modelVersion>4.0.0</modelVersion>
diff --git a/cal10n-api/src/main/java/ch/qos/cal10n/util/LexicalUtil.java b/cal10n-api/src/main/java/ch/qos/cal10n/util/LexicalUtil.java
new file mode 100755
index 0000000..b323ae4
--- /dev/null
+++ b/cal10n-api/src/main/java/ch/qos/cal10n/util/LexicalUtil.java
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2009 QOS.ch All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS  IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package ch.qos.cal10n.util;
+
+/**
+ * @author Ceki G&uuml;c&uuml;
+ */
+public class LexicalUtil {
+
+
+  public static StringBuilder convertSpecialCharacters(StringBuilder inBuf) {
+
+    int i = inBuf.indexOf("\\");
+
+    if (i == -1) {
+      return inBuf;
+    }
+
+    StringBuilder outBuf = new StringBuilder(inBuf.length());
+
+    int last = -1;
+    while (i != -1) {
+      outBuf.append(inBuf.subSequence(last + 1, i));
+      last = i + 1;
+      char next = inBuf.charAt(last);
+      switch (next) {
+        case 'u':
+          char unicodeChar = readUnicode(inBuf, last + 1);
+          outBuf.append(unicodeChar);
+          last += 4;
+          break;
+        case 'n':
+          outBuf.append('\n');
+          break;
+        case 'r':
+          outBuf.append('\r');
+          break;
+        case 't':
+          outBuf.append('\t');
+          break;
+        case 'f':
+          outBuf.append('\f');
+          break;
+        default:
+          outBuf.append('\\');
+          outBuf.append(next);
+
+      }
+      i = inBuf.indexOf("\\", last);
+    }
+    outBuf.append(inBuf.subSequence(last + 1, inBuf.length()));
+    return outBuf;
+  }
+
+  // see http://java.sun.com/docs/books/jls/second_edition/html/lexical.doc.html#95504
+
+  private static char readUnicode(StringBuilder inBuf, int i) {
+    int r = 0;
+    for (int j = i; j < i + 4; j++) {
+      char atJ = inBuf.charAt(j);
+
+      if (atJ >= '0' && atJ <= '9') {
+        r = (r << 4) + atJ - '0';
+        continue;
+      }
+      if (atJ >= 'A' && atJ <= 'F') {
+        // '7' = 'A' - 10 
+        r = (r << 4) + atJ - '7';
+        continue;
+      }
+      if (atJ >= 'a' && atJ <= 'f') {
+        // 'W' = 'a' - 10
+        r = (r << 4) + atJ - 'W';
+        continue;
+      }
+    }
+    return (char) r;
+  }
+}
diff --git a/cal10n-api/src/main/java/ch/qos/cal10n/util/TokenStream.java b/cal10n-api/src/main/java/ch/qos/cal10n/util/TokenStream.java
index ebcfb4a..93447c3 100644
--- a/cal10n-api/src/main/java/ch/qos/cal10n/util/TokenStream.java
+++ b/cal10n-api/src/main/java/ch/qos/cal10n/util/TokenStream.java
@@ -73,7 +73,7 @@ public class TokenStream {
 
   private void tokenizeLine(List<Token> tokenList, String line) {
     int len = line.length();
-    StringBuffer buf = new StringBuffer();
+    StringBuilder buf = new StringBuilder();
 
     for (int pointer = 0; pointer < len; pointer++) {
       char c = line.charAt(pointer);
@@ -95,7 +95,8 @@ public class TokenStream {
 
       case KEY:
         if (isWhiteSpace(c) || isNonWhiteSpaceSeparator(c)) {
-          tokenList.add(new Token(TokenType.KEY, buf.toString()));
+          String lexicalValue = LexicalUtil.convertSpecialCharacters(buf).toString();
+          tokenList.add(new Token(TokenType.KEY, lexicalValue));
           buf.setLength(0);
           buf.append(c);
           state = State.SEPARATOR;
@@ -119,7 +120,8 @@ public class TokenStream {
       case VAL:
         if(c == '\\') {
           if(isTrailingBackSlash(line, pointer+1)) {
-            tokenList.add(new Token(TokenType.VALUE, buf.toString()));
+            String lexicalValue = LexicalUtil.convertSpecialCharacters(buf).toString();
+            tokenList.add(new Token(TokenType.VALUE, lexicalValue));
             buf.setLength(0);
             state = State.TRAILING_BACKSLASH;
             tokenList.add(Token.TRAILING_BACKSLASH);
@@ -141,7 +143,8 @@ public class TokenStream {
     }
     
     if(state == State.VAL) {
-      tokenList.add(new Token(TokenType.VALUE, buf.toString()));
+      String lexicalValue = LexicalUtil.convertSpecialCharacters(buf).toString();
+      tokenList.add(new Token(TokenType.VALUE, lexicalValue));
       buf.setLength(0);
     }
   }
diff --git a/cal10n-api/src/test/java/ch/qos/cal10n/MessageConveyorTest.java b/cal10n-api/src/test/java/ch/qos/cal10n/MessageConveyorTest.java
index fdd4df3..96c6533 100644
--- a/cal10n-api/src/test/java/ch/qos/cal10n/MessageConveyorTest.java
+++ b/cal10n-api/src/test/java/ch/qos/cal10n/MessageConveyorTest.java
@@ -27,6 +27,7 @@ import static org.junit.Assert.fail;
 
 import java.util.Locale;
 
+import ch.qos.cal10n.sample.Labels;
 import org.junit.Test;
 
 import ch.qos.cal10n.sample.Colors;
@@ -111,5 +112,13 @@ public class MessageConveyorTest {
     MessageConveyor mc = new MessageConveyor(Locale.ENGLISH);
     assertEquals("A", mc.getMessage(Minimal.A));
   }
-  
+
+
+  @Test
+  public void specialCharacters() {
+    MessageConveyor mc = new MessageConveyor(Locale.ENGLISH);
+    assertEquals("A label \n with linefeed and unicode", mc.getMessage(Labels.L0));
+    assertEquals("Another \nlabel", mc.getMessage(Labels.L1));
+  }
+
 }
diff --git a/cal10n-api/src/test/java/ch/qos/cal10n/sample/Labels.java b/cal10n-api/src/test/java/ch/qos/cal10n/sample/Labels.java
new file mode 100755
index 0000000..5fe3c3c
--- /dev/null
+++ b/cal10n-api/src/test/java/ch/qos/cal10n/sample/Labels.java
@@ -0,0 +1,11 @@
+package ch.qos.cal10n.sample;
+
+import ch.qos.cal10n.BaseName;
+
+/**
+ * @author Ceki G&uuml;c&uuml;
+ */
+ at BaseName("labels")
+public enum Labels {
+  L0, L1;
+}
diff --git a/cal10n-api/src/test/java/ch/qos/cal10n/util/PropertyResourceBundleFinderTest.java b/cal10n-api/src/test/java/ch/qos/cal10n/util/CAL10NResourceBundleFinderTest.java
similarity index 96%
rename from cal10n-api/src/test/java/ch/qos/cal10n/util/PropertyResourceBundleFinderTest.java
rename to cal10n-api/src/test/java/ch/qos/cal10n/util/CAL10NResourceBundleFinderTest.java
index 2a2ea8e..07adf6d 100644
--- a/cal10n-api/src/test/java/ch/qos/cal10n/util/PropertyResourceBundleFinderTest.java
+++ b/cal10n-api/src/test/java/ch/qos/cal10n/util/CAL10NResourceBundleFinderTest.java
@@ -1,73 +1,73 @@
-/*
- * Copyright (c) 2009 QOS.ch All rights reserved.
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- * 
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- * 
- * THE SOFTWARE IS PROVIDED "AS  IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-package ch.qos.cal10n.util;
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.IOException;
-import java.util.Locale;
-import java.util.ResourceBundle;
-
-import org.junit.Test;
-
-import ch.qos.cal10n.sample.Colors;
-
-public class PropertyResourceBundleFinderTest {
-  ResourceBundle rb;
-  String encoding;
-  
-  Class<?> enumTyoe = Colors.BLUE.getDeclaringClass();
-  
-  @Test
-  public void smoke() throws IOException {
-    encoding = AnnotationExtractor.getCharset(enumTyoe, Locale.FRENCH);
-    rb = CAL10NResourceBundleFinder.getBundle(this.getClass().getClassLoader(),
-         "colors", Locale.FRENCH, encoding);
-    assertEquals("les roses sont rouges", rb.getString("RED"));
-  }
-
-  @Test
-  public void withCountry() throws IOException {
-    encoding = AnnotationExtractor.getCharset(enumTyoe, Locale.FRENCH);
-    rb = CAL10NResourceBundleFinder.getBundle(this.getClass().getClassLoader(),
-        "colors", Locale.FRENCH, encoding);
-    assertEquals("les roses sont rouges", rb.getString("RED"));
-
-    rb = CAL10NResourceBundleFinder.getBundle(this.getClass().getClassLoader(),
-        "colors", Locale.FRANCE, encoding);
-    assertEquals("les roses sont rouges, et alors?", rb.getString("RED"));
-  }
-
-  @Test
-  public void inDirectory() throws IOException {
-    encoding = AnnotationExtractor.getCharset(enumTyoe, Locale.ENGLISH);
-    rb = CAL10NResourceBundleFinder.getBundle(this.getClass().getClassLoader(),
-        "foobar/sample", Locale.ENGLISH, encoding);
-    assertEquals("A is the first letter of the alphabet", rb.getString("A"));
-
-    rb = CAL10NResourceBundleFinder.getBundle(this.getClass().getClassLoader(),
-        "foobar.sample", Locale.ENGLISH, encoding);
-    assertEquals("A is the first letter of the alphabet", rb.getString("A"));
-  }
-  
-
-}
+/*
+ * Copyright (c) 2009 QOS.ch All rights reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS  IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package ch.qos.cal10n.util;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+import org.junit.Test;
+
+import ch.qos.cal10n.sample.Colors;
+
+public class CAL10NResourceBundleFinderTest {
+  ResourceBundle rb;
+  String encoding;
+  
+  Class<?> enumTyoe = Colors.BLUE.getDeclaringClass();
+  
+  @Test
+  public void smoke() throws IOException {
+    encoding = AnnotationExtractor.getCharset(enumTyoe, Locale.FRENCH);
+    rb = CAL10NResourceBundleFinder.getBundle(this.getClass().getClassLoader(),
+         "colors", Locale.FRENCH, encoding);
+    assertEquals("les roses sont rouges", rb.getString("RED"));
+  }
+
+  @Test
+  public void withCountry() throws IOException {
+    encoding = AnnotationExtractor.getCharset(enumTyoe, Locale.FRENCH);
+    rb = CAL10NResourceBundleFinder.getBundle(this.getClass().getClassLoader(),
+        "colors", Locale.FRENCH, encoding);
+    assertEquals("les roses sont rouges", rb.getString("RED"));
+
+    rb = CAL10NResourceBundleFinder.getBundle(this.getClass().getClassLoader(),
+        "colors", Locale.FRANCE, encoding);
+    assertEquals("les roses sont rouges, et alors?", rb.getString("RED"));
+  }
+
+  @Test
+  public void inDirectory() throws IOException {
+    encoding = AnnotationExtractor.getCharset(enumTyoe, Locale.ENGLISH);
+    rb = CAL10NResourceBundleFinder.getBundle(this.getClass().getClassLoader(),
+        "foobar/sample", Locale.ENGLISH, encoding);
+    assertEquals("A is the first letter of the alphabet", rb.getString("A"));
+
+    rb = CAL10NResourceBundleFinder.getBundle(this.getClass().getClassLoader(),
+        "foobar.sample", Locale.ENGLISH, encoding);
+    assertEquals("A is the first letter of the alphabet", rb.getString("A"));
+  }
+  
+
+}
diff --git a/cal10n-api/src/test/java/ch/qos/cal10n/util/PackageTest.java b/cal10n-api/src/test/java/ch/qos/cal10n/util/LexicalUtilTest.java
old mode 100644
new mode 100755
similarity index 51%
copy from cal10n-api/src/test/java/ch/qos/cal10n/util/PackageTest.java
copy to cal10n-api/src/test/java/ch/qos/cal10n/util/LexicalUtilTest.java
index 3d14474..2bfaef8
--- a/cal10n-api/src/test/java/ch/qos/cal10n/util/PackageTest.java
+++ b/cal10n-api/src/test/java/ch/qos/cal10n/util/LexicalUtilTest.java
@@ -1,16 +1,16 @@
 /*
- * Copyright (c) 2009 QOS.ch All rights reserved.
- * 
+ * Copyright (c) 2010 QOS.ch All rights reserved.
+ *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
  * in the Software without restriction, including without limitation the rights
  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  * copies of the Software, and to permit persons to whom the Software is
  * furnished to do so, subject to the following conditions:
- * 
+ *
  * The above copyright notice and this permission notice shall be included in
  * all copies or substantial portions of the Software.
- * 
+ *
  * THE SOFTWARE IS PROVIDED "AS  IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -19,16 +19,54 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
  */
-
 package ch.qos.cal10n.util;
 
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-import org.junit.runners.Suite.SuiteClasses;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * @author Ceki G&uuml;c&uuml;
+ */
+public class LexicalUtilTest {
+
+
+  void verify(String in, String expected) {
+    StringBuilder inBuf = new StringBuilder(in);
+    StringBuilder outBuf = LexicalUtil.convertSpecialCharacters(inBuf);
+    assertEquals(expected, outBuf.toString());
+  }
+  @Test
+  public void identity() {
+    verify("abc", "abc");
+  }
+
+  @Test
+  public void empty() {
+    verify("", "");
+  }
+
+  @Test
+  public void withLF() {
+    verify("a\\nbc", "a\nbc");
+  }
+
+  @Test
+  public void withMultipleLF() {
+    verify("a\\nb\\rc", "a\nb\rc");
+    verify("a\\nb\\r", "a\nb\r");
+    verify("\\nb\\r", "\nb\r");
+  }
+
+  @Test
+  public void withUnicode() {
+    verify("a\\u00FCbc", "a\u00FCbc");
+    verify("a\\u00fcbc", "a\u00fcbc");
+    verify("a\\u2297bc", "a\u2297bc");
+
+    verify("a\\u2169bc", "a\u2169bc");
+    verify("\\u2169", "\u2169");
+    verify("a\\u2169", "a\u2169");
 
- at RunWith(Suite.class)
- at SuiteClasses( { AnnotationExtractorTest.class, MiscUtilTest.class,
-    TokenStreamTest.class, ParserTest.class,
-    PropertyResourceBundleFinderTest.class, ResourceBundleEncodingTest.class })
-public class PackageTest {
+  }
 }
diff --git a/cal10n-api/src/test/java/ch/qos/cal10n/util/PackageTest.java b/cal10n-api/src/test/java/ch/qos/cal10n/util/PackageTest.java
index 3d14474..c918e97 100644
--- a/cal10n-api/src/test/java/ch/qos/cal10n/util/PackageTest.java
+++ b/cal10n-api/src/test/java/ch/qos/cal10n/util/PackageTest.java
@@ -29,6 +29,6 @@ import org.junit.runners.Suite.SuiteClasses;
 @RunWith(Suite.class)
 @SuiteClasses( { AnnotationExtractorTest.class, MiscUtilTest.class,
     TokenStreamTest.class, ParserTest.class,
-    PropertyResourceBundleFinderTest.class, ResourceBundleEncodingTest.class })
+    CAL10NResourceBundleFinderTest.class, ResourceBundleEncodingTest.class })
 public class PackageTest {
 }
diff --git a/cal10n-api/src/test/java/ch/qos/cal10n/util/ParserTest.java b/cal10n-api/src/test/java/ch/qos/cal10n/util/ParserTest.java
index e14f36f..f1eb33c 100644
--- a/cal10n-api/src/test/java/ch/qos/cal10n/util/ParserTest.java
+++ b/cal10n-api/src/test/java/ch/qos/cal10n/util/ParserTest.java
@@ -70,7 +70,7 @@ public class ParserTest {
     witness.put("K0", "V0 X");
     witness.put("K1", "V1");
     witness.put("K2", "V2 l1l2  l3");
-    witness.put("K3", "V3 \\t a");
+    witness.put("K3", "V3 \t a");
     assertEquals(witness, map);
   }
   
diff --git a/cal10n-api/src/test/java/ch/qos/cal10n/util/TokenStreamTest.java b/cal10n-api/src/test/java/ch/qos/cal10n/util/TokenStreamTest.java
index 00f1140..4f3d461 100644
--- a/cal10n-api/src/test/java/ch/qos/cal10n/util/TokenStreamTest.java
+++ b/cal10n-api/src/test/java/ch/qos/cal10n/util/TokenStreamTest.java
@@ -27,6 +27,7 @@ import java.io.FileNotFoundException;
 import java.io.FileReader;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.ResourceBundle;
 
 import org.junit.Test;
 
@@ -34,19 +35,17 @@ import ch.qos.cal10n.Cal10nTestConstants;
 import ch.qos.cal10n.util.Token.TokenType;
 
 /**
- * 
  * @author Ceki G&uuml;lc&uuml;
- *
  */
 public class TokenStreamTest {
 
-  
+
   @Test
   public void smoke() throws FileNotFoundException {
-    FileReader fr = new FileReader(Cal10nTestConstants.TEST_CLASSES+"/parser/smoke.properties");
+    FileReader fr = new FileReader(Cal10nTestConstants.TEST_CLASSES + "/parser/smoke.properties");
     TokenStream ts = new TokenStream(fr);
     List<Token> tokenList = ts.tokenize();
-    
+
     List<Token> witness = new ArrayList<Token>();
     witness.add(new Token(TokenType.KEY, "K0"));
     witness.add(new Token(TokenType.SEPARATOR, "="));
@@ -59,19 +58,19 @@ public class TokenStreamTest {
     witness.add(Token.EOL);
     assertEquals(witness, tokenList);
   }
-  
+
   @Test
   public void medium() throws FileNotFoundException {
-    FileReader fr = new FileReader(Cal10nTestConstants.TEST_CLASSES+"/parser/medium.properties");
+    FileReader fr = new FileReader(Cal10nTestConstants.TEST_CLASSES + "/parser/medium.properties");
     TokenStream ts = new TokenStream(fr);
     List<Token> tokenList = ts.tokenize();
-    
-   // K0=V0 \
-   //  X
-   // # comment
-   // K1=V1
-    
-    
+
+    // K0=V0 \
+    //  X
+    // # comment
+    // K1=V1
+
+
     List<Token> witness = new ArrayList<Token>();
     witness.add(new Token(TokenType.KEY, "K0"));
     witness.add(new Token(TokenType.SEPARATOR, "="));
@@ -81,7 +80,7 @@ public class TokenStreamTest {
     witness.add(new Token(TokenType.VALUE, "X"));
     witness.add(Token.EOL);
     witness.add(Token.EOL);
-    
+
     witness.add(new Token(TokenType.KEY, "K1"));
     witness.add(new Token(TokenType.SEPARATOR, "="));
     witness.add(new Token(TokenType.VALUE, "V1"));
@@ -89,4 +88,28 @@ public class TokenStreamTest {
     assertEquals(witness, tokenList);
   }
 
+  @Test
+  public void characters() throws FileNotFoundException {
+    FileReader fr = new FileReader(Cal10nTestConstants.TEST_CLASSES + "/parser/characters.properties");
+    TokenStream ts = new TokenStream(fr);
+    List<Token> tokenList = ts.tokenize();
+
+    List<Token> witness = new ArrayList<Token>();
+    witness.add(new Token(TokenType.KEY, "K0"));
+    witness.add(new Token(TokenType.SEPARATOR, "="));
+    witness.add(new Token(TokenType.VALUE, "a\nb"));
+    witness.add(Token.EOL);
+    witness.add(new Token(TokenType.KEY, "K1"));
+    witness.add(new Token(TokenType.SEPARATOR, "="));
+    witness.add(new Token(TokenType.VALUE, "a\u2297b\nc"));
+    witness.add(Token.EOL);
+    assertEquals(witness, tokenList);
+  }
+
+  @Test
+  public void resourceBundleWithSpecialCharacters() {
+    ResourceBundle rb  = ResourceBundle.getBundle("parser/characters");
+    assertEquals("a\nb", rb.getObject("K0"));
+    assertEquals("a\u2297b\nc", rb.getObject("K1"));
+  }
 }
diff --git a/cal10n-api/src/test/resources/labels_en.properties b/cal10n-api/src/test/resources/labels_en.properties
new file mode 100755
index 0000000..8109f8d
--- /dev/null
+++ b/cal10n-api/src/test/resources/labels_en.properties
@@ -0,0 +1,6 @@
+
+
+L0=A \u006cabe\u006C \n with linefeed and unicode
+
+L1=Anothe\u0072 \n\
+  label
diff --git a/cal10n-api/src/test/resources/parser/characters.properties b/cal10n-api/src/test/resources/parser/characters.properties
new file mode 100755
index 0000000..553d982
--- /dev/null
+++ b/cal10n-api/src/test/resources/parser/characters.properties
@@ -0,0 +1,2 @@
+K0=a\nb
+K1=a\u2297b\nc
diff --git a/cal10n-site/pom.xml b/cal10n-site/pom.xml
index f681d19..25ab8f0 100644
--- a/cal10n-site/pom.xml
+++ b/cal10n-site/pom.xml
@@ -5,7 +5,7 @@
   <parent>
     <groupId>ch.qos.cal10n</groupId>
     <artifactId>cal10n-parent</artifactId>
-    <version>0.7.3</version>
+    <version>0.7.4</version>
   </parent>
 
   <modelVersion>4.0.0</modelVersion>
diff --git a/cal10n-site/src/site/pages/index.html b/cal10n-site/src/site/pages/index.html
old mode 100644
new mode 100755
index 3c7e7b0..59f1c5d
--- a/cal10n-site/src/site/pages/index.html
+++ b/cal10n-site/src/site/pages/index.html
@@ -25,7 +25,8 @@
 
    <p>Compiler Assisted Localization, abbreviated as CAL10N
    (pronounced as "calion") is a java library for writing localized
-   (internationalized) messages.
+   (internationalized) messages using resource bundles you are already
+   familiar with, but with much greater comfort.
    </p>
    
    <h3>Features</h3>
diff --git a/cal10n-site/src/site/pages/manual.html b/cal10n-site/src/site/pages/manual.html
old mode 100644
new mode 100755
index 16f15d1..d962cf8
--- a/cal10n-site/src/site/pages/manual.html
+++ b/cal10n-site/src/site/pages/manual.html
@@ -78,13 +78,11 @@
 
    <h2><a name="code" href="#core">Core idea</a></h2>
 
-   <p>Instead of using values of type String as the key for each
-   message, CAL10N uses <code>enums</code>.</p>
+   <p>Instead of using String-typed keys for each message, CAL10N uses
+   <code>enums</code>.</p>
 
    <p>For example, let us assume that you wanted to internationalize
-   color names. No one in their right minds would just want to
-   internationalize three color names but probably a much larger set
-   of items. We are using a very small set of colors just as an
+   color names.  We are using a very small set of colors just as an
    example. In CAL10N you could start by writing an enum type, named
    Colors. You can choose any name for the enum type. Colors is just
    the name this particular author picked.</p>
@@ -129,6 +127,11 @@ BLUE=les violettes sont bleues
 RED=les roses sont rouges
 GREEN=les {0} sont verts</pre>
 
+
+  <p>Strictly speaking, the <em>@LocaleData</em> annotation is
+  optional. It is used by verification tools discussed below.
+  </p>
+
   
   <h2><a name="retrieving" href="#retrieving">Retrieving
   internationalized messages</a></h2>
@@ -194,16 +197,16 @@ String green = mc.getMessage(Colors.GREEN, <b>"pommes"</b>);  // note the second
   <a
   href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/ResourceBundle.html#getBundle%28java.lang.String,%20java.util.Locale,%20java.lang.ClassLoader%29">look-up
   procedure</a> for finding resource bundles. While formally this
-  procedure is deterministic, it is too error-prone. Moreover, it
-  clashes with CAL10N's philosophy of verifiability.  We thus took the
-  bold initiative to define a simplified bundle look up procedure,
-  described below.
+  procedure is deterministic, it is also error-prone. More
+  importantly, it clashes with CAL10N's goal of verifiability.  We
+  thus took the bold initiative to define a simplified bundle look up
+  procedure, described below.
   </p>
 
   <p>Given a locale, the simplified look up procedure only takes into
-  account that locale, ignoring the default locale and the resource
-  bundle corresponding to the naked base name, i.e. the default
-  resource bundle. However, if the locale has both a language
+  account that locale, <em>ignoring</em> the default locale and the
+  resource bundle corresponding to the naked base name, i.e. the
+  default resource bundle. However, if the locale has both a language
   <b>and</b> a country, and corresponding bundle files exist, then
   CAL10N will take into account both bundles, establishing the same
   parent child relationship as the JDK <code>ResourceBundle</code>
@@ -222,11 +225,15 @@ colors_fr_FR.properties</pre>
 
    <p>and the system's default locale is "fr_FR", when CAL10N is asked
    to find resource bundles corresponding to the "en_US" locale, it
-   will ignore the <em>colors.properties</em> (~ default bundle) and
-   <em>colors_fr_FR.properties</em> (~ default locale), while
-   combining the <em>colors_en_US.properties</em> and
-   <em>colors_en.properties</em> bundles in the usual parent-child
-   relationship.
+   will systematically ignore the <em>colors.properties</em> (i.e. the
+   default bundle), and combine the <em>colors_en_US.properties</em>
+   and <em>colors_en.properties</em> bundles in the usual parent-child
+   relationship. Since CAL10N is asked to lookup resource bundles
+   corresponding to the "en_US" locale, the bundle corresponding to
+   the default locale, i.e. <em>colors_fr_FR.properties</em> will also
+   be ignored. Thus, the CAL10N bundle lookup procedure differs from
+   the standard by ignoring the default bundle, the one with the naked
+   base name, e.g. <em>colors.properties</em>.
    </p>
 
    <p>We hope that the simplified look-up procedure, while deviating
diff --git a/cal10n-site/src/site/pages/news.html b/cal10n-site/src/site/pages/news.html
index 83ceff2..0a00684 100755
--- a/cal10n-site/src/site/pages/news.html
+++ b/cal10n-site/src/site/pages/news.html
@@ -28,6 +28,19 @@
 
     <hr width="80%" align="center" />
  
+    <h3>5th of July 2009 - Release of CAL10N version 0.7.4</h3>
+
+    <p>When reading in bundles, CAL10N will now honor special
+    character combinations such as '\n', '\r', '\t' as well as unicode
+    escapes using the <a
+    href="http://java.sun.com/docs/books/jls/second_edition/html/lexical.doc.html#95504">\uxxxx
+    notation</a>. This fixes <a
+    href="http://jira.qos.ch/browse/CAL-19">CAL-19</a> reported by
+    Fabien Barbero.
+    </p>
+
+    <hr width="80%" align="center" />
+ 
     <h3>2nd of July 2009 - Release of CAL10N version 0.7.3</h3>
 
     <p>Fixed maven-cal10n-plugin so that it works with Maven
diff --git a/cal10n-site/src/site/pages/templates/footer.js b/cal10n-site/src/site/pages/templates/footer.js
old mode 100644
new mode 100755
index 5aa436c..ff6f2ff
--- a/cal10n-site/src/site/pages/templates/footer.js
+++ b/cal10n-site/src/site/pages/templates/footer.js
@@ -1,14 +1,26 @@
 
+
 document.write('<table class="footer">')
 
 document.write('<tr>')
 
 document.write('  <td>')
 document.write('  &nbsp;')
+//document.write('    <a href="http://validator.w3.org/check?uri=referer">')
+//document.write('      <img align="left" src="http://www.w3.org/Icons/valid-xhtml10"') 
+//document.write('           alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a>')
 document.write('   </td>')
 
-document.write('<td valign="top">Copyright &copy; 2009  <a href="http://www.qos.ch/">QOS.ch</a></td>')
-
+document.write('<td valign="top">Copyright &copy; 2010  <a href="http://www.qos.ch/">QOS.ch</a></td>')
 document.write('</tr>')
+
+AAT = '@'
+DOOTT = '.'
+document.write('<tr>') 
+document.write('<td align="left" colspan="2">') 
+document.write('We are actively looking for volunteers to proofread the documentation. Please send your corrections or suggestions for improvement to "corrections' + AAT +'qos'+DOOTT+'ch". See also the <a href="http://articles.qos.ch/contributing.html">instructions for contributors</a>.');
+document.write('</td>') 
+
 document.write('</table>')
 
+
diff --git a/maven-cal10n-plugin-smoke/pom.xml b/maven-cal10n-plugin-smoke/pom.xml
index e3a4f09..4f352e9 100644
--- a/maven-cal10n-plugin-smoke/pom.xml
+++ b/maven-cal10n-plugin-smoke/pom.xml
@@ -4,7 +4,7 @@
 	<parent>
 		<groupId>ch.qos.cal10n</groupId>
 		<artifactId>cal10n-parent</artifactId>
-		<version>0.7.3</version>
+		<version>0.7.4</version>
 	</parent>
 
 	<modelVersion>4.0.0</modelVersion>
diff --git a/maven-cal10n-plugin/pom.xml b/maven-cal10n-plugin/pom.xml
index 19f00fb..33c8eb0 100644
--- a/maven-cal10n-plugin/pom.xml
+++ b/maven-cal10n-plugin/pom.xml
@@ -8,7 +8,7 @@
   <parent>
     <artifactId>cal10n-parent</artifactId>
     <groupId>ch.qos.cal10n</groupId>
-    <version>0.7.3</version>
+    <version>0.7.4</version>
   </parent>
 
   <groupId>ch.qos.cal10n.plugins</groupId>
diff --git a/pom.xml b/pom.xml
index f0d18ed..809bedc 100755
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
   <groupId>ch.qos.cal10n</groupId>
   <artifactId>cal10n-parent</artifactId>
 	<packaging>pom</packaging>
-  <version>0.7.3</version>
+  <version>0.7.4</version>
   <name>Compiler assisted localization library (CAL10N) - Parent</name>
 
   <url>http://cal10n.qos.ch</url>

-----------------------------------------------------------------------

Summary of changes:
 cal10n-api/pom.xml                                 |    2 +-
 .../main/java/ch/qos/cal10n/util/LexicalUtil.java  |   98 +++++++++++++
 .../main/java/ch/qos/cal10n/util/TokenStream.java  |   11 +-
 .../java/ch/qos/cal10n/MessageConveyorTest.java    |   11 ++-
 .../src/test/java/ch/qos/cal10n/sample/Labels.java |   11 ++
 ...st.java => CAL10NResourceBundleFinderTest.java} |  146 ++++++++++----------
 ...tionExtractorTest.java => LexicalUtilTest.java} |   59 ++++++---
 .../test/java/ch/qos/cal10n/util/PackageTest.java  |    2 +-
 .../test/java/ch/qos/cal10n/util/ParserTest.java   |    2 +-
 .../java/ch/qos/cal10n/util/TokenStreamTest.java   |   53 +++++--
 cal10n-api/src/test/resources/labels_en.properties |    6 +
 .../test/resources/parser/characters.properties    |    2 +
 cal10n-site/pom.xml                                |    2 +-
 cal10n-site/src/site/pages/index.html              |    3 +-
 cal10n-site/src/site/pages/manual.html             |   41 ++++---
 cal10n-site/src/site/pages/news.html               |   13 ++
 cal10n-site/src/site/pages/templates/footer.js     |   16 ++-
 maven-cal10n-plugin-smoke/pom.xml                  |    2 +-
 maven-cal10n-plugin/pom.xml                        |    2 +-
 pom.xml                                            |    2 +-
 20 files changed, 346 insertions(+), 138 deletions(-)
 create mode 100755 cal10n-api/src/main/java/ch/qos/cal10n/util/LexicalUtil.java
 create mode 100755 cal10n-api/src/test/java/ch/qos/cal10n/sample/Labels.java
 rename cal10n-api/src/test/java/ch/qos/cal10n/util/{PropertyResourceBundleFinderTest.java => CAL10NResourceBundleFinderTest.java} (96%)
 copy cal10n-api/src/test/java/ch/qos/cal10n/util/{AnnotationExtractorTest.java => LexicalUtilTest.java} (56%)
 mode change 100644 => 100755
 create mode 100755 cal10n-api/src/test/resources/labels_en.properties
 create mode 100755 cal10n-api/src/test/resources/parser/characters.properties
 mode change 100644 => 100755 cal10n-site/src/site/pages/index.html
 mode change 100644 => 100755 cal10n-site/src/site/pages/manual.html
 mode change 100644 => 100755 cal10n-site/src/site/pages/templates/footer.js


hooks/post-receive
-- 
Compiler assisted localization library


More information about the cal10n-dev mailing list