1 | /** |
---|
2 | * @copyright |
---|
3 | * ==================================================================== |
---|
4 | * Copyright (c) 2007 CollabNet. All rights reserved. |
---|
5 | * |
---|
6 | * This software is licensed as described in the file COPYING, which |
---|
7 | * you should have received as part of this distribution. The terms |
---|
8 | * are also available at http://subversion.tigris.org/license-1.html. |
---|
9 | * If newer versions of this license are posted there, you may use a |
---|
10 | * newer version instead, at your option. |
---|
11 | * |
---|
12 | * This software consists of voluntary contributions made by many |
---|
13 | * individuals. For exact contribution history, see the revision |
---|
14 | * history and logs, available at http://subversion.tigris.org/. |
---|
15 | * ==================================================================== |
---|
16 | * @endcopyright |
---|
17 | */ |
---|
18 | |
---|
19 | package org.tigris.subversion.javahl; |
---|
20 | |
---|
21 | /** |
---|
22 | * The concept of depth for directories. |
---|
23 | * |
---|
24 | * Note: |
---|
25 | * This is similar to, but not exactly the same as, the WebDAV and LDAP |
---|
26 | * concepts of depth. |
---|
27 | * |
---|
28 | */ |
---|
29 | public final class Depth |
---|
30 | { |
---|
31 | /* The order of these depths is important: the higher the number, |
---|
32 | the deeper it descends. This allows us to compare two depths |
---|
33 | numerically to decide which should govern. */ |
---|
34 | |
---|
35 | /** Depth undetermined or ignored. */ |
---|
36 | public static final int unknown = -2; |
---|
37 | |
---|
38 | /** Exclude (i.e, don't descend into) directory D. */ |
---|
39 | public static final int exclude = -1; |
---|
40 | |
---|
41 | /** Just the named directory D, no entries. Updates will not pull in |
---|
42 | any files or subdirectories not already present. */ |
---|
43 | public static final int empty = 0; |
---|
44 | |
---|
45 | /** D + its file children, but not subdirs. Updates will pull in any |
---|
46 | files not already present, but not subdirectories. */ |
---|
47 | public static final int files = 1; |
---|
48 | |
---|
49 | /** D + immediate children (D and its entries). Updates will pull in |
---|
50 | any files or subdirectories not already present; those |
---|
51 | subdirectories' this_dir entries will have depth-empty. */ |
---|
52 | public static final int immediates = 2; |
---|
53 | |
---|
54 | /** D + all descendants (full recursion from D). Updates will pull |
---|
55 | in any files or subdirectories not already present; those |
---|
56 | subdirectories' this_dir entries will have depth-infinity. |
---|
57 | Equivalent to the pre-1.5 default update behavior. */ |
---|
58 | public static final int infinity = 3; |
---|
59 | |
---|
60 | /** |
---|
61 | * @return A depth value of {@link #infinity} when |
---|
62 | * <code>recurse</code> is <code>true</code>, or {@link #empty} |
---|
63 | * otherwise. |
---|
64 | */ |
---|
65 | public static final int infinityOrEmpty(boolean recurse) |
---|
66 | { |
---|
67 | return (recurse ? infinity : empty); |
---|
68 | } |
---|
69 | |
---|
70 | /** |
---|
71 | * @return A depth value of {@link #infinity} when |
---|
72 | * <code>recurse</code> is <code>true</code>, or {@link #files} |
---|
73 | * otherwise. |
---|
74 | */ |
---|
75 | public static final int infinityOrFiles(boolean recurse) |
---|
76 | { |
---|
77 | return (recurse ? infinity : files); |
---|
78 | } |
---|
79 | |
---|
80 | /** |
---|
81 | * @return A depth value of {@link #infinity} when |
---|
82 | * <code>recurse</code> is <code>true</code>, or {@link |
---|
83 | * #immediates} otherwise. |
---|
84 | */ |
---|
85 | public static final int infinityOrImmediates(boolean recurse) |
---|
86 | { |
---|
87 | return (recurse ? infinity : immediates); |
---|
88 | } |
---|
89 | |
---|
90 | /** |
---|
91 | * @return A depth value of {@link #unknown} when |
---|
92 | * <code>recurse</code> is <code>true</code>, or {@link #empty} |
---|
93 | * otherwise. |
---|
94 | */ |
---|
95 | public static final int unknownOrEmpty(boolean recurse) |
---|
96 | { |
---|
97 | return (recurse ? unknown : empty); |
---|
98 | } |
---|
99 | |
---|
100 | /** |
---|
101 | * @return A depth value of {@link #unknown} when |
---|
102 | * <code>recurse</code> is <code>true</code>, or {@link #files} |
---|
103 | * otherwise. |
---|
104 | */ |
---|
105 | public static final int unknownOrFiles(boolean recurse) |
---|
106 | { |
---|
107 | return (recurse ? unknown : files); |
---|
108 | } |
---|
109 | |
---|
110 | /** |
---|
111 | * @return A depth value of {@link #unknown} when |
---|
112 | * <code>recurse</code> is <code>true</code>, or {@link |
---|
113 | * #immediates} otherwise. |
---|
114 | */ |
---|
115 | public static final int unknownOrImmediates(boolean recurse) |
---|
116 | { |
---|
117 | return (recurse ? unknown : immediates); |
---|
118 | } |
---|
119 | } |
---|