|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.core.runtime.PlatformObject
org.eclipse.jdt.internal.core.JavaElement
org.eclipse.jdt.internal.core.Openable
org.eclipse.jdt.internal.core.PackageFragment
public class PackageFragment
IPackageFragment
Field Summary | |
---|---|
java.lang.String[] |
names
|
Fields inherited from class 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 |
Fields inherited from interface org.eclipse.jdt.core.IPackageFragment |
---|
DEFAULT_PACKAGE_NAME |
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 |
Fields inherited from interface org.eclipse.jdt.internal.compiler.util.SuffixConstants |
---|
EXTENSION_class, EXTENSION_CLASS, EXTENSION_java, EXTENSION_JAVA, SUFFIX_class, SUFFIX_CLASS, SUFFIX_java, SUFFIX_JAVA, SUFFIX_STRING_class, SUFFIX_STRING_CLASS, SUFFIX_STRING_java, SUFFIX_STRING_JAVA |
Method Summary | |
---|---|
boolean |
containsJavaResources()
Returns true if this fragment contains at least one java resource. |
void |
copy(IJavaElement container,
IJavaElement sibling,
java.lang.String rename,
boolean force,
org.eclipse.core.runtime.IProgressMonitor monitor)
Copies this element to the given container. |
ICompilationUnit |
createCompilationUnit(java.lang.String cuName,
java.lang.String contents,
boolean force,
org.eclipse.core.runtime.IProgressMonitor monitor)
Creates and returns a compilation unit in this package fragment with the specified name and contents. |
void |
delete(boolean force,
org.eclipse.core.runtime.IProgressMonitor monitor)
Deletes this element, forcing if specified and necessary. |
boolean |
equals(java.lang.Object o)
Returns true if this handle represents the same Java element as the given handle. |
boolean |
exists()
Returns whether this Java element exists in the model. |
java.lang.String |
getAttachedJavadoc(org.eclipse.core.runtime.IProgressMonitor monitor)
Returns the Javadoc as an html source if this element has an attached javadoc, null otherwise. |
IClassFile |
getClassFile(java.lang.String classFileName)
Returns the class file with the specified name in this package (for example, "Object.class" ). |
IClassFile[] |
getClassFiles()
Returns a the collection of class files in this - a folder package fragment which has a root that has its kind set to IPackageFragmentRoot.K_Source does not
recognize class files. |
ICompilationUnit |
getCompilationUnit(java.lang.String cuName)
Returns the compilation unit with the specified name in this package (for example, "Object.java" ). |
ICompilationUnit[] |
getCompilationUnits()
Returns all of the compilation units in this package fragment. |
ICompilationUnit[] |
getCompilationUnits(WorkingCopyOwner owner)
Returns all of the compilation units in this package fragment that are in working copy mode and that have the given owner. |
java.lang.String |
getElementName()
Returns the name of this element. |
int |
getElementType()
Returns this element's kind encoded as an integer. |
IJavaElement |
getHandleFromMemento(java.lang.String token,
MementoTokenizer memento,
WorkingCopyOwner owner)
|
int |
getKind()
Returns this package fragment's root kind encoded as an integer. |
java.lang.Object[] |
getNonJavaResources()
Returns an array of non-java resources contained in the receiver. |
org.eclipse.core.runtime.IPath |
getPath()
Returns the path to the innermost resource enclosing this element. |
IResource |
getUnderlyingResource()
Returns the smallest underlying resource that contains this element, or null if this element is not contained
in a resource. |
boolean |
hasChildren()
Returns whether this element has one or more immediate children. |
int |
hashCode()
Returns the hash code for this Java element. |
boolean |
hasSubpackages()
Returns whether this package fragment's name is a prefix of other package fragments in this package fragment's root. |
boolean |
isDefaultPackage()
Returns whether this package fragment is a default package. |
void |
move(IJavaElement container,
IJavaElement sibling,
java.lang.String rename,
boolean force,
org.eclipse.core.runtime.IProgressMonitor monitor)
Moves this element to the given container. |
void |
rename(java.lang.String newName,
boolean force,
org.eclipse.core.runtime.IProgressMonitor monitor)
Renames this element to the given name. |
IResource |
resource(PackageFragmentRoot root)
|
Methods inherited from class org.eclipse.jdt.internal.core.Openable |
---|
bufferChanged, canBeRemovedFromCache, canBufferBeRemovedFromCache, findRecommendedLineSeparator, getBuffer, getBufferFactory, getCorrespondingResource, getOpenable, getPackageFragmentRoot, getResource, hasUnsavedChanges, isConsistent, isOpen, isStructureKnown, makeConsistent, open, resource, save |
Methods inherited from class org.eclipse.jdt.internal.core.JavaElement |
---|
close, findNode, getAncestor, getChildren, getChildrenOfType, getClassFile, getCompilationUnit, getElementInfo, getElementInfo, getHandleFromMemento, getHandleIdentifier, getHandleMemento, getJavaModel, getJavaProject, getOpenableParent, getParent, getPrimaryElement, getPrimaryElement, getSchedulingRule, getSourceMapper, isAncestorOf, isReadOnly, newJavaModelException, newNotPresentException, readableName, resolved, toDebugString, toString, toStringInfo, toStringWithAncestors, toStringWithAncestors, unresolved |
Methods inherited from class org.eclipse.core.runtime.PlatformObject |
---|
getAdapter |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.eclipse.jdt.core.IParent |
---|
getChildren |
Methods inherited from interface org.eclipse.jdt.core.IJavaElement |
---|
getAncestor, getCorrespondingResource, getHandleIdentifier, getJavaModel, getJavaProject, getOpenable, getParent, getPrimaryElement, getResource, getSchedulingRule, 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 |
Field Detail |
---|
public java.lang.String[] names
Method Detail |
---|
public boolean containsJavaResources() throws JavaModelException
containsJavaResources
in interface IPackageFragment
JavaModelException
- if this element does not exist or if an
exception occurs while accessing its corresponding resource.public void copy(IJavaElement container, IJavaElement sibling, java.lang.String rename, boolean force, org.eclipse.core.runtime.IProgressMonitor monitor) throws JavaModelException
ISourceManipulation
copy
in interface ISourceManipulation
container
- the containersibling
- the sibling element before which the copy should be inserted,
or null
if the copy should be inserted as the last child of
the containerrename
- the new name for the element, or null
if the copy
retains the name of this elementforce
- true
if any existing child in the 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 this element could not be copied. Reasons include:
CoreException
occurred while updating an underlying resource
replace
has been specified as false
ISourceManipulation
public ICompilationUnit createCompilationUnit(java.lang.String cuName, java.lang.String contents, boolean force, org.eclipse.core.runtime.IProgressMonitor monitor) throws JavaModelException
IPackageFragment
It is possible that a compilation unit with the same name already exists in this
package fragment.
The value of the force
parameter effects the resolution of
such a conflict:
true
- in this case the compilation is created with the new contentsfalse
- in this case a JavaModelException
is thrown
createCompilationUnit
in interface IPackageFragment
cuName
- the given namecontents
- the given contentsforce
- specify how to handle conflict is the same name already existsmonitor
- the given progress monitor
JavaModelException
- if the element could not be created. Reasons include:
CoreException
occurred while creating an underlying resource
null
(INVALID_CONTENTS)
IPackageFragment
public void delete(boolean force, org.eclipse.core.runtime.IProgressMonitor monitor) throws JavaModelException
ISourceManipulation
delete
in interface ISourceManipulation
force
- a flag controlling whether underlying resources that are not
in sync with the local file system will be tolerated (same as the force flag
in IResource operations).monitor
- a progress monitor
JavaModelException
- if this element could not be deleted. Reasons include:
CoreException
occurred while updating an underlying resource (CORE_EXCEPTION)ISourceManipulation
public boolean equals(java.lang.Object o)
JavaElement
If a subclass has other requirements for equality, this method must be overridden.
equals
in class JavaElement
Object.equals(java.lang.Object)
public boolean exists()
IJavaElement
Java elements are handle objects that may or may not be backed by an
actual element. Java elements that are backed by an actual element are
said to "exist", and this method returns true
. For Java
elements that are not working copies, it is always the case that if the
element exists, then its parent also exists (provided it has one) and
includes the element as one of its children. It is therefore possible
to navigated to any existing Java element from the root of the Java model
along a chain of existing Java elements. On the other hand, working
copies are said to exist until they are destroyed (with
IWorkingCopy.destroy
). Unlike regular Java elements, a
working copy never shows up among the children of its parent element
(which may or may not exist).
exists
in interface IJavaElement
exists
in class Openable
true
if this element exists in the Java model, and
false
if this element does not existIJavaElement
public IClassFile getClassFile(java.lang.String classFileName)
IPackageFragment
"Object.class"
).
The ".class" suffix is required.
This is a handle-only method. The class file may or may not be present.
getClassFile
in interface IPackageFragment
classFileName
- the given name
java.lang.IllegalArgumentException
- if the name does not end with ".class"IPackageFragment.getClassFile(String)
public IClassFile[] getClassFiles() throws JavaModelException
IPackageFragmentRoot.K_Source
does not
recognize class files.
getClassFiles
in interface IPackageFragment
JavaModelException
- if this element does not exist or if an
exception occurs while accessing its corresponding resource.IPackageFragment.getClassFiles()
public ICompilationUnit getCompilationUnit(java.lang.String cuName)
IPackageFragment
"Object.java"
).
The name has to be a valid compilation unit name.
This is a handle-only method. The compilation unit may or may not be present.
getCompilationUnit
in interface IPackageFragment
cuName
- the given name
java.lang.IllegalArgumentException
- if the name does not end with ".java"IPackageFragment.getCompilationUnit(String)
public ICompilationUnit[] getCompilationUnits() throws JavaModelException
IPackageFragment
Note: it is possible that a package fragment contains only
class files (in other words, its kind is K_BINARY
), in which
case this method returns an empty collection.
getCompilationUnits
in interface IPackageFragment
JavaModelException
- if this element does not exist or if an
exception occurs while accessing its corresponding resource.IPackageFragment.getCompilationUnits()
public ICompilationUnit[] getCompilationUnits(WorkingCopyOwner owner)
IPackageFragment
Only existing working copies are returned. So a compilation unit handle that has no corresponding resource on disk will be included if and only if is in working copy mode.
Note: it is possible that a package fragment contains only
class files (in other words, its kind is K_BINARY
), in which
case this method returns an empty collection.
getCompilationUnits
in interface IPackageFragment
owner
- the owner of the returned compilation units
IPackageFragment.getCompilationUnits(WorkingCopyOwner)
public java.lang.String getElementName()
IJavaElement
getElementName
in interface IJavaElement
getElementName
in interface IPackageFragment
getElementName
in class JavaElement
IAdaptable
public int getElementType()
IJavaElement
getElementType
in interface IJavaElement
IJavaElement
IJavaElement
public IJavaElement getHandleFromMemento(java.lang.String token, MementoTokenizer memento, WorkingCopyOwner owner)
getHandleFromMemento
in class JavaElement
public int getKind() throws JavaModelException
IPackageFragment
Java-like extensions
),
or .class
files. This is a convenience method.
getKind
in interface IPackageFragment
JavaModelException
- if this element does not exist or if an
exception occurs while accessing its corresponding resource.IPackageFragment.getKind()
public java.lang.Object[] getNonJavaResources() throws JavaModelException
getNonJavaResources
in interface IPackageFragment
IFile
s,
IFolder
s, or IStorage
s if the
package fragment is in an archive) contained in this package
fragment
JavaModelException
- if this element does not exist or if an
exception occurs while accessing its corresponding resource.IClasspathEntry.getInclusionPatterns()
,
IClasspathEntry.getExclusionPatterns()
public org.eclipse.core.runtime.IPath getPath()
IJavaElement
getPath
in interface IJavaElement
IJavaElement.getPath()
public IResource resource(PackageFragmentRoot root)
JavaElement.resource()
public IResource getUnderlyingResource() throws JavaModelException
IJavaElement
null
if this element is not contained
in a resource.
getUnderlyingResource
in interface IJavaElement
getUnderlyingResource
in class Openable
null
if none
JavaModelException
- if this element does not exist or if an
exception occurs while accessing its underlying resourceIJavaElement.getUnderlyingResource()
public int hashCode()
JavaElement
hashCode
in class JavaElement
public boolean hasChildren() throws JavaModelException
IParent
getChildren
is an empty array.
hasChildren
in interface IParent
hasChildren
in class JavaElement
JavaModelException
- if this element does not exist or if an
exception occurs while accessing its corresponding resourceIParent
public boolean hasSubpackages() throws JavaModelException
IPackageFragment
hasSubpackages
in interface IPackageFragment
JavaModelException
- if this element does not exist or if an
exception occurs while accessing its corresponding resource.IPackageFragment.hasSubpackages()
public boolean isDefaultPackage()
IPackageFragment
isDefaultPackage
in interface IPackageFragment
IPackageFragment.isDefaultPackage()
public void move(IJavaElement container, IJavaElement sibling, java.lang.String rename, boolean force, org.eclipse.core.runtime.IProgressMonitor monitor) throws JavaModelException
ISourceManipulation
move
in interface ISourceManipulation
container
- the containersibling
- the sibling element before which the element should be inserted,
or null
if the element should be inserted as the last child of
the containerrename
- the new name for the element, or null
if the
element retains its nameforce
- true
if any existing child in the 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 this element could not be moved. Reasons include:
CoreException
occurred while updating an underlying resource
replace
has been specified as false
ISourceManipulation.move(IJavaElement, IJavaElement, String, boolean, IProgressMonitor)
public void rename(java.lang.String newName, boolean force, org.eclipse.core.runtime.IProgressMonitor monitor) throws JavaModelException
ISourceManipulation
rename
in interface ISourceManipulation
newName
- the new name for the elementforce
- true
if any existing element 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 this element could not be renamed. Reasons include:
CoreException
occurred while updating an underlying resource
replace
has been specified as false
ISourceManipulation.rename(String, boolean, IProgressMonitor)
public java.lang.String getAttachedJavadoc(org.eclipse.core.runtime.IProgressMonitor monitor) throws JavaModelException
IJavaElement
Returns the Javadoc as an html source if this element has an attached javadoc, null otherwise.
This should be used only for binary elements. Source elements will always return null.
The encoding used to read the javadoc is the one defined by the content type of the file. If none is defined, then the project's encoding of this java element is used. If the project's encoding cannot be retrieved, then the platform encoding is used.
In case of the javadoc doesn't exist for this element, null is returned.
The html is extracted from the attached javadoc and provided as is. No transformation or validation is done.
getAttachedJavadoc
in interface IJavaElement
getAttachedJavadoc
in class JavaElement
monitor
- the given progress monitor
JavaModelException
- if:IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |