Skip to content

Commit

Permalink
Use commons-lang, now that we are using more methods of it, with no
Browse files Browse the repository at this point in the history
modification, and it's only for jstf-generator.
  • Loading branch information
slaout committed Apr 5, 2014
1 parent d4e9f11 commit 1032165
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 283 deletions.
6 changes: 6 additions & 0 deletions jstf-generator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
<artifactId>jstf-lib</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.apache.commons.lang.StringEscapeUtils;
import org.jstf.generator.parser.FormatterParser;
import org.jstf.generator.parser.MessageFormatParser;
import org.jstf.generator.util.StringUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
Expand Down Expand Up @@ -203,7 +203,7 @@ private static void parseXmlFile(String locale, String xmlFileName, Map<String,
Node stringNode = stringNodes.item(i);
String key = stringNode.getAttributes().getNamedItem("name").getTextContent();
// Read the string in the XML file and interpret things like \n & \u0042
String value = StringUtils.unescapeJava(stringNode.getTextContent());
String value = StringEscapeUtils.unescapeJava(stringNode.getTextContent());

// Map<locale, translatedString>
Map<String, String> mapForKey = strings.get(key);
Expand Down Expand Up @@ -247,7 +247,7 @@ private static String getQuantityString(NodeList itemNodes, String quantity) {
Node itemNode = itemNodes.item(i);
if (itemNode.getAttributes() != null && quantity.equals(itemNode.getAttributes().getNamedItem("quantity").getNodeValue())) {
// Read the string in the XML file and interpret things like \n & \u0042
return StringUtils.unescapeJava(itemNode.getTextContent());
return StringEscapeUtils.unescapeJava(itemNode.getTextContent());
}
}
return null;
Expand Down Expand Up @@ -581,7 +581,7 @@ private static void generateLocaleClass(String locale, Map<String, Map<String, S
int i = 0;
for (Entry<String, Map<String, String>> entry : strings.entrySet()) {
// Replace " by \" and escape international characters with encoding-independent \u0042 equivalents
String value = StringUtils.escapeJava(entry.getValue().get(locale));
String value = StringEscapeUtils.escapeJava(entry.getValue().get(locale));
builder.append("\t\t").append(value == null ? "null" : "\"" + value + "\"").append(i < keySetSize - 1 ? "," : "").append(LS);
i++;
}
Expand All @@ -596,7 +596,8 @@ private static void generateLocaleClass(String locale, Map<String, Map<String, S
String[] values = entry.getValue().get(locale);
if (values != null) {
for(int j = 0; j < values.length; j++) {
String value = StringUtils.escapeJava(values[j]);
// Replace " by \" and escape international characters with encoding-independent \u0042 equivalents
String value = StringEscapeUtils.escapeJava(values[j]);
builder.append("\t\t\t").append(value == null ? "null" : "\"" + value + "\"").append(j < values.length - 1 ? "," : "").append(LS);
}
}
Expand Down
278 changes: 0 additions & 278 deletions jstf-generator/src/main/java/org/jstf/generator/util/StringUtils.java

This file was deleted.

0 comments on commit 1032165

Please sign in to comment.