1 11 package org.eclipse.jdt.internal.core.search.matching; 12 13 import org.eclipse.jdt.core.compiler.CharOperation; 14 import org.eclipse.jdt.core.search.SearchPattern; 15 16 public class PackageReferencePattern extends AndPattern { 17 18 protected char[] pkgName; 19 20 protected char[][] segments; 21 protected int currentSegment; 22 23 protected static char[][] CATEGORIES = { REF }; 24 25 public PackageReferencePattern(char[] pkgName, int matchRule) { 26 this(matchRule); 27 28 if (pkgName == null || pkgName.length == 0) { 29 this.pkgName = null; 30 this.segments = new char[][] {CharOperation.NO_CHAR}; 31 ((InternalSearchPattern)this).mustResolve = false; 32 } else { 33 this.pkgName = (isCaseSensitive() || isCamelCase()) ? pkgName : CharOperation.toLowerCase(pkgName); 34 this.segments = CharOperation.splitOn('.', this.pkgName); 35 ((InternalSearchPattern)this).mustResolve = true; 36 } 37 } 38 PackageReferencePattern(int matchRule) { 39 super(PKG_REF_PATTERN, matchRule); 40 } 41 public void decodeIndexKey(char[] key) { 42 this.pkgName = key; 44 } 45 public SearchPattern getBlankPattern() { 46 return new PackageReferencePattern(R_EXACT_MATCH | R_CASE_SENSITIVE); 47 } 48 public char[] getIndexKey() { 49 if (this.currentSegment >= 0) 51 return this.segments[this.currentSegment]; 52 return null; 53 } 54 public char[][] getIndexCategories() { 55 return CATEGORIES; 56 } 57 protected boolean hasNextQuery() { 58 return --this.currentSegment >= (this.segments.length >= 4 ? 2 : 0); 61 } 62 public boolean matchesDecodedKey(SearchPattern decodedPattern) { 63 return true; } 65 protected void resetQuery() { 66 67 this.currentSegment = this.segments.length - 1; 68 } 69 protected StringBuffer print(StringBuffer output) { 70 output.append("PackageReferencePattern: <"); if (this.pkgName != null) 72 output.append(this.pkgName); 73 else 74 output.append("*"); output.append(">"); return super.print(output); 77 } 78 } 79 | Popular Tags |