View Javadoc

1   // PassiveParameters.java
2   // $Id: PassiveParameters.java,v 1.3 2006/02/20 04:52:11 sjardine Exp $
3   //
4   // Copyright 2000, Joe Phillips <jaiger@innovationsw.com>
5   // Copyright 2001, 2002 Innovation Software Group, LLC - http://www.innovationsw.com
6   //
7   // This library is free software; you can redistribute it and/or
8   // modify it under the terms of the GNU Library General Public
9   // License as published by the Free Software Foundation; either
10  // version 2 of the License, or (at your option) any later version.
11  //
12  // This library is distributed in the hope that it will be useful,
13  // but WITHOUT ANY WARRANTY; without even the implied warranty of
14  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  // Library General Public License for more details.
16  //
17  // You should have received a copy of the GNU Library General Public
18  // License along with this library; if not, write to the Free
19  // Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  //
21  package gnu.inet.ftp;
22  
23  import java.net.InetAddress;
24  import java.net.UnknownHostException;
25  
26  /***
27   * This class encapsulates the parameters of a passive data connection.
28   */
29  public class PassiveParameters extends Object {
30      // private data members
31      private InetAddress address;
32      private Integer port;
33  
34      //
35      // public methods
36      //
37  
38      /***
39       * create a new instance of PassiveParameters
40       * 
41       * @param address
42       *                IP address
43       * @param port
44       *                TCP/IP port value
45       */
46      public PassiveParameters(String address, int port)
47  	    throws UnknownHostException {
48  	this.address = InetAddress.getByName(address);
49  	this.port = new Integer(port);
50      }
51  
52      /***
53       * get the port value
54       * 
55       * @return port value as int
56       */
57      public int getPort() {
58  	return port.intValue();
59      }
60  
61      /***
62       * get the IP address
63       * 
64       * @return IP address
65       */
66      public InetAddress getInetAddress() {
67  	return address;
68      }
69  
70      /***
71       * compare another PassiveParameters instance to this one.
72       * 
73       * @param other
74       *                the other instance to compare this one with
75       * @return true if the other instance equals this one, false if they are not
76       *         equal
77       */
78      public boolean equals(PassiveParameters other) {
79  	if ((this.port == other.port) && (this.address.equals(other.address))) {
80  	    return true;
81  	}
82  	return false;
83      }
84  
85  }