1 19 20 package org.netbeans.api.editor.fold; 21 22 import java.util.ArrayList ; 23 import java.util.Collection ; 24 import java.util.Collections ; 25 import java.util.Iterator ; 26 import java.util.List ; 27 import org.netbeans.modules.editor.fold.FoldUtilitiesImpl; 28 29 40 41 public final class FoldUtilities { 42 43 private FoldUtilities() { 44 } 46 47 53 public static boolean isRootFold(Fold fold) { 54 return fold.isRootFold(); 55 } 56 57 81 public static int findFoldStartIndex(Fold fold, int offset) { 82 return FoldUtilitiesImpl.findFoldStartIndex(fold, offset, true); 85 } 86 87 108 public static int findFoldEndIndex(Fold fold, int offset) { 109 return FoldUtilitiesImpl.findFoldEndIndex(fold, offset); 110 } 111 112 119 public static boolean isEmpty(Fold fold) { 120 return (fold.getStartOffset() == fold.getEndOffset()); 121 } 122 123 130 public static void collapseAll(FoldHierarchy hierarchy) { 131 collapse(hierarchy, (Collection )null); 132 } 133 134 142 public static void collapse(FoldHierarchy hierarchy, FoldType type) { 143 collapse(hierarchy, Collections.singleton(type)); 144 } 145 146 155 public static void collapse(FoldHierarchy hierarchy, Collection foldTypes) { 156 FoldUtilitiesImpl.collapseOrExpand(hierarchy, foldTypes, true); 157 } 158 159 166 public static void expandAll(FoldHierarchy hierarchy) { 167 expand(hierarchy, (Collection )null); 168 } 169 170 178 public static void expand(FoldHierarchy hierarchy, FoldType type) { 179 expand(hierarchy, Collections.singleton(type)); 180 } 181 182 191 public static void expand(FoldHierarchy hierarchy, Collection foldTypes) { 192 FoldUtilitiesImpl.collapseOrExpand(hierarchy, foldTypes, false); 193 } 194 195 203 public static boolean containsOffset(Fold fold, int offset) { 204 return (offset < fold.getEndOffset() && offset >= fold.getStartOffset()); 205 } 206 207 213 public static Fold[] childrenToArray(Fold fold) { 214 return childrenToArray(fold, 0, fold.getFoldCount()); 215 } 216 217 226 public static Fold[] childrenToArray(Fold fold, int index, int count) { 227 return fold.foldsToArray(index, count); 228 } 229 230 239 public static List childrenAsList(Fold fold) { 240 return childrenAsList(fold, 0, fold.getFoldCount()); 241 } 242 243 255 public static List childrenAsList(Fold fold, int index, int count) { 256 return FoldUtilitiesImpl.childrenAsList(fold, index, count); 257 } 258 259 272 public static List find(Fold fold, FoldType foldType) { 273 return find(fold, Collections.singletonList(foldType)); 274 } 275 276 290 public static List find(Fold fold, Collection foldTypes) { 291 return FoldUtilitiesImpl.find(fold, foldTypes); 292 } 293 294 306 public static List findRecursive(Fold fold) { 307 return findRecursive(fold, (Collection )null); 308 } 309 310 324 public static List findRecursive(Fold fold, FoldType foldType) { 325 return findRecursive(fold, Collections.singletonList(foldType)); 326 } 327 328 343 public static List findRecursive(Fold fold, Collection foldTypes) { 344 return FoldUtilitiesImpl.findRecursive(null, fold, foldTypes); 345 } 346 347 360 public static Fold findNearestFold(FoldHierarchy hierarchy, int offset) { 361 return FoldUtilitiesImpl.findNearestFold(hierarchy, offset, Integer.MAX_VALUE); 362 } 363 364 378 public static Fold findOffsetFold(FoldHierarchy hierarchy, int offset) { 379 return FoldUtilitiesImpl.findOffsetFold(hierarchy, offset); 380 } 381 382 393 public static Fold findCollapsedFold(FoldHierarchy hierarchy, 394 int startOffset, int endOffset) { 395 396 return FoldUtilitiesImpl.findFirstCollapsedFold(hierarchy, startOffset, endOffset); 397 } 398 399 412 public static Iterator collapsedFoldIterator(FoldHierarchy hierarchy, 413 int startOffset, int endOffset) { 414 415 return FoldUtilitiesImpl.collapsedFoldIterator(hierarchy, startOffset, endOffset); 416 } 417 418 } 419 | Popular Tags |