[gatein-commits] gatein SVN: r4943 - portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router.

do-not-reply at jboss.org do-not-reply at jboss.org
Thu Nov 4 10:56:33 EDT 2010


Author: julien_viet
Date: 2010-11-04 10:56:33 -0400 (Thu, 04 Nov 2010)
New Revision: 4943

Added:
   portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RequestParam.java
Removed:
   portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RequestParamDef.java
Modified:
   portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Route.java
Log:
rename for more consistency


Copied: portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RequestParam.java (from rev 4919, portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RequestParamDef.java)
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RequestParam.java	                        (rev 0)
+++ portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RequestParam.java	2010-11-04 14:56:33 UTC (rev 4943)
@@ -0,0 +1,146 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.web.controller.router;
+
+import org.exoplatform.web.controller.QualifiedName;
+import org.exoplatform.web.controller.metadata.RequestParamDescriptor;
+
+import java.util.regex.Pattern;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+class RequestParam
+{
+
+   /** . */
+   final QualifiedName name;
+
+   /** . */
+   final String matchName;
+
+   /** . */
+   final Pattern matchValue;
+
+   /** . */
+   final boolean required;
+
+   RequestParam(RequestParamDescriptor descriptor)
+   {
+      if (descriptor == null)
+      {
+         throw new NullPointerException("No null descriptor accepted");
+      }
+
+      //
+      Pattern matchValue = null;
+      if (descriptor.getMatchValue() != null)
+      {
+         PatternBuilder matchValueBuilder = new PatternBuilder();
+         matchValueBuilder.expr("^");
+         int level = 0;
+         for (char c : descriptor.getMatchValue().toCharArray())
+         {
+            switch (c)
+            {
+               case '{':
+
+                  if (level++ > 0)
+                  {
+                     matchValueBuilder.expr('{');
+                  }
+                  break;
+               case '}':
+                  if (--level > 0)
+                  {
+                     matchValueBuilder.expr('}');
+                  }
+                  break;
+               default:
+                  if (level == 0)
+                  {
+                     matchValueBuilder.litteral(c);
+                  }
+                  else
+                  {
+                     matchValueBuilder.expr(c);
+                  }
+                  break;
+            }
+         }
+         matchValueBuilder.expr("$");
+         matchValue = matchValueBuilder.build();
+      }
+
+      //
+      this.name = descriptor.getName();
+      this.matchName = descriptor.getMatchName();
+      this.matchValue = matchValue;
+      this.required = descriptor.isRequired();
+   }
+
+   RequestParam(QualifiedName name, String matchName, Pattern matchValue, boolean required)
+   {
+      if (name == null)
+      {
+         throw new NullPointerException("No null name accepted");
+      }
+      if (matchName == null)
+      {
+         throw new NullPointerException("No null match name accepted");
+      }
+      if (matchValue == null)
+      {
+         throw new NullPointerException("No null match value accepted");
+      }
+
+      //
+      this.name = name;
+      this.matchName = matchName;
+      this.matchValue = matchValue;
+      this.required = required;
+   }
+
+   public QualifiedName getName()
+   {
+      return name;
+   }
+
+   public String getMatchName()
+   {
+      return matchName;
+   }
+
+   public Pattern getMatchValue()
+   {
+      return matchValue;
+   }
+
+   public boolean matchValue(String value)
+   {
+      return matchValue == null || matchValue.matcher(value).matches();
+   }
+
+   public boolean isRequired()
+   {
+      return required;
+   }
+}

