|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface IJavaModel
Represent the root Java element corresponding to the workspace.
Since there is only one such root element, it is commonly referred to as
the Java model element.
The Java model element needs to be opened before it can be navigated or manipulated.
The Java model element has no parent (it is the root of the Java element
hierarchy). Its children are IJavaProject
s.
This interface provides methods for performing copy, move, rename, and delete operations on multiple Java elements.
An instance of one of these handles can be created via
JavaCore.create(workspace.getRoot())
.
JavaCore.create(org.eclipse.core.resources.IWorkspaceRoot)
Field Summary |
---|
Fields inherited from interface 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 |
Method Summary | |
---|---|
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 replace,
org.eclipse.core.runtime.IProgressMonitor monitor)
Copies the given elements to the specified container(s). |
void |
delete(IJavaElement[] elements,
boolean force,
org.eclipse.core.runtime.IProgressMonitor monitor)
Deletes the given elements, forcing the operation if necessary and specified. |
IJavaProject |
getJavaProject(java.lang.String name)
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. |
IWorkspace |
getWorkspace()
Returns the workspace associated with this Java model. |
void |
move(IJavaElement[] elements,
IJavaElement[] containers,
IJavaElement[] siblings,
java.lang.String[] renamings,
boolean replace,
org.eclipse.core.runtime.IProgressMonitor monitor)
Moves the given elements to the specified container(s). |
void |
refreshExternalArchives(IJavaElement[] elementsScope,
org.eclipse.core.runtime.IProgressMonitor monitor)
Triggers an update of the JavaModel with respect to the referenced external archives. |
void |
rename(IJavaElement[] elements,
IJavaElement[] destinations,
java.lang.String[] names,
boolean replace,
org.eclipse.core.runtime.IProgressMonitor monitor)
Renames the given elements as specified. |
Methods inherited from interface org.eclipse.jdt.core.IJavaElement |
---|
exists, getAncestor, getAttachedJavadoc, getCorrespondingResource, getElementName, getElementType, getHandleIdentifier, getJavaModel, getJavaProject, getOpenable, getParent, getPath, getPrimaryElement, getResource, getSchedulingRule, getUnderlyingResource, isReadOnly, isStructureKnown |
Methods inherited from interface org.eclipse.core.runtime.IAdaptable |
---|
getAdapter |
Methods inherited from interface org.eclipse.jdt.core.IOpenable |
---|
close, findRecommendedLineSeparator, getBuffer, hasUnsavedChanges, isConsistent, isOpen, makeConsistent, open, save |
Methods inherited from interface org.eclipse.jdt.core.IParent |
---|
getChildren, hasChildren |
Method Detail |
---|
boolean contains(IResource resource)
IJavaElement
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.
resource
- the resource to check
void copy(IJavaElement[] elements, IJavaElement[] containers, IJavaElement[] siblings, java.lang.String[] renamings, boolean replace, org.eclipse.core.runtime.IProgressMonitor monitor) throws JavaModelException
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.
elements
- the elements to copycontainers
- the container, or list of containerssiblings
- the list of siblings element any of which may be
null
; or null
renamings
- the list of new names any of which may be
null
; or null
replace
- 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
) void delete(IJavaElement[] elements, boolean force, org.eclipse.core.runtime.IProgressMonitor monitor) throws JavaModelException
elements
- 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
) IJavaProject getJavaProject(java.lang.String name)
name
- the name of the Java project
IJavaProject[] getJavaProjects() throws JavaModelException
JavaModelException
- if this request fails.java.lang.Object[] getNonJavaResources() throws JavaModelException
Non-Java projects include all projects that are closed (even if they have the Java nature).
IProject
s) contained
in the workspace.
JavaModelException
- if this element does not exist or if an
exception occurs while accessing its corresponding resourceIWorkspace getWorkspace()
void move(IJavaElement[] elements, IJavaElement[] containers, IJavaElement[] siblings, java.lang.String[] renamings, boolean replace, org.eclipse.core.runtime.IProgressMonitor monitor) throws JavaModelException
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.
elements
- the elements to movecontainers
- the container, or list of containerssiblings
- the list of siblings element any of which may be
null
; or null
renamings
- the list of new names any of which may be
null
; or null
replace
- 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
) java.lang.IllegalArgumentException
- any element or container is null
void refreshExternalArchives(IJavaElement[] elementsScope, org.eclipse.core.runtime.IProgressMonitor monitor) throws JavaModelException
null
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.
elementsScope
- - a collection of elements defining the scope of the refreshmonitor
- - a progress monitor used to report progress
JavaModelException
- in one of the corresponding situation:
IJavaElementDelta
void rename(IJavaElement[] elements, IJavaElement[] destinations, java.lang.String[] names, boolean replace, org.eclipse.core.runtime.IProgressMonitor monitor) throws JavaModelException
elements
- the elements to renamedestinations
- the container, or list of containersnames
- the list of new namesreplace
- 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
)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |