KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > lib > cvsclient > command > PipedFileInformation


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 NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.lib.cvsclient.command;
20
21 import java.io.*;
22
23 /**
24  * Contains intercepted infomation from command standard output.
25  * Actula data are held in temporary file.
26  *
27  */

28 public class PipedFileInformation extends FileInfoContainer {
29     private File file;
30
31     private String JavaDoc repositoryRevision;
32
33     private String JavaDoc repositoryFileName;
34
35     private File tempFile;
36
37     private OutputStream tmpStream;
38
39     public PipedFileInformation(File tempFile) {
40         this.tempFile = tempFile;
41         //this.tempFile.deleteOnExit();
42
try {
43             tmpStream = new BufferedOutputStream(new FileOutputStream(tempFile));
44         }
45         catch (IOException ex) {
46             // TODO
47
}
48     }
49
50     /**
51      * Returns the original file. For piped content see {@link #getTempFile()}.
52      */

53     public File getFile() {
54         return file;
55     }
56
57     /**
58      * Sets the original file.
59      */

60     protected void setFile(File file) {
61         this.file = file;
62     }
63
64     /**
65      * Returns the revision of the incoming file.
66      */

67     public String JavaDoc getRepositoryRevision() {
68         return repositoryRevision;
69     }
70
71     /**
72      * Sets the revision of the incoming file.
73      */

74     protected void setRepositoryRevision(String JavaDoc repositoryRevision) {
75         this.repositoryRevision = repositoryRevision;
76     }
77
78     /**
79      * Returns the filename in the repository.
80      */

81     public String JavaDoc getRepositoryFileName() {
82         return repositoryFileName;
83     }
84
85     /**
86      * Sets the repository filename.
87      */

88     protected void setRepositoryFileName(String JavaDoc repositoryFileName) {
89         this.repositoryFileName = repositoryFileName;
90     }
91
92     /**
93      * Adds the specified line to the temporary file.
94      */

95     protected void addToTempFile(byte[] bytes) throws IOException {
96         if (tmpStream != null) {
97             tmpStream.write(bytes);
98         }
99     }
100     /**
101      * Adds the specified line to the temporary file.
102      */

103     public void addToTempFile(byte[] bytes, int len) throws IOException {
104         if (tmpStream != null) {
105             tmpStream.write(bytes, 0, len);
106         }
107     }
108
109     protected void closeTempFile() throws IOException {
110         if (tmpStream != null) {
111             tmpStream.flush();
112             tmpStream.close();
113         }
114     }
115
116     public File getTempFile() {
117         return tempFile;
118     }
119
120 }
121
Popular Tags