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.vfs2; 18 19 /** 20 * An enumerated type for file name scope, used when resolving a name relative to a file. 21 */ 22 public enum NameScope { 23 24 /** 25 * Resolve against the children of the base file. The name is resolved as described by {@link #FILE_SYSTEM}. 26 * However, an exception is thrown if the resolved file is not a direct child of the base file. 27 */ 28 CHILD("child"), 29 30 /** 31 * Resolve against the descendants of the base file. The name is resolved as described by {@link #FILE_SYSTEM}. 32 * However, an exception is thrown if the resolved file is not a descendent of the base file. 33 */ 34 DESCENDENT("descendent"), 35 36 /** 37 * Resolve against the descendants of the base file. The name is resolved as described by {@link #FILE_SYSTEM}. 38 * However, an exception is thrown if the resolved file is not a descendent of the base file, or the base files 39 * itself. 40 */ 41 DESCENDENT_OR_SELF("descendent_or_self"), 42 43 /** 44 * Resolve against files in the same file system as the base file. 45 * <p> 46 * If the supplied name is an absolute path, then it is resolved relative to the root of the file system that the 47 * base file belongs to. If a relative name is supplied, then it is resolved relative to the base file. 48 * </p> 49 * <p> 50 * The path may use any mix of {@code /}, {@code \}, or file system specific separators to separate elements in the 51 * path. It may also contain {@code .} and {@code ..} elements. 52 * </p> 53 * <p> 54 * A path is considered absolute if it starts with a separator character, and relative if it does not. 55 * </p> 56 */ 57 FILE_SYSTEM("filesystem"); 58 59 /** The name */ 60 private final String realName; 61 62 NameScope(final String name) { 63 this.realName = name; 64 } 65 66 /** 67 * Returns the name of the scope. 68 * 69 * @return The name of the scope. 70 */ 71 @Override 72 public String toString() { 73 return realName; 74 } 75 76 /** 77 * Returns the name of the scope. 78 * 79 * @return The name of the scope. 80 */ 81 public String getName() { 82 return realName; 83 } 84 }