|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.ObjectPlatformObject
org.aspectj.org.eclipse.jdt.internal.core.JavaElement
org.aspectj.org.eclipse.jdt.internal.core.Openable
org.aspectj.org.eclipse.jdt.internal.core.JavaModel
public class JavaModel
Implementation of IJavaModel. The Java Model maintains a cache of active
IJavaProjects in a workspace. A Java Model is specific to a workspace.
To retrieve a workspace's model, use the
#getJavaModel() method.
IJavaModel| Field Summary | |
|---|---|
static java.util.HashSet |
existingExternalConfirmedFiles
A set of external files ( existingExternalFiles) which have
been confirmed as file (i.e. |
static java.util.HashSet |
existingExternalFiles
A set of java.io.Files used as a cache of external jars that are known to be existing. |
| Fields inherited from class org.aspectj.org.eclipse.jdt.internal.core.JavaElement |
|---|
JEM_ANNOTATION, JEM_CLASSFILE, JEM_COMPILATIONUNIT, JEM_COUNT, JEM_ESCAPE, JEM_FIELD, JEM_IMPORTDECLARATION, JEM_INITIALIZER, JEM_JAVAPROJECT, JEM_LOCALVARIABLE, JEM_METHOD, JEM_PACKAGEDECLARATION, JEM_PACKAGEFRAGMENT, JEM_PACKAGEFRAGMENTROOT, JEM_TYPE, JEM_TYPE_PARAMETER, NO_ELEMENTS, NO_INFO, parent |
| Fields inherited from interface org.aspectj.org.eclipse.jdt.core.IJavaElement |
|---|
ANNOTATION, CLASS_FILE, COMPILATION_UNIT, FIELD, IMPORT_CONTAINER, IMPORT_DECLARATION, INITIALIZER, JAVA_MODEL, JAVA_PROJECT, LOCAL_VARIABLE, METHOD, PACKAGE_DECLARATION, PACKAGE_FRAGMENT, PACKAGE_FRAGMENT_ROOT, TYPE, TYPE_PARAMETER |
| Constructor Summary | |
|---|---|
protected |
JavaModel()
Constructs a new Java Model on the given workspace. |
| Method Summary | |
|---|---|
protected boolean |
buildStructure(OpenableElementInfo info,
IProgressMonitor pm,
java.util.Map newElements,
IResource underlyingResource)
Builds this element's structure and properties in the given info object, based on this element's current contents (reuse buffer contents if this element has an open buffer, or resource contents if this element does not have an open buffer). |
boolean |
contains(IResource resource)
Returns whether this Java model contains an IJavaElement whose
resource is the given resource or a non-Java resource which is the given resource. |
void |
copy(IJavaElement[] elements,
IJavaElement[] containers,
IJavaElement[] siblings,
java.lang.String[] renamings,
boolean force,
IProgressMonitor monitor)
Copies the given elements to the specified container(s). |
protected java.lang.Object |
createElementInfo()
Returns a new element info for this element. |
void |
delete(IJavaElement[] elements,
boolean force,
IProgressMonitor monitor)
Deletes the given elements, forcing the operation if necessary and specified. |
boolean |
equals(java.lang.Object o)
Returns true if this handle represents the same Java element as the given handle. |
static void |
flushExternalFileCache()
Flushes the cache of external files known to be existing. |
int |
getElementType()
Returns this element's kind encoded as an integer. |
static java.lang.Object |
getExternalTarget(IPath path,
boolean checkResourceExistence)
|
static java.io.File |
getFile(java.lang.Object target)
Helper method - returns the file item (i.e. |
IJavaElement |
getHandleFromMemento(java.lang.String token,
MementoTokenizer memento,
WorkingCopyOwner owner)
|
protected void |
getHandleMemento(java.lang.StringBuffer buff)
|
protected char |
getHandleMementoDelimiter()
Returns the char that marks the start of this handles
contribution to a memento. |
IJavaProject |
getJavaProject(IResource resource)
Returns the active Java project associated with the specified resource, or null if no Java project yet exists
for the resource. |
IJavaProject |
getJavaProject(java.lang.String projectName)
Returns the Java project with the given name. |
IJavaProject[] |
getJavaProjects()
Returns the Java projects in this Java model, or an empty array if there are none. |
java.lang.Object[] |
getNonJavaResources()
Returns an array of non-Java resources (that is, non-Java projects) in the workspace. |
IPath |
getPath()
Returns the path to the innermost resource enclosing this element. |
static java.lang.Object |
getTarget(IPath path,
boolean checkResourceExistence)
Helper method - returns the targeted item (IResource if internal or java.io.File if external), or null if unbound Internal items must be referred to using container relative paths. |
IResource |
getUnderlyingResource()
Returns the smallest underlying resource that contains this element, or null if this element is not contained
in a resource. |
IWorkspace |
getWorkspace()
Returns the workbench associated with this object. |
static IResource |
getWorkspaceTarget(IPath path)
|
static boolean |
isFile(java.lang.Object target)
Helper method - returns whether an object is afile (i.e. |
void |
move(IJavaElement[] elements,
IJavaElement[] containers,
IJavaElement[] siblings,
java.lang.String[] renamings,
boolean force,
IProgressMonitor monitor)
Moves the given elements to the specified container(s). |
void |
refreshExternalArchives(IJavaElement[] elementsScope,
IProgressMonitor monitor)
Triggers an update of the JavaModel with respect to the referenced external archives. |
void |
rename(IJavaElement[] elements,
IJavaElement[] destinations,
java.lang.String[] renamings,
boolean force,
IProgressMonitor monitor)
Renames the given elements as specified. |
IResource |
resource(PackageFragmentRoot root)
|
protected void |
runOperation(MultiOperation op,
IJavaElement[] elements,
IJavaElement[] siblings,
java.lang.String[] renamings,
IProgressMonitor monitor)
Configures and runs the MultiOperation. |
protected void |
toStringInfo(int tab,
java.lang.StringBuffer buffer,
java.lang.Object info,
boolean showResolvedInfo)
Debugging purposes |
protected IStatus |
validateExistence(IResource underlyingResource)
|
| Methods inherited from class org.aspectj.org.eclipse.jdt.internal.core.Openable |
|---|
bufferChanged, canBeRemovedFromCache, canBufferBeRemovedFromCache, closeBuffer, closing, codeComplete, codeSelect, exists, findRecommendedLineSeparator, generateInfos, getBuffer, getBufferFactory, getBufferManager, getCorrespondingResource, getOpenable, getPackageFragmentRoot, getResource, hasBuffer, hasUnsavedChanges, isConsistent, isOpen, isSourceElement, isStructureKnown, makeConsistent, open, openAncestors, openBuffer, resource, resourceExists, save |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.aspectj.org.eclipse.jdt.core.IJavaElement |
|---|
exists, getAncestor, getAttachedJavadoc, getCorrespondingResource, getElementName, getHandleIdentifier, getJavaModel, getJavaProject, getOpenable, getParent, getPrimaryElement, getResource, getSchedulingRule, isReadOnly, isStructureKnown |
| Methods inherited from interface org.aspectj.org.eclipse.jdt.core.IOpenable |
|---|
close, findRecommendedLineSeparator, getBuffer, hasUnsavedChanges, isConsistent, isOpen, makeConsistent, open, save |
| Methods inherited from interface org.aspectj.org.eclipse.jdt.core.IParent |
|---|
getChildren, hasChildren |
| Field Detail |
|---|
public static java.util.HashSet existingExternalFiles
public static java.util.HashSet existingExternalConfirmedFiles
existingExternalFiles) which have
been confirmed as file (i.e. which returns true to File.isFile().
Note this cache is kept for the whole session.
| Constructor Detail |
|---|
protected JavaModel()
throws java.lang.Error
java.lang.Error - if called more than once| Method Detail |
|---|
protected boolean buildStructure(OpenableElementInfo info,
IProgressMonitor pm,
java.util.Map newElements,
IResource underlyingResource)
Openable
buildStructure in class Openablepublic boolean contains(IResource resource)
IJavaModelIJavaElement whose
resource is the given resource or a non-Java resource which is the given resource.
Note: no existency check is performed on the argument resource. If it is not accessible
(see IResource.isAccessible()) yet but would be located in Java model
range, then it will return true.
If the resource is accessible, it can be reached by navigating the Java model down using the
getChildren() and/or getNonJavaResources() methods.
contains in interface IJavaModelresource - the resource to check
public void copy(IJavaElement[] elements,
IJavaElement[] containers,
IJavaElement[] siblings,
java.lang.String[] renamings,
boolean force,
IProgressMonitor monitor)
throws JavaModelException
IJavaModel
Optionally, each copy can positioned before a sibling
element. If null is specified for a given sibling, the copy
is inserted as the last child of its associated container.
Optionally, each copy can be renamed. If
null is specified for the new name, the copy
is not renamed.
Optionally, any existing child in the destination container with
the same name can be replaced by specifying true for
force. Otherwise an exception is thrown in the event that a name
collision occurs.
copy in interface IJavaModelelements - the elements to copycontainers - the container, or list of containerssiblings - the list of siblings element any of which may be
null; or nullrenamings - the list of new names any of which may be
null; or nullforce - true if any existing child in a target container
with the target name should be replaced, and false to throw an
exception in the event of a name collisionmonitor - a progress monitor
JavaModelException - if an element could not be copied. Reasons include:
CoreException occurred while updating an underlying resourceINVALID_DESTINATION)INVALID_SIBLING)INVALID_NAME)replace has been specified as false (NAME_COLLISION)READ_ONLY) IJavaModelprotected java.lang.Object createElementInfo()
createElementInfo in class Openable
public void delete(IJavaElement[] elements,
boolean force,
IProgressMonitor monitor)
throws JavaModelException
IJavaModel
delete in interface IJavaModelelements - the elements to deleteforce - a flag controlling whether underlying resources that are not
in sync with the local file system will be toleratedmonitor - a progress monitor
JavaModelException - if an element could not be deleted. Reasons include:
CoreException occurred while updating an underlying resourceREAD_ONLY) IJavaModelpublic boolean equals(java.lang.Object o)
JavaElementIf a subclass has other requirements for equality, this method must be overridden.
equals in class JavaElementObject.equals(java.lang.Object)public int getElementType()
IJavaElement
getElementType in interface IJavaElementIJavaElementIJavaElementpublic static void flushExternalFileCache()
public IJavaElement getHandleFromMemento(java.lang.String token,
MementoTokenizer memento,
WorkingCopyOwner owner)
getHandleFromMemento in class JavaElementprotected void getHandleMemento(java.lang.StringBuffer buff)
getHandleMemento in class JavaElementJavaElement.getHandleMemento(StringBuffer)protected char getHandleMementoDelimiter()
char that marks the start of this handles
contribution to a memento.
getHandleMementoDelimiter in class JavaElementpublic IJavaProject getJavaProject(java.lang.String projectName)
IJavaModelIPath#isValidSegment(String).
This is a handle-only method.
The project may or may not exist.
getJavaProject in interface IJavaModelprojectName - the name of the Java project
IJavaModelpublic IJavaProject getJavaProject(IResource resource)
null if no Java project yet exists
for the resource.
getJavaProject in interface IJavaModelresource - the name of the Java project
java.lang.IllegalArgumentException - if the given resource
is not one of an IProject, IFolder, or IFile.
public IJavaProject[] getJavaProjects()
throws JavaModelException
IJavaModel
getJavaProjects in interface IJavaModelJavaModelException - if this request fails.IJavaModel
public java.lang.Object[] getNonJavaResources()
throws JavaModelException
IJavaModelNon-Java projects include all projects that are closed (even if they have the Java nature).
getNonJavaResources in interface IJavaModelIProjects) contained
in the workspace.
JavaModelException - if this element does not exist or if an
exception occurs while accessing its corresponding resourceIJavaModelpublic IPath getPath()
IJavaElement
getPath in interface IJavaElementpublic IResource resource(PackageFragmentRoot root)
resource in class Openablepublic IResource getUnderlyingResource()
IJavaElementnull if this element is not contained
in a resource.
getUnderlyingResource in interface IJavaElementgetUnderlyingResource in class Openablenull if noneIOpenablepublic IWorkspace getWorkspace()
getWorkspace in interface IJavaModel
public void move(IJavaElement[] elements,
IJavaElement[] containers,
IJavaElement[] siblings,
java.lang.String[] renamings,
boolean force,
IProgressMonitor monitor)
throws JavaModelException
IJavaModel
Optionally, each element can positioned before a sibling
element. If null is specified for sibling, the element
is inserted as the last child of its associated container.
Optionally, each element can be renamed. If
null is specified for the new name, the element
is not renamed.
Optionally, any existing child in the destination container with
the same name can be replaced by specifying true for
force. Otherwise an exception is thrown in the event that a name
collision occurs.
move in interface IJavaModelelements - the elements to movecontainers - the container, or list of containerssiblings - the list of siblings element any of which may be
null; or nullrenamings - the list of new names any of which may be
null; or nullforce - true if any existing child in a target container
with the target name should be replaced, and false to throw an
exception in the event of a name collisionmonitor - a progress monitor
JavaModelException - if an element could not be moved. Reasons include:
CoreException occurred while updating an underlying resourceINVALID_DESTINATION)INVALID_SIBLING)INVALID_NAME)replace has been specified as false (NAME_COLLISION)READ_ONLY) IJavaModel
public void refreshExternalArchives(IJavaElement[] elementsScope,
IProgressMonitor monitor)
throws JavaModelException
IJavaModelnull along is equivalent to refreshing the entire mode).
The elements can be:
In case an archive is used by multiple projects, the delta issued will account for all of them. This means that even if a project was not part of the elements scope, it may still be notified of changes if it is referencing a library comprised in the scope.
Since 3.7, a project refresh automatically triggers a refresh of external archives. Hence, this method doesn't need to be explicitly called after a project refresh.
refreshExternalArchives in interface IJavaModelelementsScope - - a collection of elements defining the scope of the refreshmonitor - - a progress monitor used to report progress
JavaModelException - in one of the corresponding situation:
IJavaModel.refreshExternalArchives(IJavaElement[], IProgressMonitor)
public void rename(IJavaElement[] elements,
IJavaElement[] destinations,
java.lang.String[] renamings,
boolean force,
IProgressMonitor monitor)
throws JavaModelException
IJavaModel
rename in interface IJavaModelelements - the elements to renamedestinations - the container, or list of containersrenamings - the list of new namesforce - true if an existing child in a target container
with the target name should be replaced, and false to throw an
exception in the event of a name collisionmonitor - a progress monitor
JavaModelException - if an element could not be renamed. Reasons include:
CoreException occurred while updating an underlying resource
INVALID_NAME)
replace has been specified as false (NAME_COLLISION)
READ_ONLY)
IJavaModel
protected void runOperation(MultiOperation op,
IJavaElement[] elements,
IJavaElement[] siblings,
java.lang.String[] renamings,
IProgressMonitor monitor)
throws JavaModelException
MultiOperation.
JavaModelException
protected void toStringInfo(int tab,
java.lang.StringBuffer buffer,
java.lang.Object info,
boolean showResolvedInfo)
JavaElement
toStringInfo in class JavaElementshowResolvedInfo - TODO
public static java.lang.Object getTarget(IPath path,
boolean checkResourceExistence)
public static IResource getWorkspaceTarget(IPath path)
public static java.lang.Object getExternalTarget(IPath path,
boolean checkResourceExistence)
public static boolean isFile(java.lang.Object target)
File.isFile().
public static java.io.File getFile(java.lang.Object target)
File.isFile(),
or null if unbound
protected IStatus validateExistence(IResource underlyingResource)
validateExistence in class Openable
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||