View Javadoc

    1   /*
    2    *  Licensed to the Apache Software Foundation (ASF) under one
    3    *  or more contributor license agreements.  See the NOTICE file
    4    *  distributed with this work for additional information
    5    *  regarding copyright ownership.  The ASF licenses this file
    6    *  to you under the Apache License, Version 2.0 (the
    7    *  "License"); you may not use this file except in compliance
    8    *  with the License.  You may obtain a copy of the License at
    9    *
    10   *    http://www.apache.org/licenses/LICENSE-2.0
    11   *
    12   *  Unless required by applicable law or agreed to in writing,
    13   *  software distributed under the License is distributed on an
    14   *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    15   *  KIND, either express or implied.  See the License for the
    16   *  specific language governing permissions and limitations
    17   *  under the License.
    18   *
    19   */
    20  package org.apache.mina.transport.vmpipe;
    21
    22  import java.net.SocketAddress;
    23
    24  /**
    25   * A {@link SocketAddress} which represents in-VM pipe port number.
    26   *
    27   * @author The Apache Directory Project (mina-dev@directory.apache.org)
    28   * @version $Rev: 587373 $, $Date: 2007-10-23 04:54:05 +0200 (Tue, 23 Oct 2007) $
    29   */
    30  public class VmPipeAddress extends SocketAddress implements Comparable<VmPipeAddress> {
    31      private static final long serialVersionUID = 3257844376976830515L;
    32
    33      private final int port;
    34
    35      /**
    36       * Creates a new instance with the specifid port number.
    37       */
    38      public VmPipeAddress(int port) {
    39          this.port = port;
    40      }
    41
    42      /**
    43       * Returns the port number.
    44       */
    45      public int getPort() {
    46          return port;
    47      }
    48
    49      public int hashCode() {
    50          return port;
    51      }
    52
    53      public boolean equals(Object o) {
    54          if (o == null)
    55              return false;
    56          if (this == o)
    57              return true;
    58          if (o instanceof VmPipeAddress) {
    59              VmPipeAddress that = (VmPipeAddress) o;
    60              return this.port == that.port;
    61          }
    62
    63          return false;
    64      }
    65
    66      public int compareTo(VmPipeAddress o) {
    67          return this.port - o.port;
    68      }
    69
    70      public String toString() {
    71          return "vm:" + port;
    72      }
    73  }