KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > lib > cvsclient > file > FileHandler


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.file;
23
24 import java.io.*;
25 import java.util.*;
26
27 import org.netbeans.lib.cvsclient.command.*;
28 import org.netbeans.lib.cvsclient.request.*;
29 import org.netbeans.lib.cvsclient.util.*;
30
31 /**
32  * Handles the reading and writing of files to and from the server. Different
33  * implementations of this interface can use different formats for sending or
34  * receiving the files, for example gzipped format.
35  * @author Robert Greig
36  */

37 public interface FileHandler {
38     /**
39      * Transmit a text file to the server, using the standard CVS protocol
40      * conventions. CR/LFs are converted to the Unix format.
41      * @param file the file to transmit
42      * @param dos the data outputstream on which to transmit the file
43      */

44     void transmitTextFile(File file, LoggedDataOutputStream dos)
45         throws IOException;
46
47     /**
48      * Transmit a binary file to the server, using the standard CVS protocol
49      * conventions.
50      * @param file the file to transmit
51      * @param dos the data outputstream on which to transmit the file
52      */

53     void transmitBinaryFile(File file, LoggedDataOutputStream dos)
54         throws IOException;
55
56      /**
57      * Write (either create or replace) a text file on the local machine with
58      * one read from the server.
59      * @param path the absolute path of the file, (including the file name).
60      * @param mode the mode of the file
61      * @param dis the stream to read the file from, as bytes
62      * @param length the number of bytes to read
63      */

64     void writeTextFile(String JavaDoc path, String JavaDoc mode, LoggedDataInputStream dis,
65                    int length) throws IOException;
66
67     /**
68      * Merge a text file on the local machine with
69      * the diff from the server. (it uses the RcsDiff response format
70      * - see cvsclient.ps for details)
71      * @param path the absolute path of the file, (including the file name).
72      * @param mode the mode of the file
73      * @param dis the stream to read the file from, as bytes
74      * @param length the number of bytes to read
75      */

76     void writeRcsDiffFile(String JavaDoc path, String JavaDoc mode, LoggedDataInputStream dis,
77                           int length) throws IOException;
78
79     /**
80      * Write (either create or replace) a text file on the local machine with
81      * one read from the server.
82      * @param path the absolute path of the file, (including the file name).
83      * @param mode the mode of the file
84      * @param dis the stream to read the file from, as bytes
85      * @param length the number of bytes to read
86      */

87     void writeBinaryFile(String JavaDoc path, String JavaDoc mode, LoggedDataInputStream dis,
88                          int length) throws IOException;
89
90     /**
91      * Remove the specified file from the local disk.
92      * If the file does not exist, the operation does nothing.
93
94      * @param pathname the full path to the file to remove
95      * @throws IOException if an IO error occurs while removing the file
96      */

97     void removeLocalFile(String JavaDoc pathname) throws IOException;
98
99     /**
100      * Rename the local file
101      * If the destination file exists, the operation does nothing.
102      *
103      * @param pathname the full path to the file to rename
104      * @param newName the new name of the file (not the full path)
105      * @throws IOException if an IO error occurs while renaming the file
106      */

107     void renameLocalFile(String JavaDoc pathname, String JavaDoc newName) throws IOException;
108
109     /**
110      * Set the modified date of the next file to be written. The next call
111      * to writeFile will use this date.
112      * @param modifiedDate the date the file should be marked as modified
113      */

114     void setNextFileDate(Date modifiedDate);
115
116     /**
117      * Get any requests that must be sent before commands are sent, to init
118      * this file handler.
119      * @return an array of Requests that must be sent
120      */

121     Request[] getInitialisationRequests();
122
123     /**
124      * Sets the global options.
125      * This can be useful to detect, whether local files should be made read-only.
126      */

127     void setGlobalOptions(GlobalOptions globalOptions);
128 }
129
Popular Tags