View Javadoc

    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  You may obtain a copy of the License at
    8    *
    9    *      http://www.apache.org/licenses/LICENSE-2.0
    10   *
    11   * Unless required by applicable law or agreed to in writing, software
    12   * distributed under the License is distributed on an "AS IS" BASIS,
    13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14   * See the License for the specific language governing permissions and
    15   * limitations under the License.
    16   */
    17  package org.apache.commons.vfs;
    18
    19  /***
    20   * An enumerated type that represents a file's type.
    21   *
    22   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
    23   * @version $Revision: 480428 $ $Date: 2006-11-29 07:15:24 +0100 (Mi, 29 Nov 2006) $
    24   */
    25  public final class FileType
    26  {
    27      /***
    28       * A folder.  May contain other files, and have attributes, but does not
    29       * have any data content.
    30       */
    31      public static final FileType FOLDER = new FileType("folder", true, false, true);
    32
    33      /***
    34       * A regular file.  May have data content and attributes, but cannot
    35       * contain other files.
    36       */
    37      public static final FileType FILE = new FileType("file", false, true, true);
    38
    39  	/***
    40  	 * A file or folder.  May have data content and attributes, and can
    41  	 * contain other files.
    42  	 */
    43  	public static final FileType FILE_OR_FOLDER = new FileType("fileOrFolder", true, true, true);
    44
    45  	/***
    46       * A file that does not exist.  May not have data content, attributes,
    47       * or contain other files.
    48       */
    49      public static final FileType IMAGINARY = new FileType("imaginary", false, false, false);
    50
    51      private final String name;
    52      private final boolean hasChildren;
    53      private final boolean hasContent;
    54      private final boolean hasAttrs;
    55
    56      private FileType(final String name,
    57                       final boolean hasChildren,
    58                       final boolean hasContent,
    59                       final boolean hasAttrs)
    60      {
    61          this.name = name;
    62          this.hasChildren = hasChildren;
    63          this.hasContent = hasContent;
    64          this.hasAttrs = hasAttrs;
    65      }
    66
    67      /***
    68       * Returns the name of this type.
    69       */
    70      public String toString()
    71      {
    72          return name;
    73      }
    74
    75      /***
    76       * Returns the name of this type.
    77       */
    78      public String getName()
    79      {
    80          return name;
    81      }
    82
    83      /***
    84       * Returns true if files of this type may contain other files.
    85       */
    86      public boolean hasChildren()
    87      {
    88          return hasChildren;
    89      }
    90
    91      /***
    92       * Returns true if files of this type may have data content.
    93       */
    94      public boolean hasContent()
    95      {
    96          return hasContent;
    97      }
    98
    99      /***
    100      * Returns true if files of this type may have attributes.
    101      */
    102     public boolean hasAttributes()
    103     {
    104         return hasAttrs;
    105     }
    106 }