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 2004/12/01 20:21:04 UTC
svn commit: r109371 - in incubator/beehive/trunk/netui/src: tomcat-webapp/5x/META-INF tomcat-webapp/5x/META-INF/services util/org/apache/beehive/netui/core/urls
Author: rich
Date: Wed Dec 1 11:21:03 2004
New Revision: 109371
URL: http://svn.apache.org/viewcvs?view=rev&rev=109371
Log:
Some small mods to MutableURI:
- Changed ArrayList to List wherever it appeared in APIs (return values, method arguments).
- Fixed an NPE in getParameters when there are no parameters.
- Changed addParameters() to accept an empty map of parameters.
Also added the missing META-INF directory for beehive-netui-tomcat-webapp-5x.jar.
DRT: netui (WinXP)
BB: self (linux)
Added:
incubator/beehive/trunk/netui/src/tomcat-webapp/5x/META-INF/
incubator/beehive/trunk/netui/src/tomcat-webapp/5x/META-INF/services/
incubator/beehive/trunk/netui/src/tomcat-webapp/5x/META-INF/services/org.apache.beehive.netui.pageflow.ServerAdapter
Modified:
incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/core/urls/MutableURI.java
Added: incubator/beehive/trunk/netui/src/tomcat-webapp/5x/META-INF/services/org.apache.beehive.netui.pageflow.ServerAdapter
Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tomcat-webapp/5x/META-INF/services/org.apache.beehive.netui.pageflow.ServerAdapter?view=auto&rev=109371
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/netui/src/tomcat-webapp/5x/META-INF/services/org.apache.beehive.netui.pageflow.ServerAdapter Wed Dec 1 11:21:03 2004
@@ -0,0 +1 @@
+org.apache.beehive.netui.tomcat.TomcatServerAdapter
Modified: incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/core/urls/MutableURI.java
Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/core/urls/MutableURI.java?view=diff&rev=109371&p1=incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/core/urls/MutableURI.java&r1=109370&p2=incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/core/urls/MutableURI.java&r2=109371
==============================================================================
--- incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/core/urls/MutableURI.java (original)
+++ incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/core/urls/MutableURI.java Wed Dec 1 11:21:03 2004
@@ -28,6 +28,7 @@
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
+import java.util.HashMap;
/**
* Class for creating URIs.
@@ -60,11 +61,15 @@
private String _path;
/** Query parameters */
- private LinkedHashMap< String, ArrayList< String > > _params;
+ private LinkedHashMap< String, List< String > > _params;
/** Fragment */
private String _fragment;
+ private static final List< String > EMPTY_LIST = Collections.unmodifiableList( new ArrayList< String >( 0 ) );
+ private static final Map< String, List< String > > EMPTY_MAP =
+ Collections.unmodifiableMap( new HashMap< String, List< String > >() );
+
/**
* Constructs a <code>MutableURI</code>.
*/
@@ -444,10 +449,10 @@
if ( _params == null )
{
- _params = new LinkedHashMap< String, ArrayList< String > >();
+ _params = new LinkedHashMap< String, List< String > >();
}
- ArrayList< String > values = _params.get( name );
+ List< String > values = _params.get( name );
if ( values == null )
{
values = new ArrayList< String >();
@@ -472,14 +477,19 @@
*/
public void addParameters( Map newParams, boolean encoded, String encoding )
{
- if ( newParams == null || newParams.size() == 0 )
+ if ( newParams == null )
{
- throw new IllegalArgumentException( "Cannot add null or empty map of parameters." );
+ throw new IllegalArgumentException( "Cannot add null map of parameters." );
+ }
+
+ if ( newParams.size() == 0 )
+ {
+ return;
}
if ( _params == null )
{
- _params = new LinkedHashMap< String, ArrayList< String > >();
+ _params = new LinkedHashMap< String, List< String > >();
}
Iterator keys = newParams.keySet().iterator();
@@ -490,7 +500,7 @@
if ( !encoded ) { encodedName = encode( name, encoding ); }
- ArrayList< String > values = _params.get( encodedName );
+ List< String > values = _params.get( encodedName );
if ( values == null )
{
values = new ArrayList< String >();
@@ -529,7 +539,7 @@
}
}
- private static void addValue( ArrayList< String > list, String value, boolean encoded, String encoding )
+ private static void addValue( List< String > list, String value, boolean encoded, String encoding )
{
if ( !encoded )
{
@@ -551,7 +561,7 @@
{
if ( _params == null ) { return null; }
- ArrayList< String > values = _params.get( name );
+ List< String > values = _params.get( name );
if ( values != null && values.size() > 0 )
{
return values.get( 0 );
@@ -572,7 +582,7 @@
{
if ( _params == null )
{
- return Collections.unmodifiableList( new ArrayList< String >( 0 ) );
+ return EMPTY_LIST;
}
else
{
@@ -585,9 +595,16 @@
*
* @return an unmodifiable {@link java.util.Map} of names and values for all parameters
*/
- public Map< String, ArrayList< String > > getParameters()
+ public Map< String, List< String > > getParameters()
{
- return Collections.unmodifiableMap( _params );
+ if ( _params == null )
+ {
+ return EMPTY_MAP;
+ }
+ else
+ {
+ return Collections.unmodifiableMap( _params );
+ }
}
/**
@@ -789,7 +806,7 @@
( _path == testURI.getPath() || ( _path != null && _path.equals( testURI.getPath() ) ) ) &&
( _fragment == testURI.getFragment() || ( _fragment != null && _fragment.equals( testURI.getFragment() ) ) ) )
{
- Map< String, ArrayList< String > > testParams = testURI.getParameters();
+ Map< String, List< String > > testParams = testURI.getParameters();
if ( ( _params == null && testParams == null ) ||
( _params != null && _params.equals( testParams ) ) ) {