You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by bo...@apache.org on 2007/05/06 15:21:10 UTC

svn commit: r535609 - /myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/LayoutTokens.java

Author: bommel
Date: Sun May  6 06:21:09 2007
New Revision: 535609

URL: http://svn.apache.org/viewvc?view=rev&rev=535609
Log:
(TOBAGO-380) Define a Object Interface for LayoutTokens in GridLayout

Modified:
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/LayoutTokens.java

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/LayoutTokens.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/LayoutTokens.java?view=diff&rev=535609&r1=535608&r2=535609
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/LayoutTokens.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/LayoutTokens.java Sun May  6 06:21:09 2007
@@ -17,6 +17,9 @@
  * limitations under the License.
  */
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
 import java.util.StringTokenizer;
 import java.util.List;
 import java.util.ArrayList;
@@ -26,6 +29,7 @@
  * Time: 1:11:25 PM
  */
 public class LayoutTokens {
+  private static final Log LOG = LogFactory.getLog(LayoutTokens.class);
 
   private List<LayoutToken> tokens = new ArrayList<LayoutToken>();
 
@@ -85,19 +89,25 @@
   }
 
   private static void parseToken(String token, LayoutTokens layoutTokens) {
+    try {
     // TODO optimize me
-    if ("*".equals(token)) {
-      layoutTokens.addToken(new RelativeLayoutToken(1));
-    } else if (token.equals("fixed")) {
-      layoutTokens.addToken(new FixedLayoutToken());
-    } else if (token.equals("minimum")) {
-      layoutTokens.addToken(new MinimumLayoutToken());
-    } else if (token.matches("\\d+px")) {
-      layoutTokens.addToken(new PixelLayoutToken(Integer.parseInt(token.replaceAll("\\D", ""))));
-    } else if (token.matches("^\\d+\\%")) {
-      layoutTokens.addToken(new PercentLayoutToken(Integer.parseInt(token.replaceAll("\\D", ""))));
-    } else if (token.matches("^\\d+\\*")) {
-      layoutTokens.addToken(new RelativeLayoutToken(Integer.parseInt(token.replaceAll("\\D", ""))));
+      if ("*".equals(token)) {
+        layoutTokens.addToken(new RelativeLayoutToken(1));
+      } else if (token.equals("fixed")) {
+        layoutTokens.addToken(new FixedLayoutToken());
+      } else if (token.equals("minimum")) {
+        layoutTokens.addToken(new MinimumLayoutToken());
+      } else if (token.matches("\\d+px")) {
+        layoutTokens.addToken(new PixelLayoutToken(Integer.parseInt(token.replaceAll("\\D", ""))));
+      } else if (token.matches("^\\d+\\%")) {
+        layoutTokens.addToken(new PercentLayoutToken(Integer.parseInt(token.replaceAll("\\D", ""))));
+      } else if (token.matches("^\\d+\\*")) {
+        layoutTokens.addToken(new RelativeLayoutToken(Integer.parseInt(token.replaceAll("\\D", ""))));
+      } else {
+        LOG.error("Unknown layout token " + token + " ignoring");
+      }
+    } catch (NumberFormatException e) {
+      LOG.error("Error parsing layout token " + token, e);
     }
   }