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 */
017package org.apache.commons.vfs2;
018
019/**
020 * An enumerated type that represents a file's type.
021 */
022public enum FileType
023{
024    /**
025     * A folder.  May contain other files, and have attributes, but does not
026     * have any data content.
027     */
028    FOLDER("folder", true, false, true),
029
030    /**
031     * A regular file.  May have data content and attributes, but cannot
032     * contain other files.
033     */
034    FILE("file", false, true, true),
035
036    /**
037     * A file or folder.  May have data content and attributes, and can
038     * contain other files.
039     */
040    FILE_OR_FOLDER("fileOrFolder", true, true, true),
041
042    /**
043     * A file that does not exist.  May not have data content, attributes,
044     * or contain other files.
045     */
046    IMAGINARY("imaginary", false, false, false);
047
048    /** The name of the FileType */
049    private final String name;
050
051    /** true if the FileType can have children */
052    private final boolean hasChildren;
053
054    /** true if the FileType can have content */
055    private final boolean hasContent;
056
057    /** true if the FileType has attributes */
058    private final boolean hasAttrs;
059
060    private FileType(final String name,
061                     final boolean hasChildren,
062                     final boolean hasContent,
063                     final boolean hasAttrs)
064    {
065        this.name = name;
066        this.hasChildren = hasChildren;
067        this.hasContent = hasContent;
068        this.hasAttrs = hasAttrs;
069    }
070
071    /**
072     * Returns the name of this type.
073     * @return The name of this type.
074     */
075    @Override
076    public String toString()
077    {
078        return name;
079    }
080
081    /**
082     * Returns the name of this type.
083     * @return The name of the type.
084     */
085    public String getName()
086    {
087        return name;
088    }
089
090    /**
091     * Returns true if files of this type may contain other files.
092     * @return true if files can contain other files.
093     */
094    public boolean hasChildren()
095    {
096        return hasChildren;
097    }
098
099    /**
100     * Returns true if files of this type may have data content.
101     * @return true if files can have content.
102     */
103    public boolean hasContent()
104    {
105        return hasContent;
106    }
107
108    /**
109     * Returns true if files of this type may have attributes.
110     * @return true if files can have attributes
111     */
112    public boolean hasAttributes()
113    {
114        return hasAttrs;
115    }
116}