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