View Javadoc

1   // PassiveConnection.java
2   // $Id: PassiveConnection.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.io.IOException;
24  import java.net.Socket;
25  import java.net.UnknownHostException;
26  
27  /***
28   * This class encapsulates the parameters of a passive data connection.
29   */
30  public class PassiveConnection extends Object {
31  
32      // private data members
33      private PassiveParameters parameters;
34      private Socket sock;
35  
36      //
37      // public methods
38      //
39  
40      /***
41       * create a new instance of PassiveParameters
42       * 
43       * @param parameters
44       *                passive connection parameters
45       */
46      public PassiveConnection(PassiveParameters parameters)
47  	    throws UnknownHostException, IOException {
48  	this.parameters = parameters;
49  	this.sock = new Socket(parameters.getInetAddress(), parameters
50  		.getPort());
51      }
52  
53      /***
54       * get the passive parameters
55       * 
56       * @return passive parameter data
57       */
58      public PassiveParameters getPassiveParameters() {
59  	return parameters;
60      }
61  
62      /***
63       * get the socket for this passive connection
64       * 
65       * @return the socket for this passive connection
66       */
67      public Socket getSocket() {
68  	return this.sock;
69      }
70  
71      /***
72       * compare another PassiveConnection instance to this one.
73       * 
74       * @param other
75       *                the other instance to compare this one with
76       * @return true if the other instance equals this one, false if they are not
77       *         equal
78       */
79      public boolean equals(PassiveConnection other) {
80  	if (this.parameters.equals(other.parameters)) {
81  	    return true;
82  	}
83  	return false;
84      }
85  
86  }
87  
88  // PassiveConnection.java