1 22 package org.jboss.virtual; 23 24 31 public class VisitorAttributes 32 { 33 34 public static final AcceptAnyFilter RECURSE_ALL = new AcceptAnyFilter(); 35 36 37 public static final VisitorAttributes DEFAULT = new ImmutableVisitorAttributes(); 38 39 40 public static final VisitorAttributes LEAVES_ONLY = new ImmutableVisitorAttributes(true, null); 41 42 43 public static final VisitorAttributes RECURSE = new ImmutableVisitorAttributes(false, RECURSE_ALL); 44 45 46 public static final VisitorAttributes RECURSE_LEAVES_ONLY = new ImmutableVisitorAttributes(true, RECURSE_ALL); 47 48 49 private boolean includeRoot; 50 51 52 private boolean leavesOnly; 53 54 55 private boolean ignoreErrors; 56 57 58 private boolean includeHidden; 59 60 61 private VirtualFileFilter recurseFilter; 62 63 70 public boolean isLeavesOnly() 71 { 72 return leavesOnly; 73 } 74 75 81 public void setLeavesOnly(boolean leavesOnly) 82 { 83 this.leavesOnly = leavesOnly; 84 } 85 86 94 public boolean isRecurse(VirtualFile file) 95 { 96 boolean recurse = false; 97 if( recurseFilter != null ) 98 recurse = recurseFilter.accepts(file); 99 return recurse; 100 } 101 102 106 public VirtualFileFilter getRecurseFilter() 107 { 108 return recurseFilter; 109 } 110 111 117 public void setRecurseFilter(VirtualFileFilter filter) 118 { 119 this.recurseFilter = filter; 120 } 121 122 129 public boolean isIncludeRoot() 130 { 131 return includeRoot; 132 } 133 134 140 public void setIncludeRoot(boolean includeRoot) 141 { 142 this.includeRoot = includeRoot; 143 } 144 145 152 public boolean isIgnoreErrors() 153 { 154 return ignoreErrors; 155 } 156 157 163 public void setIgnoreErrors(boolean ignoreErrors) 164 { 165 this.ignoreErrors = ignoreErrors; 166 } 167 168 175 public boolean isIncludeHidden() 176 { 177 return includeHidden; 178 } 179 180 186 public void setIncludeHidden(boolean includeHidden) 187 { 188 this.includeHidden = includeHidden; 189 } 190 191 private static class AcceptAnyFilter implements VirtualFileFilter 192 { 193 public boolean accepts(VirtualFile file) 194 { 195 return true; 196 } 197 } 198 201 private static class ImmutableVisitorAttributes extends VisitorAttributes 202 { 203 206 public ImmutableVisitorAttributes() 207 { 208 } 209 210 216 public ImmutableVisitorAttributes(boolean leavesOnly, VirtualFileFilter recurseFilter) 217 { 218 super.setLeavesOnly(leavesOnly); 219 super.setRecurseFilter(recurseFilter); 220 } 221 222 @Override 223 public void setLeavesOnly(boolean leavesOnly) 224 { 225 throw new IllegalStateException ("The preconfigured attributes are immutable"); 226 } 227 228 @Override 229 public void setIncludeRoot(boolean includeRoot) 230 { 231 throw new IllegalStateException ("The preconfigured attributes are immutable"); 232 } 233 234 @Override 235 public void setRecurseFilter(VirtualFileFilter filter) 236 { 237 throw new IllegalStateException ("The preconfigured attributes are immutable"); 238 } 239 240 @Override 241 public void setIgnoreErrors(boolean ignoreErrors) 242 { 243 throw new IllegalStateException ("The preconfigured attributes are immutable"); 244 } 245 246 @Override 247 public void setIncludeHidden(boolean includeHidden) 248 { 249 throw new IllegalStateException ("The preconfigured attributes are immutable"); 250 } 251 } 252 } 253 | Popular Tags |