You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by ri...@apache.org on 2005/07/07 00:47:59 UTC

svn commit: r209533 - in /incubator/beehive/trunk/netui: src/pageflow/org/apache/beehive/netui/pageflow/internal/ src/util/org/apache/beehive/netui/core/urltemplates/ test/src/junitTests/org/apache/beehive/netui/test/core/urltemplates/

Author: rich
Date: Wed Jul  6 15:47:56 2005
New Revision: 209533

URL: http://svn.apache.org/viewcvs?rev=209533&view=rev
Log:
This is an update from Carlin Rogers for http://issues.apache.org/jira/browse/BEEHIVE-838 : Add a toString(boolean) method to support optional cleanup of unknown tokens in URLTemplate class.

tests: bvt in netui (WinXP)
BB: self (linux)


Modified:
    incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/DefaultTemplatedURLFormatter.java
    incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/core/urltemplates/URLTemplate.java
    incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/urltemplates/URLTemplateTest.java

Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/DefaultTemplatedURLFormatter.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/DefaultTemplatedURLFormatter.java?rev=209533&r1=209532&r2=209533&view=diff
==============================================================================
--- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/DefaultTemplatedURLFormatter.java (original)
+++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/DefaultTemplatedURLFormatter.java Wed Jul  6 15:47:56 2005
@@ -118,6 +118,6 @@
 
         template.substitute( TemplatedURLFormatter.FRAGMENT_TOKEN, fragment );
 
-        return template.toString();
+        return template.format();
     }
 }

Modified: incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/core/urltemplates/URLTemplate.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/core/urltemplates/URLTemplate.java?rev=209533&r1=209532&r2=209533&view=diff
==============================================================================
--- incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/core/urltemplates/URLTemplate.java (original)
+++ incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/core/urltemplates/URLTemplate.java Wed Jul  6 15:47:56 2005
@@ -230,7 +230,20 @@
      */
     public String toString()
     {
-        return toString( true );
+        return format( true );
+    }
+
+    /**
+     * Return the String representation of the URL after replacing
+     * the tokens in the template with their associated values. If
+     * there is no value for a token, the token is discarded/removed.
+     * I.E. It will not be part of the returned String.
+     *
+     * @return the url
+     */
+    public String format()
+    {
+        return format( true );
     }
 
     /**
@@ -244,7 +257,7 @@
      *        or leave the unset tokens in the URL.
      * @return the url
      */
-    public String toString( boolean removeUnsetTokens )
+    public String format( boolean removeUnsetTokens )
     {
         // template should already have been parsed with a call to
         if ( !_isParsed )

Modified: incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/urltemplates/URLTemplateTest.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/urltemplates/URLTemplateTest.java?rev=209533&r1=209532&r2=209533&view=diff
==============================================================================
--- incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/urltemplates/URLTemplateTest.java (original)
+++ incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/urltemplates/URLTemplateTest.java Wed Jul  6 15:47:56 2005
@@ -132,10 +132,10 @@
         tokensAndValues.put( "{url:path}", "/my/path" );
         tokensAndValues.put( "{url:queryString}", "param1=true&foo" );
         urlTemplate.substitute( tokensAndValues );
-        assertEquals( intermediateResult, urlTemplate.toString() );
-        assertEquals( intermediateResultWithToken, urlTemplate.toString( false ) );
+        assertEquals( intermediateResult, urlTemplate.format() );
+        assertEquals( intermediateResultWithToken, urlTemplate.format( false ) );
         urlTemplate.substitute( "{url:currentPage}", "&cur=arb" );
-        assertEquals( result, urlTemplate.toString() );
+        assertEquals( result, urlTemplate.format() );
     }
 
     public void testArbitraryTokenTemplate()
@@ -158,6 +158,6 @@
         tokensAndValues.put( "{token-2}", "%20" );
         tokensAndValues.put( "{token_1}", "xyz" );
         urlTemplate.substitute( tokensAndValues );
-        assertEquals( result, urlTemplate.toString() );
+        assertEquals( result, urlTemplate.format() );
     }
 }