You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by aw...@apache.org on 2007/09/11 20:04:27 UTC

svn commit: r574655 - /myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/ConfigParser.java

Author: awiner
Date: Tue Sep 11 11:04:27 2007
New Revision: 574655

URL: http://svn.apache.org/viewvc?rev=574655&view=rev
Log:
TRINIDAD-638: trinidad-config.xml's parser should greedily trim white spaces for some properties

Modified:
    myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/ConfigParser.java

Modified: myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/ConfigParser.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/ConfigParser.java?rev=574655&r1=574654&r2=574655&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/ConfigParser.java (original)
+++ myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/ConfigParser.java Tue Sep 11 11:04:27 2007
@@ -169,7 +169,12 @@
                            String localName,
                            String qName)
     {
-      if ((_currentText != null) && !"".equals(_currentText))
+      String currentText = _currentText;
+      if (currentText == null)
+        return;
+      
+      currentText = currentText.trim();
+      if (!"".equals(currentText))
       {
         PropertyKey key = _bean.getType().findKey(localName);
         if (key == null)
@@ -179,8 +184,8 @@
         }
         else
         {
-          if (_currentText.startsWith("#{") &&
-              _currentText.endsWith("}"))
+          if (currentText.startsWith("#{") &&
+              currentText.endsWith("}"))
           {
             if (!key.getSupportsBinding())
             {
@@ -190,7 +195,7 @@
             else
             {
               ValueBinding binding =
-                LazyValueBinding.createValueBinding(_currentText);
+                LazyValueBinding.createValueBinding(currentText);
               _bean.setValueBinding(key, binding);
             }
           }
@@ -200,25 +205,25 @@
 
             if (key.getType() == Character.class)
             {
-              value = _currentText.charAt(0);
+              value = currentText.charAt(0);
             }
             else if (key.getType() == Integer.class)
             {
-              value = _getIntegerValue(_currentText, qName);
+              value = _getIntegerValue(currentText, qName);
             }
             else if (key.getType() == Boolean.class)
             {
-              value = ("true".equalsIgnoreCase(_currentText)
+              value = ("true".equalsIgnoreCase(currentText)
                        ? Boolean.TRUE : Boolean.FALSE);
             }
             else if (key.getType() == TimeZone.class)
             {
-              value = TimeZone.getTimeZone(_currentText);
+              value = TimeZone.getTimeZone(currentText);
             }
             else if (key.getType() == Locale.class)
             {
-              _currentText = _currentText.replace('_', '-');
-              value = LocaleUtils.getLocaleForIANAString(_currentText);
+              currentText = currentText.replace('_', '-');
+              value = LocaleUtils.getLocaleForIANAString(currentText);
             }
             else if (key.getType().isEnum())
             {
@@ -226,18 +231,18 @@
               try
               {
                 value = Enum.valueOf((Class<? extends Enum>) key.getType(),
-                                     _currentText.trim());
+                                     currentText);
               }
               catch (IllegalArgumentException iae)
               {
                 _LOG.warning("INVALID_ENUM_IN_CONFIG",
-                             new Object[]{_currentText, qName});
+                             new Object[]{currentText, qName});
                 return;
               }
             }
             else
             {
-              value = _currentText;
+              value = currentText;
             }
 
             if (key == RequestContextBean.REMOTE_DEVICE_REPOSITORY_URI)
@@ -261,23 +266,22 @@
       _currentText = null;
     }
 
-  private static Integer _getIntegerValue(String text, String qName)
-  {
-    Integer value = null;
-    try
+    private static Integer _getIntegerValue(String text, String qName)
     {
-      value = Integer.valueOf(text);
-    }
-    catch (NumberFormatException nfe)
-    {
-      if (_LOG.isWarning())
+      Integer value = null;
+      try
       {
-        _LOG.warning("ELEMENT_ONLY_ACCEPT_INTEGER", qName);
+        value = Integer.valueOf(text);
       }
+      catch (NumberFormatException nfe)
+      {
+        if (_LOG.isWarning())
+        {
+          _LOG.warning("ELEMENT_ONLY_ACCEPT_INTEGER", qName);
+        }
+      }
+      return value;
     }
-    return value;
-  }
-
 
     private RequestContextBean  _bean;
     private String              _currentText;