Skip to main content
summaryrefslogtreecommitdiffstats
blob: ed893af0a28461da52d27661599c943284111a80 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
package org.eclipse.jdt.core;

/*
 * (c) Copyright IBM Corp. 2000, 2001.
 * All Rights Reserved.
 */
 
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;

/**
 * A package fragment root contains a set of package fragments.
 * It corresponds to an underlying resource which is either a folder,
 * JAR, or zip.  In the case of a folder, all descendant folders represent
 * package fragments.  For a given child folder representing a package fragment, 
 * the corresponding package name is composed of the folder names between the folder 
 * for this root and the child folder representing the package, separated by '.'.
 * In the case of a JAR or zip, the contents of the archive dictates 
 * the set of package fragments in an analogous manner.
 * Package fragment roots need to be opened before they can be navigated or manipulated.
 * The children are of type <code>IPackageFragment</code>, and are in no particular order.
 * <p>
 * This interface is not intended to be implemented by clients.
 * </p>
 */
public interface IPackageFragmentRoot extends IParent, IJavaElement, IOpenable {
	
	/**
	 * Kind constant for a source path root. Indicates this root
	 * only contains source files.
	 */
	int K_SOURCE = 1;
	
	/**
	 * Kind constant for a binary path root. Indicates this
	 * root only contains binary files.
	 */
	int K_BINARY = 2;
	/**
	 * Empty root path
	 */
	String DEFAULT_PACKAGEROOT_PATH = ""/*nonNLS*/;

/**
 * Attaches the source archive identified by the given absolute path to this
 * JAR package fragment root. <code>rootPath</code> specifies the location
 * of the root within the archive (<code>null</code> or empty specifies the default root).
 * Once a source archive is attached to the JAR,
 * the <code>getSource</code> and <code>getSourceRange</code>
 * methods become operational for binary types/members.
 * To detach a source archive from a JAR, specify <code>null</code> as the
 * archivePath.
 *
 * @exception JavaModelException if this operation fails. Reasons include:
 * <ul>
 * <li> This Java element does not exist (ELEMENT_DOES_NOT_EXIST)</li>
 * <li> A <code>CoreException</code> occurred while updating a server property
 * <li> This package fragment root is not a JAR (INVALID_ELEMENT_TYPES)
 * <li> The path provided is not absolute (RELATIVE_PATH)
 * </ul>
 * @deprecated - source attachment is to be specified using classpath entries.
 */
void attachSource(IPath archivePath, IPath rootPath, IProgressMonitor monitor) throws JavaModelException;
/**
 * Creates and returns a package fragment in this root with the 
 * given dot-separated package name.  An empty string specifies the default package. 
 * This has the side effect of creating all package
 * fragments that are a prefix of the new package fragment which
 * do not exist yet. If the package fragment already exists, this
 * has no effect.
 *
 * For a descrption of the <code>force</code> flag, see <code>IFolder.create</code>.
 *
 * @exception JavaModelException if the element could not be created. Reasons include:
 * <ul>
 * <li> This Java element does not exist (ELEMENT_DOES_NOT_EXIST)</li>
 * <li> A <code>CoreException</code> occurred while creating an underlying resource
 * <li> This package fragment root is read only (READ_ONLY)
 * <li> The name is not a valid package name (INVALID_NAME)
 * </ul>
 * @see org.eclipse.core.resources.IFolder#create
 */
IPackageFragment createPackageFragment(String name, boolean force, IProgressMonitor monitor) throws JavaModelException;
/**
 * Returns this package fragment root's kind encoded as an integer.
 * A package fragment root can contain <code>.java</code> source files,
 * or <code>.class</code> files, but not both.
 * If the underlying folder or archive contains other kinds of files, they are ignored.
 * In particular, <code>.class</code> files are ignored under a source package fragment root,
 * and <code>.java</code> files are ignored under a binary package fragment root.
 *
 * @see IPackageFragmentRoot#K_SOURCE
 * @see IPackageFragmentRoot#K_BINARY
 *
 * @exception JavaModelException if this element does not exist or if an
 *		exception occurs while accessing its corresponding resource.
 */
int getKind() throws JavaModelException;
/**
 * Returns an array of non-Java resources contained in this package fragment root.
 */
Object[] getNonJavaResources() throws JavaModelException;
/**
 * Returns the package fragment with the given package name.
 * An empty string indicates the default package.
 * This is a handle-only operation.  The package fragment
 * may or may not exist.
 */
IPackageFragment getPackageFragment(String packageName);
/**
 * Returns the path of this package fragment root. If this
 * package fragment root is not external, the path returned is the
 * full, absolute path to this package fragment root, relative to the
 * workbench. If this package fragment root is external, the path
 * returned is the absolute path to this package fragment root's
 * archive in the file system.
 */
IPath getPath();
/**
 * Returns the absolute path to the source archive attached to
 * this package fragment root's binary archive.
 *
 * @return the absolute path to the corresponding source archive, 
 *   or <code>null</code> if this package fragment root's binary archive
 *   has no corresponding source archive, or if this package fragment root
 *   is not a binary archive
 * @exception JavaModelException if this operation fails
 */
IPath getSourceAttachmentPath() throws JavaModelException;
/**
 * Returns the path within this package fragment root's source archive. 
 * An empty path indicates that packages are located at the root of the
 * source archive.
 *
 * @return the path within the corresponding source archive, 
 *   or <code>null</code> if this package fragment root's binary archive
 *   has no corresponding source archive, or if this package fragment root
 *   is not a binary archive
 * @exception JavaModelException if this operation fails
 */
IPath getSourceAttachmentRootPath() throws JavaModelException;
/**
 * Returns whether this package fragment root's underlying
 * resource is a binary archive (a JAR or zip file).
 */
public boolean isArchive();
/**
 * Returns whether this package fragment root is external
 * to the workbench (that is, a local file), and has no
 * underlying resource.
 */
boolean isExternal();
}

Back to the top