cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thors...@apache.org
Subject svn commit: r1308839 - /cocoon/cocoon3/trunk/cocoon-sax/src/main/java/org/apache/cocoon/sax/component/I18nTransformer.java
Date Tue, 03 Apr 2012 12:13:31 GMT
Author: thorsten
Date: Tue Apr  3 12:13:30 2012
New Revision: 1308839

URL: http://svn.apache.org/viewvc?rev=1308839&view=rev
Log:
Fixing parseXml usage to be usable as well outside a sitemap context and with minimal parameter
injection.

Modified:
    cocoon/cocoon3/trunk/cocoon-sax/src/main/java/org/apache/cocoon/sax/component/I18nTransformer.java

Modified: cocoon/cocoon3/trunk/cocoon-sax/src/main/java/org/apache/cocoon/sax/component/I18nTransformer.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sax/src/main/java/org/apache/cocoon/sax/component/I18nTransformer.java?rev=1308839&r1=1308838&r2=1308839&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sax/src/main/java/org/apache/cocoon/sax/component/I18nTransformer.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-sax/src/main/java/org/apache/cocoon/sax/component/I18nTransformer.java
Tue Apr  3 12:13:30 2012
@@ -607,9 +607,11 @@ public class I18nTransformer extends Abs
     }
 
     // All date-time related parameter types and element names
+    // FIXME: Use it or drop it
     private static final Set<String> DATE_TYPES;
 
     // All number related parameter types and element names
+    // FIXME: Use it or drop it
     private static final Set<String> NUMBER_TYPES;
 
     // Date pattern types map: short, medium, long, full
@@ -732,6 +734,14 @@ public class I18nTransformer extends Abs
     // parse XML inside messages?
     private boolean parseXml;
 
+    public void setParseXml(boolean parseXml) {
+        this.parseXml = parseXml;
+    }
+
+    public void setParseNamespace(String parseNamespace) {
+        this.parseNamespace = parseNamespace;
+    }
+
     // default namespace for XML inside messages
     private String parseNamespace;
 
@@ -808,22 +818,20 @@ public class I18nTransformer extends Abs
         this.strBuffer = new StringBuilder();
     }
 
+    @SuppressWarnings("unchecked")
     @Override
     public void setConfiguration(
             final Map<String, ? extends Object> configuration) {
-
         this.setup((Map<String, Object>) configuration);
     }
 
     @Override
     public void setup(final Map<String, Object> parameters) {
-        if (parameters == null || !parameters.containsKey(PARAM_BUNDLE)) {
+        // If we do not have parameters we will not go on
+        if (parameters == null) {
             return;
         }
         
-        final String encoding = (String) (parameters.containsKey(PARAM_ENCODING)
-                ? parameters.get(PARAM_ENCODING) : DEFAULT_ENCODING);
-        
         this.parseXml = parameters.containsKey(PARAM_PARSE_XML)
                 ? Boolean.parseBoolean((String) parameters.get(PARAM_PARSE_XML))
                 : false;
@@ -833,7 +841,13 @@ public class I18nTransformer extends Abs
                     ? (String) parameters.get(PARAM_PARSE_NAMESPACE)
                     : "http://www.w3.org/1999/xhtml";
         }
-
+        // If we do not have a bundle we cannot proceed
+        if (!parameters.containsKey(PARAM_BUNDLE)) {
+            return;
+        }
+        final String encoding = (String) (parameters.containsKey(PARAM_ENCODING)
+                ? parameters.get(PARAM_ENCODING) : DEFAULT_ENCODING);
+        
         this.init(parseLocale((String) parameters.get(PARAM_LOCALE)),
                 (String) parameters.get(PARAM_BUNDLE),
                 (String) parameters.get(PARAM_UNTRANSLATED),



Mime
View raw message