1 11 package org.eclipse.jdt.internal.core; 12 13 import org.eclipse.core.runtime.Assert; 14 import org.eclipse.jdt.core.*; 15 16 20 21 public class ImportDeclaration extends SourceRefElement implements IImportDeclaration { 22 23 protected String name; 24 protected boolean isOnDemand; 25 26 30 protected ImportDeclaration(ImportContainer parent, String name, boolean isOnDemand) { 31 super(parent); 32 this.name = name; 33 this.isOnDemand = isOnDemand; 34 } 35 public boolean equals(Object o) { 36 if (!(o instanceof ImportDeclaration)) return false; 37 return super.equals(o); 38 } 39 public String getElementName() { 40 if (this.isOnDemand) 41 return this.name + ".*"; return this.name; 43 } 44 public String getNameWithoutStar() { 45 return this.name; 46 } 47 50 public int getElementType() { 51 return IMPORT_DECLARATION; 52 } 53 56 public int getFlags() throws JavaModelException { 57 ImportDeclarationElementInfo info = (ImportDeclarationElementInfo)getElementInfo(); 58 return info.getModifiers(); 59 } 60 64 protected void getHandleMemento(StringBuffer buff) { 65 ((JavaElement)getParent()).getHandleMemento(buff); 66 escapeMementoName(buff, getElementName()); 67 if (this.occurrenceCount > 1) { 68 buff.append(JEM_COUNT); 69 buff.append(this.occurrenceCount); 70 } 71 } 72 75 protected char getHandleMementoDelimiter() { 76 Assert.isTrue(false, "Should not be called"); return 0; 79 } 80 83 public IJavaElement getPrimaryElement(boolean checkOwner) { 84 CompilationUnit cu = (CompilationUnit)this.parent.getParent(); 85 if (checkOwner && cu.isPrimary()) return this; 86 return cu.getImport(getElementName()); 87 } 88 91 public boolean isOnDemand() { 92 return this.isOnDemand; 93 } 94 96 public String readableName() { 97 98 return null; 99 } 100 103 protected void toStringInfo(int tab, StringBuffer buffer, Object info, boolean showResolvedInfo) { 104 buffer.append(this.tabString(tab)); 105 buffer.append("import "); toStringName(buffer); 107 if (info == null) { 108 buffer.append(" (not open)"); } 110 } 111 } 112 | Popular Tags |