Deleted: portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RequestParamDef.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RequestParamDef.java	2010-11-04 14:54:55 UTC (rev 4942)
+++ portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/RequestParamDef.java	2010-11-04 14:56:33 UTC (rev 4943)
@@ -1,146 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.web.controller.router;
-
-import org.exoplatform.web.controller.QualifiedName;
-import org.exoplatform.web.controller.metadata.RequestParamDescriptor;
-
-import java.util.regex.Pattern;
-
-/**
- * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-class RequestParamDef
-{
-
-   /** . */
-   final QualifiedName name;
-
-   /** . */
-   final String matchName;
-
-   /** . */
-   final Pattern matchValue;
-
-   /** . */
-   final boolean required;
-
-   RequestParamDef(RequestParamDescriptor descriptor)
-   {
-      if (descriptor == null)
-      {
-         throw new NullPointerException("No null descriptor accepted");
-      }
-
-      //
-      Pattern matchValue = null;
-      if (descriptor.getMatchValue() != null)
-      {
-         PatternBuilder matchValueBuilder = new PatternBuilder();
-         matchValueBuilder.expr("^");
-         int level = 0;
-         for (char c : descriptor.getMatchValue().toCharArray())
-         {
-            switch (c)
-            {
-               case '{':
-
-                  if (level++ > 0)
-                  {
-                     matchValueBuilder.expr('{');
-                  }
-                  break;
-               case '}':
-                  if (--level > 0)
-                  {
-                     matchValueBuilder.expr('}');
-                  }
-                  break;
-               default:
-                  if (level == 0)
-                  {
-                     matchValueBuilder.litteral(c);
-                  }
-                  else
-                  {
-                     matchValueBuilder.expr(c);
-                  }
-                  break;
-            }
-         }
-         matchValueBuilder.expr("$");
-         matchValue = matchValueBuilder.build();
-      }
-
-      //
-      this.name = descriptor.getName();
-      this.matchName = descriptor.getMatchName();
-      this.matchValue = matchValue;
-      this.required = descriptor.isRequired();
-   }
-
-   RequestParamDef(QualifiedName name, String matchName, Pattern matchValue, boolean required)
-   {
-      if (name == null)
-      {
-         throw new NullPointerException("No null name accepted");
-      }
-      if (matchName == null)
-      {
-         throw new NullPointerException("No null match name accepted");
-      }
-      if (matchValue == null)
-      {
-         throw new NullPointerException("No null match value accepted");
-      }
-
-      //
-      this.name = name;
-      this.matchName = matchName;
-      this.matchValue = matchValue;
-      this.required = required;
-   }
-
-   public QualifiedName getName()
-   {
-      return name;
-   }
-
-   public String getMatchName()
-   {
-      return matchName;
-   }
-
-   public Pattern getMatchValue()
-   {
-      return matchValue;
-   }
-
-   public boolean matchValue(String value)
-   {
-      return matchValue == null || matchValue.matcher(value).matches();
-   }
-
-   public boolean isRequired()
-   {
-      return required;
-   }
-}

Modified: portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Route.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Route.java	2010-11-04 14:54:55 UTC (rev 4942)
+++ portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/Route.java	2010-11-04 14:56:33 UTC (rev 4943)
@@ -62,7 +62,7 @@
    private final Map<QualifiedName, String> routeParameters;
 
    /** . */
-   private final Map<String, RequestParamDef> requestParamDefs;
+   private final Map<String, RequestParam> requestParamDefs;
 
    Route()
    {
@@ -71,7 +71,7 @@
       this.segments = new LinkedHashMap<String, List<SegmentRoute>>();
       this.patterns = new ArrayList<PatternRoute>();
       this.routeParameters = new HashMap<QualifiedName, String>();
-      this.requestParamDefs = new HashMap<String, RequestParamDef>();
+      this.requestParamDefs = new HashMap<String, RequestParam>();
    }
 
    /*
@@ -97,7 +97,7 @@
       //
       if (requestParamDefs.size() > 0)
       {
-         for (RequestParamDef requestParamDef : requestParamDefs.values())
+         for (RequestParam requestParamDef : requestParamDefs.values())
          {
             String s = blah.get(requestParamDef.getName());
             if (s != null)
@@ -180,7 +180,7 @@
       // Match any request parameter
       if (requestParamDefs.size() > 0)
       {
-         for (RequestParamDef requestParamDef : requestParamDefs.values())
+         for (RequestParam requestParamDef : requestParamDefs.values())
          {
             String a = blah.get(requestParamDef.name);
             if (a != null)
@@ -284,7 +284,7 @@
       Map<QualifiedName, String> routeRequestParams = Collections.emptyMap();
       if (requestParamDefs.size() > 0)
       {
-         for (RequestParamDef requestParamDef : requestParamDefs.values())
+         for (RequestParam requestParamDef : requestParamDefs.values())
          {
             String value = null;
             String[] values = requestParams.get(requestParamDef.getMatchName());
@@ -510,7 +510,7 @@
       route.routeParameters.putAll(descriptor.getParams());
       for (RequestParamDescriptor requestParamDescriptor : descriptor.getRequestParams().values())
       {
-         RequestParamDef requestParamDef = new RequestParamDef(requestParamDescriptor);
+         RequestParam requestParamDef = new RequestParam(requestParamDescriptor);
          route.requestParamDefs.put(requestParamDef.getMatchName(), requestParamDef);
       }
 



More information about the gatein-commits mailing list