directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r156127 - incubator/directory/network/mina/trunk/src/java/org/apache/mina/common/TransportType.java
Date Fri, 04 Mar 2005 03:37:00 GMT
Author: trustin
Date: Thu Mar  3 19:36:58 2005
New Revision: 156127

URL: http://svn.apache.org/viewcvs?view=rev&rev=156127
Log:
Added TransportType.getInstance(String) as Enrique requested.

Modified:
    incubator/directory/network/mina/trunk/src/java/org/apache/mina/common/TransportType.java

Modified: incubator/directory/network/mina/trunk/src/java/org/apache/mina/common/TransportType.java
URL: http://svn.apache.org/viewcvs/incubator/directory/network/mina/trunk/src/java/org/apache/mina/common/TransportType.java?view=diff&r1=156126&r2=156127
==============================================================================
--- incubator/directory/network/mina/trunk/src/java/org/apache/mina/common/TransportType.java
(original)
+++ incubator/directory/network/mina/trunk/src/java/org/apache/mina/common/TransportType.java
Thu Mar  3 19:36:58 2005
@@ -50,6 +50,40 @@
     public static final TransportType VM_PIPE = new TransportType( "VM_PIPE",
             false );
 
+    /**
+     * Returns the transport type of the specified name.  Here are the list
+     * of available names:
+     * <ul>
+     *   <li><code>"socket"</code> or <code>"tcp"</code> -
{@link #SOCKET}</li>
+     *   <li><code>"datagram"</code> or <code>"udp"</code>
- {@link #DATAGRAM}</li>
+     *   <li><code>"vm_pipe"</code> - {@link #VM_PIPE}</li>
+     * </ul>
+     * 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)
+    {
+        if( "socket".equalsIgnoreCase(name) || "tcp".equalsIgnoreCase(name) )
+        {
+            return SOCKET;
+        }
+
+        if( "datagram".equalsIgnoreCase(name) || "udp".equalsIgnoreCase(name) )
+        {
+            return DATAGRAM;
+        }
+        
+        if( "vm_pipe".equalsIgnoreCase(name) )
+        {
+            return VM_PIPE;
+        }
+        
+        throw new IllegalArgumentException("Unknown transport type name: " + name);
+    }
+
     private final String strVal;
 
     private final boolean stateless;



Mime
View raw message