myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfreed...@apache.org
Subject svn commit: r1071846 [4/4] - in /myfaces/portlet-bridge/core/branches/2.0.0-branch: ./ api/ api/src/main/resources/META-INF/ assembly/ assembly/src/main/resources/META-INF/ examples/ examples/assembly/ examples/blank/ examples/carstore/ examples/facele...
Date Fri, 18 Feb 2011 00:29:56 GMT
Modified: myfaces/portlet-bridge/core/branches/2.0.0-branch/impl/src/main/java/org/apache/myfaces/portlet/faces/util/URLUtils.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/branches/2.0.0-branch/impl/src/main/java/org/apache/myfaces/portlet/faces/util/URLUtils.java?rev=1071846&r1=1071845&r2=1071846&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/branches/2.0.0-branch/impl/src/main/java/org/apache/myfaces/portlet/faces/util/URLUtils.java
(original)
+++ myfaces/portlet-bridge/core/branches/2.0.0-branch/impl/src/main/java/org/apache/myfaces/portlet/faces/util/URLUtils.java
Fri Feb 18 00:29:55 2011
@@ -1,146 +1,215 @@
-/* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.myfaces.portlet.faces.util;
-
-public class URLUtils
-{
-
-  /**
-   * Borrowed from package oracle.adfinternal.view.faces.share.url.EncoderUtils
-   */
-  public static String appendURLArguments(StringBuilder buffer, String baseURL,
-                                          String[] keysAndValues)
-  {
-
-    // Bug 1814825: the anchor has to stay on the end.
-    int anchorIndex = baseURL.indexOf('#');
-
-    if (anchorIndex >= 0)
-    {
-      buffer.append(baseURL.substring(0, anchorIndex));
-    }
-    else
-    {
-      buffer.append(baseURL);
-    }
-
-    boolean queryAppended = baseURL.indexOf('?') >= 0;
-
-    for (int i = 0; i < keysAndValues.length; i += 2)
-    {
-      String value = keysAndValues[i + 1];
-      if (value != null)
-      {
-        // only append '?' at start if the URL doesn't already contain
-        // arguments
-        if (!queryAppended)
-        {
-          queryAppended = true;
-          buffer.append('?');
-        }
-        else
-        {
-          buffer.append('&');
-        }
-
-        buffer.append(keysAndValues[i]);
-        buffer.append('=');
-        buffer.append(value);
-      }
-    }
-
-    String beforeEncode = buffer.toString();
-    return beforeEncode;
-  }
-
-  /**
-   * Borrowed from package oracle.adfinternal.view.faces.share.url.EncoderUtils
-   */
-  public static String appendURLArguments(String baseURL, String[] keysAndValues)
-  {
-    // buffer length = base + separators + keys + values
-    int bufferLength = baseURL.length() + keysAndValues.length;
-    for (int i = 0; i < keysAndValues.length; i += 2)
-    {
-      String value = keysAndValues[i + 1];
-      if (value != null)
-      {
-        bufferLength += keysAndValues[i].length() + value.length();
-      }
-    }
-
-    StringBuilder buffer = new StringBuilder(bufferLength);
-
-    return appendURLArguments(buffer, baseURL, keysAndValues);
-  }
-
-  public static String convertFromRelative(String currentPath, String relativeLoc)
-                                                                                  throws
IllegalArgumentException
-  {
-    // determine if and how many levels we must walk up the currentPath
-    int levels = 0;
-    int i = 0, length = relativeLoc.length();
-    while (i + 1 < length)
-    {
-      if (relativeLoc.charAt(i) != '.')
-      {
-        break;
-      }
-      else if (relativeLoc.charAt(i) == '.' && relativeLoc.charAt(i + 1) == '/')
-      {
-        // no new level but prune the ./
-        i += 2;
-      }
-      else if (i + 2 < length && relativeLoc.charAt(i) == '.' && relativeLoc.charAt(i
+ 1) == '.'
-               && relativeLoc.charAt(i + 2) == '/')
-      {
-        levels += 1;
-        i += 3;
-      }
-    }
-
-    StringBuilder sb = new StringBuilder(currentPath);
-    if (currentPath.endsWith("/"))
-    {
-      sb = sb.deleteCharAt(currentPath.length() - 1);
-    }
-    for (int j = 0; j < levels; j++)
-    {
-      int loc = sb.lastIndexOf("/");
-      if (loc < 0)
-      {
-        throw new IllegalArgumentException("Location: " + relativeLoc
-                                           + "Can't be made relative to: " + currentPath);
-      }
-      sb = sb.delete(loc, sb.length());
-    }
-
-    // now sb should contain root path without trailing / so add one
-    sb = sb.append("/");
-
-    // now add the portion of the relativeLoc that doesn't contain
-    // the relative references
-    sb = sb.append(relativeLoc.substring(i));
-
-    return sb.toString();
-
-  }
-
-}
+/* Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.myfaces.portlet.faces.util;
+
+import java.util.List;
+import java.util.Map;
+
+public class URLUtils
+{
+
+  /**
+   * Borrowed from package oracle.adfinternal.view.faces.share.url.EncoderUtils
+   */
+  public static String appendURLArguments(StringBuilder buffer, String baseURL,
+                                          String[] keysAndValues)
+  {
+
+    // Bug 1814825: the anchor has to stay on the end.
+    int anchorIndex = baseURL.indexOf('#');
+
+    if (anchorIndex >= 0)
+    {
+      buffer.append(baseURL.substring(0, anchorIndex));
+    }
+    else
+    {
+      buffer.append(baseURL);
+    }
+
+    boolean queryAppended = baseURL.indexOf('?') >= 0;
+
+    for (int i = 0; i < keysAndValues.length; i += 2)
+    {
+      String value = keysAndValues[i + 1];
+      if (value != null)
+      {
+        // only append '?' at start if the URL doesn't already contain
+        // arguments
+        if (!queryAppended)
+        {
+          queryAppended = true;
+          buffer.append('?');
+        }
+        else
+        {
+          buffer.append('&');
+        }
+
+        buffer.append(keysAndValues[i]);
+        buffer.append('=');
+        buffer.append(value);
+      }
+    }
+
+    String beforeEncode = buffer.toString();
+    return beforeEncode;
+  }
+
+  /**
+   * Borrowed from package oracle.adfinternal.view.faces.share.url.EncoderUtils
+   */
+  public static String appendURLArguments(String baseURL, String[] keysAndValues)
+  {
+    // buffer length = base + separators + keys + values
+    int bufferLength = baseURL.length() + keysAndValues.length;
+    for (int i = 0; i < keysAndValues.length; i += 2)
+    {
+      String value = keysAndValues[i + 1];
+      if (value != null)
+      {
+        bufferLength += keysAndValues[i].length() + value.length();
+      }
+    }
+
+    StringBuilder buffer = new StringBuilder(bufferLength);
+
+    return appendURLArguments(buffer, baseURL, keysAndValues);
+  }
+  
+  
+  public static String appendURLArguments(StringBuilder buffer, String baseURL,
+                                          Map<String, List<String>> keysAndValues)
+  {
+
+    // Bug 1814825: the anchor has to stay on the end.
+    int anchorIndex = baseURL.indexOf('#');
+
+    if (anchorIndex >= 0)
+    {
+      buffer.append(baseURL.substring(0, anchorIndex));
+    }
+    else
+    {
+      buffer.append(baseURL);
+    }
+
+    boolean queryAppended = baseURL.indexOf('?') >= 0;
+    
+    for (Map.Entry<String, List<String>> entry : keysAndValues.entrySet())
+    {
+      String key = entry.getKey();
+      List<String> values = entry.getValue();
+      
+      if (values == null) continue;
+      
+      for (String value : values)
+      {
+        if (value != null)
+        {
+          // only append '?' at start if the URL doesn't already contain
+          // arguments
+          if (!queryAppended)
+          {
+            queryAppended = true;
+            buffer.append('?');
+          }
+          else
+          {
+            buffer.append('&');
+          }
+
+          buffer.append(key);
+          buffer.append('=');
+          buffer.append(value);
+        }
+      }
+    }
+
+
+    String beforeEncode = buffer.toString();
+    return beforeEncode;
+  }
+  
+  public static String appendURLArguments(String baseURL, Map<String, List<String>>
keysAndValues)
+  {
+    if (keysAndValues != null) 
+    {    
+      return appendURLArguments(new StringBuilder(baseURL.length()), baseURL, keysAndValues);
+    }
+    else
+    {
+      return baseURL;
+    }
+  }
+
+  public static String convertFromRelative(String currentPath, String relativeLoc)
+                                                                                  throws
IllegalArgumentException
+  {
+    // determine if and how many levels we must walk up the currentPath
+    int levels = 0;
+    int i = 0, length = relativeLoc.length();
+    while (i + 1 < length)
+    {
+      if (relativeLoc.charAt(i) != '.')
+      {
+        break;
+      }
+      else if (relativeLoc.charAt(i) == '.' && relativeLoc.charAt(i + 1) == '/')
+      {
+        // no new level but prune the ./
+        i += 2;
+      }
+      else if (i + 2 < length && relativeLoc.charAt(i) == '.' && relativeLoc.charAt(i
+ 1) == '.'
+               && relativeLoc.charAt(i + 2) == '/')
+      {
+        levels += 1;
+        i += 3;
+      }
+    }
+
+    StringBuilder sb = new StringBuilder(currentPath);
+    if (currentPath.endsWith("/"))
+    {
+      sb = sb.deleteCharAt(currentPath.length() - 1);
+    }
+    for (int j = 0; j < levels; j++)
+    {
+      int loc = sb.lastIndexOf("/");
+      if (loc < 0)
+      {
+        throw new IllegalArgumentException("Location: " + relativeLoc
+                                           + "Can't be made relative to: " + currentPath);
+      }
+      sb = sb.delete(loc, sb.length());
+    }
+
+    // now sb should contain root path without trailing / so add one
+    sb = sb.append("/");
+
+    // now add the portion of the relativeLoc that doesn't contain
+    // the relative references
+    sb = sb.append(relativeLoc.substring(i));
+
+    return sb.toString();
+
+  }
+
+}

Propchange: myfaces/portlet-bridge/core/branches/2.0.0-branch/impl/src/main/resources/META-INF/NOTICE
            ('svn:mergeinfo' removed)

Modified: myfaces/portlet-bridge/core/branches/2.0.0-branch/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/branches/2.0.0-branch/pom.xml?rev=1071846&r1=1071845&r2=1071846&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/branches/2.0.0-branch/pom.xml (original)
+++ myfaces/portlet-bridge/core/branches/2.0.0-branch/pom.xml Fri Feb 18 00:29:55 2011
@@ -24,7 +24,7 @@
   <artifactId>portlet-bridge</artifactId>
   <packaging>pom</packaging>
   <name>MyFaces Portlet Bridge</name>
-  <version>2.0.1-SNAPSHOT</version>	 
+  <version>2.0.0.1-PATCH</version>	 
   <inceptionYear>2007</inceptionYear>  
   <description>
   Portlet Bridge for JavaServer Faces is a subproject of Apache MyFaces which provides an



Mime
View raw message