KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > vfs > FileType


1 /*
2  * Copyright 2002-2005 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.commons.vfs;
17
18 /**
19  * An enumerated type that represents a file's type.
20  *
21  * @author <a HREF="mailto:adammurdoch@apache.org">Adam Murdoch</a>
22  */

23 public final class FileType
24 {
25     /**
26      * A folder. May contain other files, and have attributes, but does not
27      * have any data content.
28      */

29     public static final FileType FOLDER = new FileType("folder", true, false, true);
30
31     /**
32      * A regular file. May have data content and attributes, but cannot
33      * contain other files.
34      */

35     public static final FileType FILE = new FileType("file", false, true, true);
36
37     /**
38      * A file that does not exist. May not have data content, attributes,
39      * or contain other files.
40      */

41     public static final FileType IMAGINARY = new FileType("imaginary", false, false, false);
42
43     private final String JavaDoc name;
44     private final boolean hasChildren;
45     private final boolean hasContent;
46     private final boolean hasAttrs;
47
48     private FileType(final String JavaDoc name,
49                      final boolean hasChildren,
50                      final boolean hasContent,
51                      final boolean hasAttrs)
52     {
53         this.name = name;
54         this.hasChildren = hasChildren;
55         this.hasContent = hasContent;
56         this.hasAttrs = hasAttrs;
57     }
58
59     /**
60      * Returns the name of this type.
61      */

62     public String JavaDoc toString()
63     {
64         return name;
65     }
66
67     /**
68      * Returns the name of this type.
69      */

70     public String JavaDoc getName()
71     {
72         return name;
73     }
74
75     /**
76      * Returns true if files of this type may contain other files.
77      */

78     public boolean hasChildren()
79     {
80         return hasChildren;
81     }
82
83     /**
84      * Returns true if files of this type may have data content.
85      */

86     public boolean hasContent()
87     {
88         return hasContent;
89     }
90
91     /**
92      * Returns true if files of this type may have attributes.
93      */

94     public boolean hasAttributes()
95     {
96         return hasAttrs;
97     }
98 }
99
Popular Tags