001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.commons.vfs;
018:
019: /**
020: * An enumerated type that represents a file's type.
021: *
022: * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
023: * @version $Revision: 480428 $ $Date: 2006-11-28 22:15:24 -0800 (Tue, 28 Nov 2006) $
024: */
025: public final class FileType {
026: /**
027: * A folder. May contain other files, and have attributes, but does not
028: * have any data content.
029: */
030: public static final FileType FOLDER = new FileType("folder", true,
031: false, true);
032:
033: /**
034: * A regular file. May have data content and attributes, but cannot
035: * contain other files.
036: */
037: public static final FileType FILE = new FileType("file", false,
038: true, true);
039:
040: /**
041: * A file or folder. May have data content and attributes, and can
042: * contain other files.
043: */
044: public static final FileType FILE_OR_FOLDER = new FileType(
045: "fileOrFolder", true, true, true);
046:
047: /**
048: * A file that does not exist. May not have data content, attributes,
049: * or contain other files.
050: */
051: public static final FileType IMAGINARY = new FileType("imaginary",
052: false, false, false);
053:
054: private final String name;
055: private final boolean hasChildren;
056: private final boolean hasContent;
057: private final boolean hasAttrs;
058:
059: private FileType(final String name, final boolean hasChildren,
060: final boolean hasContent, final boolean hasAttrs) {
061: this .name = name;
062: this .hasChildren = hasChildren;
063: this .hasContent = hasContent;
064: this .hasAttrs = hasAttrs;
065: }
066:
067: /**
068: * Returns the name of this type.
069: */
070: public String toString() {
071: return name;
072: }
073:
074: /**
075: * Returns the name of this type.
076: */
077: public String getName() {
078: return name;
079: }
080:
081: /**
082: * Returns true if files of this type may contain other files.
083: */
084: public boolean hasChildren() {
085: return hasChildren;
086: }
087:
088: /**
089: * Returns true if files of this type may have data content.
090: */
091: public boolean hasContent() {
092: return hasContent;
093: }
094:
095: /**
096: * Returns true if files of this type may have attributes.
097: */
098: public boolean hasAttributes() {
099: return hasAttrs;
100: }
101: }
|