1 11 package org.eclipse.jdt.internal.core; 12 13 import java.util.HashMap ; 14 15 import org.eclipse.core.runtime.IProgressMonitor; 16 import org.eclipse.jdt.core.IJavaElement; 17 import org.eclipse.jdt.core.IJavaModelStatusConstants; 18 import org.eclipse.jdt.core.ISourceRange; 19 import org.eclipse.jdt.core.JavaModelException; 20 import org.eclipse.jdt.core.compiler.CharOperation; 21 22 25 public abstract class BinaryMember extends NamedMember { 26 29 protected BinaryMember(JavaElement parent, String name) { 30 super(parent, name); 31 } 32 35 public void copy(IJavaElement container, IJavaElement sibling, String rename, boolean force, IProgressMonitor monitor) throws JavaModelException { 36 throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.READ_ONLY, this)); 37 } 38 41 protected void generateInfos(Object info, HashMap newElements, IProgressMonitor pm) throws JavaModelException { 42 Openable openableParent = (Openable) getOpenableParent(); 43 if (JavaModelManager.getJavaModelManager().getInfo(openableParent) == null) { 44 openableParent.generateInfos(openableParent.createElementInfo(), newElements, pm); 45 } 46 } 47 public String [] getCategories() throws JavaModelException { 48 SourceMapper mapper= getSourceMapper(); 49 if (mapper != null) { 50 ((ClassFile)getClassFile()).getBuffer(); 52 53 if (mapper.categories != null) { 54 String [] categories = (String []) mapper.categories.get(this); 55 if (categories != null) 56 return categories; 57 } 58 } 59 return CharOperation.NO_STRINGS; 60 } 61 public String getKey() { 62 try { 63 return getKey(false); 64 } catch (JavaModelException e) { 65 return null; 67 } 68 } 69 72 public abstract String getKey(boolean forceOpen) throws JavaModelException; 73 76 public ISourceRange getNameRange() throws JavaModelException { 77 SourceMapper mapper= getSourceMapper(); 78 if (mapper != null) { 79 ((ClassFile)getClassFile()).getBuffer(); 81 82 return mapper.getNameRange(this); 83 } else { 84 return SourceMapper.UNKNOWN_RANGE; 85 } 86 } 87 90 public ISourceRange getSourceRange() throws JavaModelException { 91 SourceMapper mapper= getSourceMapper(); 92 if (mapper != null) { 93 ((ClassFile)getClassFile()).getBuffer(); 95 96 return mapper.getSourceRange(this); 97 } else { 98 return SourceMapper.UNKNOWN_RANGE; 99 } 100 } 101 104 public boolean isBinary() { 105 return true; 106 } 107 110 public boolean isStructureKnown() throws JavaModelException { 111 return ((IJavaElement)getOpenableParent()).isStructureKnown(); 112 } 113 116 public void move(IJavaElement container, IJavaElement sibling, String rename, boolean force, IProgressMonitor monitor) throws JavaModelException { 117 throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.READ_ONLY, this)); 118 } 119 122 public void rename(String newName, boolean force, IProgressMonitor monitor) throws JavaModelException { 123 throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.READ_ONLY, this)); 124 } 125 129 public void setContents(String contents, IProgressMonitor monitor) throws JavaModelException { 130 throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.READ_ONLY, this)); 131 } 132 } 133 | Popular Tags |