KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > vfs > NameScope


1 /*
2  * Copyright 2002-2005 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.commons.vfs;
17
18 /**
19  * An enumerated type for file name scope, used when resolving a name relative
20  * to a file.
21  *
22  * @author <a HREF="mailto:adammurdoch@apache.org">Adam Murdoch</a>
23  */

24 public final class NameScope
25 {
26     /**
27      * Resolve against the children of the base file. The name is resolved
28      * as described by {@link #FILE_SYSTEM}. However, an exception is
29      * thrown if the resolved file is not a direct child of the base file.
30      */

31     public static final NameScope CHILD = new NameScope("child");
32
33     /**
34      * Resolve against the descendents of the base file. The name is resolved
35      * as described by {@link #FILE_SYSTEM}. However, an exception is thrown
36      * if the resolved file is not a descendent of the base file.
37      */

38     public static final NameScope DESCENDENT = new NameScope("descendent");
39
40     /**
41      * Resolve against the descendents of the base file. The name is resolved
42      * as described by {@link #FILE_SYSTEM}. However, an exception is thrown
43      * if the resolved file is not a descendent of the base file, or the base
44      * files itself.
45      */

46     public static final NameScope DESCENDENT_OR_SELF =
47         new NameScope("descendent_or_self");
48
49     /**
50      * Resolve against files in the same file system as the base file.
51      * <p/>
52      * <p>If the supplied name is an absolute path, then it is resolved
53      * relative to the root of the file system that the base file belongs to.
54      * If a relative name is supplied, then it is resolved relative to the base
55      * file.
56      * <p/>
57      * <p>The path may use any mix of <code>/</code>, <code>\</code>, or file
58      * system specific separators to separate elements in the path. It may
59      * also contain <code>.</code> and <code>..</code> elements.
60      * <p/>
61      * <p>A path is considered absolute if it starts with a separator character,
62      * and relative if it does not.
63      */

64     public static final NameScope FILE_SYSTEM = new NameScope("filesystem");
65
66     private final String JavaDoc name;
67
68     private NameScope(final String JavaDoc name)
69     {
70         this.name = name;
71     }
72
73     /**
74      * Returns the name of the scope.
75      */

76     public String JavaDoc toString()
77     {
78         return name;
79     }
80
81     /**
82      * Returns the name of the scope.
83      */

84     public String JavaDoc getName()
85     {
86         return name;
87     }
88 }
89
Popular Tags