KickJava   Java API By Example, From Geeks To Geeks.

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


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  * Describes checkout/tag/update information for a file.
25  * The fields in instances of this object are populated by response handlers.
26  *
27  * @author Thomas Singer
28  */

29 public class DefaultFileInfoContainer extends FileInfoContainer {
30
31     public static final String JavaDoc PERTINENT_STATE = "Y"; //NOI18N
32
public static final String JavaDoc MERGED_FILE = "G"; //NOI18N
33
private File file;
34
35     private String JavaDoc type;
36
37     public DefaultFileInfoContainer() {
38     }
39
40     /**
41      * Returns the associated file.
42      */

43     public File getFile() {
44         return file;
45     }
46
47     /**
48      * Returns true if the associated file is a directory.
49      */

50     public boolean isDirectory() {
51         File file = getFile();
52         if (file == null) {
53             return false;
54         }
55         return file.isDirectory();
56     }
57
58     /**
59      * Sets the associated file.
60      */

61     public void setFile(File file) {
62         this.file = file;
63     }
64
65     /**
66      * Returns the type.
67      * Mostly the type value equals to the states returned by update and tag command.
68      * see description in cvs manual.
69      * Some states are added:
70      * G - file was merged (when using the cvs update -j <rev> <file> command.
71      * D - file was deleted - no longer pertinent.
72      */

73     public String JavaDoc getType() {
74         return type;
75     }
76
77     /**
78      * Sets the type.
79      */

80     public void setType(String JavaDoc type) {
81         this.type = type;
82     }
83
84     /**
85      * Return a string representation of this object. Useful for debugging.
86      */

87     public String JavaDoc toString() {
88         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
89         buffer.append(type);
90         buffer.append(" "); //NOI18N
91
if (isDirectory()) {
92             buffer.append("Directory "); //NOI18N
93
}
94         buffer.append(file != null ? file.getAbsolutePath()
95                       : "null"); //NOI18N
96
return buffer.toString();
97     }
98 }
99
Popular Tags