Author: proyal
Date: Sun Nov 5 14:53:17 2006
New Revision: 471557
URL: http://svn.apache.org/viewvc?view=rev&rev=471557
Log:
generics
Modified:
directory/branches/mina/1.2/core/src/main/java/org/apache/mina/common/TransportType.java
Modified: directory/branches/mina/1.2/core/src/main/java/org/apache/mina/common/TransportType.java
URL: http://svn.apache.org/viewvc/directory/branches/mina/1.2/core/src/main/java/org/apache/mina/common/TransportType.java?view=diff&rev=471557&r1=471556&r2=471557
==============================================================================
--- directory/branches/mina/1.2/core/src/main/java/org/apache/mina/common/TransportType.java
(original)
+++ directory/branches/mina/1.2/core/src/main/java/org/apache/mina/common/TransportType.java
Sun Nov 5 14:53:17 2006
@@ -6,16 +6,16 @@
* 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.
- *
+ * under the License.
+ *
*/
package org.apache.mina.common;
@@ -39,16 +39,16 @@
* <p>
* You can also create your own transport type. Please refer to
* {@link #TransportType(String[], boolean)}.
- *
+ *
* @author The Apache Directory Project (mina-dev@directory.apache.org)
* @version $Rev$, $Date$
*/
public final class TransportType implements Serializable
{
private static final long serialVersionUID = 3258132470497883447L;
-
- private static final Map name2type = new HashMap();
-
+
+ private static final Map<String,TransportType> name2type = new HashMap<String,
TransportType>();
+
private static void register( String[] names, TransportType type )
{
synchronized( name2type )
@@ -82,47 +82,47 @@
new TransportType( new String[] { "DATAGRAM", "UDP" }, true );
/**
- * Transport type: in-VM pipe (Registry name: <tt>"VM_PIPE"</tt>)
+ * Transport type: in-VM pipe (Registry name: <tt>"VM_PIPE"</tt>)
* Please refer to
* <a href="../protocol/vmpipe/package-summary.htm"><tt>org.apache.mina.protocol.vmpipe</tt></a>
* package.
*/
public static final TransportType VM_PIPE =
new TransportType( new String[] { "VM_PIPE" }, Object.class, false );
-
+
/**
* Returns the transport type of the specified name.
* All names are case-insensitive.
- *
+ *
* @param name the name of the transport type
* @return the transport type
* @throws IllegalArgumentException if the specified name is not available.
*/
public static TransportType getInstance( String name )
{
- TransportType type = (TransportType) name2type.get( name.toUpperCase() );
+ TransportType type = name2type.get( name.toUpperCase() );
if( type != null )
{
return type;
}
-
+
throw new IllegalArgumentException("Unknown transport type name: " + name);
}
private final String[] names;
private final transient boolean connectionless;
-
+
private final transient Class envelopeType;
/**
* Creates a new instance. New transport type is automatically registered
* to internal registry so that you can look it up using {@link #getInstance(String)}.
- *
+ *
* @param names the name or aliases of this transport type
* @param connectionless <tt>true</tt> if and only if this transport type
is connectionless
- *
+ *
* @throws IllegalArgumentException if <tt>names</tt> are already registered
or empty
*/
public TransportType( String[] names, boolean connectionless )
@@ -133,10 +133,10 @@
/**
* Creates a new instance. New transport type is automatically registered
* to internal registry so that you can look it up using {@link #getInstance(String)}.
- *
+ *
* @param names the name or aliases of this transport type
* @param connectionless <tt>true</tt> if and only if this transport type
is connectionless
- *
+ *
* @throws IllegalArgumentException if <tt>names</tt> are already registered
or empty
*/
public TransportType( String[] names, Class envelopeType, boolean connectionless )
@@ -160,7 +160,7 @@
{
throw new NullPointerException( "strVals[" + i + "]" );
}
-
+
names[ i ] = names[ i ].toUpperCase();
}
@@ -178,31 +178,32 @@
{
return connectionless;
}
-
+
public Class getEnvelopeType()
{
return envelopeType;
}
-
+
/**
* Returns the known names of this transport type.
*/
- public Set getNames()
+ public Set<String> getNames()
{
- Set result = new TreeSet();
+ Set<String> result = new TreeSet<String>();
for( int i = names.length - 1; i >= 0; i -- )
{
result.add( names[ i ] );
}
-
+
return result;
}
+ @Override
public String toString()
{
return names[0];
}
-
+
private Object readResolve() throws ObjectStreamException
{
for( int i = names.length - 1; i >= 0; i -- )
@@ -216,7 +217,7 @@
// ignore
}
}
-
+
throw new InvalidObjectException( "Unknown transport type." );
}
}
|