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 for file name scope, used when resolving a name relative to a file.
021 */
022public enum NameScope {
023
024    /**
025     * Resolve against the children of the base file. The name is resolved as described by {@link #FILE_SYSTEM}.
026     * However, an exception is thrown if the resolved file is not a direct child of the base file.
027     */
028    CHILD("child"),
029
030    /**
031     * Resolve against the descendants of the base file. The name is resolved as described by {@link #FILE_SYSTEM}.
032     * However, an exception is thrown if the resolved file is not a descendent of the base file.
033     */
034    DESCENDENT("descendent"),
035
036    /**
037     * Resolve against the descendants of the base file. The name is resolved as described by {@link #FILE_SYSTEM}.
038     * However, an exception is thrown if the resolved file is not a descendent of the base file, or the base files
039     * itself.
040     */
041    DESCENDENT_OR_SELF("descendent_or_self"),
042
043    /**
044     * Resolve against files in the same file system as the base file.
045     * <p>
046     * If the supplied name is an absolute path, then it is resolved relative to the root of the file system that the
047     * base file belongs to. If a relative name is supplied, then it is resolved relative to the base file.
048     * </p>
049     * <p>
050     * The path may use any mix of {@code /}, {@code \}, or file system specific separators to separate elements in the
051     * path. It may also contain {@code .} and {@code ..} elements.
052     * </p>
053     * <p>
054     * A path is considered absolute if it starts with a separator character, and relative if it does not.
055     * </p>
056     */
057    FILE_SYSTEM("filesystem");
058
059    /** The name */
060    private final String realName;
061
062    NameScope(final String name) {
063        realName = name;
064    }
065
066    /**
067     * Returns the name of the scope.
068     *
069     * @return The name of the scope.
070     */
071    public String getName() {
072        return realName;
073    }
074
075    /**
076     * Returns the name of the scope.
077     *
078     * @return The name of the scope.
079     */
080    @Override
081    public String toString() {
082        return realName;
083    }
084}