KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > lib > cvsclient > connection > Connection


1 /*****************************************************************************
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14
15  * The Original Software is the CVS Client Library.
16  * The Initial Developer of the Original Software is Robert Greig.
17  * Portions created by Robert Greig are Copyright (C) 2000.
18  * All Rights Reserved.
19
20  * Contributor(s): Robert Greig.
21  *****************************************************************************/

22 package org.netbeans.lib.cvsclient.connection;
23
24 import java.io.*;
25
26 import org.netbeans.lib.cvsclient.command.CommandAbortedException;
27 import org.netbeans.lib.cvsclient.util.*;
28
29 /**
30  * Provides a method for accessing a connection, in order to be able to
31  * communicate using the CVS Protocol. Instances of this interface are used
32  * by the Client class to communicate with the server without being too
33  * concerned with how the communication is taking place or how it was
34  * set up.
35  * @see org.netbeans.lib.cvsclient.Client
36  * @author Robert Greig
37  */

38 public interface Connection {
39     /**
40      * Get a data inputstream for reading data
41      * @return an input stream
42      **/

43     LoggedDataInputStream getInputStream();
44
45     /**
46      * Get an output stream for sending data to the server
47      * @return an output stream
48      **/

49     LoggedDataOutputStream getOutputStream();
50
51     /**
52      * Open a connection with the server. Until this method is called, no
53      * communication with the server can take place. This Client will
54      * call this method before interacting with the server. It is up to
55      * implementing classes to ensure that they are configured to
56      * talk to the server (e.g. port number etc.)
57      * @throws AutenticationException if the connection with the server
58      * cannot be established
59      **/

60     void open() throws AuthenticationException, CommandAbortedException;
61
62     /**
63      * Verify a cnnection with the server. Simply verifies that a connection
64      * could be made, for example that the user name and password are both
65      * acceptable. Does not create input and output stream. For that, use
66      * the open() method.
67      */

68     void verify() throws AuthenticationException;
69
70     /**
71      * Close the connection with the server
72      */

73     void close() throws IOException;
74
75     /**
76      * Returns true to indicate that the connection was successfully established.
77      */

78     boolean isOpen();
79
80     /**
81      * Get the repository
82      */

83     String JavaDoc getRepository();
84     
85     /**
86      * Get the port number, which this connection is actually using.
87      * @return The port number or zero, when the port number does not have sense.
88      */

89     int getPort();
90
91     /**
92      * Modify the underlying inputstream
93      * @param modifier the connection modifier that performs the modifications
94      * @throws IOException if an error occurs modifying the streams
95      */

96     void modifyInputStream(ConnectionModifier modifier) throws IOException;
97
98     /**
99      * Modify the underlying outputstream
100      * @param modifier the connection modifier that performs the modifications
101      * @throws IOException if an error occurs modifying the streams
102      */

103     void modifyOutputStream(ConnectionModifier modifier) throws IOException;
104 }
105
Popular Tags