View Javadoc

1   /*
2    * @(#) $Id: VmPipeAddress.java 210062 2005-07-11 03:52:38Z trustin $
3    */
4   package org.apache.mina.protocol.vmpipe;
5   
6   import java.net.SocketAddress;
7   
8   /***
9    * A {@link SocketAddress} which represents in-VM pipe port number.
10   * 
11   * @author Trustin Lee (trustin@apache.org)
12   * @version $Rev: 210062 $, $Date: 2005-07-11 12:52:38 +0900 $
13   */
14  public class VmPipeAddress extends SocketAddress implements Comparable
15  {
16      private static final long serialVersionUID = 3257844376976830515L;
17  
18  	private final int port;
19  
20      /***
21       * Creates a new instance with the specifid port number.
22       */
23      public VmPipeAddress( int port )
24      {
25          this.port = port;
26      }
27  
28      /***
29       * Returns the port number.
30       */
31      public int getPort()
32      {
33          return port;
34      }
35  
36      public int hashCode()
37      {
38          return port;
39      }
40  
41      public boolean equals( Object o )
42      {
43          if( o == null )
44              return false;
45          if( this == o )
46              return true;
47          if( o instanceof VmPipeAddress )
48          {
49              VmPipeAddress that = ( VmPipeAddress ) o;
50              return this.port == that.port;
51          }
52  
53          return false;
54      }
55  
56      public int compareTo( Object o )
57      {
58          return this.port - ( ( VmPipeAddress ) o ).port;
59      }
60  
61      public String toString()
62      {
63          return "vm:" + port;
64      }
65  }