| java.lang.Object org.netbeans.api.project.FileOwnerQuery
FileOwnerQuery | public class FileOwnerQuery (Code) | | Find the project which owns a file.
There is a default implementation of
org.netbeans.spi.project.FileOwnerQueryImplementation which considers a file owned by the project corresponding to the nearest enclosing
project directory or marked external owner, if such a directory exists. But
other implementations can be registered to lookup as well.
Warning: This class and it's methods may not be used within DataObject recognition in DataLoaders.
eg. in
org.openide.loaders.MultiFileLoader.findPrimaryFile author: Jesse Glick |
Field Summary | |
final public static int | EXTERNAL_ALGORITHM_TRANSIENT Simplest algorithm for marking external file owners, which just keeps
a transient memory cache of this information.
The external marking is only guaranteed to be good during this VM session
for as long as the external file root is retained in memory as a
FileObject . |
Method Summary | |
public static Project | getOwner(FileObject file) Find the project, if any, which "owns" the given file. | public static Project | getOwner(URI uri) Find the project, if any, which "owns" the given URI. | public static void | markExternalOwner(FileObject root, Project owner, int algorithm) Mark an external folder or file as being owned by a particular project. | public static void | markExternalOwner(URI root, Project owner, int algorithm) Mark an external URI (folder or file) as being owned by a particular project. | static void | reset() Intended for use from unit tests. |
EXTERNAL_ALGORITHM_TRANSIENT | final public static int EXTERNAL_ALGORITHM_TRANSIENT(Code) | | Simplest algorithm for marking external file owners, which just keeps
a transient memory cache of this information.
The external marking is only guaranteed to be good during this VM session
for as long as the external file root is retained in memory as a
FileObject . For this reason, a project which makes such a
marking when it is created is obliged to hold a reference to the external
file root for as long as the project itself is in memory, to ensure that
it continues to work.
|
getOwner | public static Project getOwner(FileObject file)(Code) | | Find the project, if any, which "owns" the given file.
Parameters: file - the file (generally on disk) a project which contains it, or null if there is no known project containing it |
getOwner | public static Project getOwner(URI uri)(Code) | | Find the project, if any, which "owns" the given URI.
Parameters: uri - the uri to the file (generally on disk); must be absolute and not opaque a project which contains it, or null if there is no known project containing it throws: IllegalArgumentException - if the URI is relative or opaque |
markExternalOwner | public static void markExternalOwner(FileObject root, Project owner, int algorithm) throws IllegalArgumentException(Code) | | Mark an external folder or file as being owned by a particular project.
After this call is made, for the duration appropriate to the selected
algorithm, that folder or file and its ancestors will be considered owned
by the project (if any) matching the named project directory, except in
the case that a lower enclosing project directory can be found.
Typical usage would be to call this method for each external source root
of a project (if any) as soon as the project is loaded, if a transient
algorithm is selected, or only when the project is created, if a reliable
persistent algorithm is selected.
Parameters: root - a folder or a file which should be considered part of a project Parameters: owner - a project which should be considered to own that folder tree(any prior marked external owner is overridden),or null to cancel external ownership for this folder root Parameters: algorithm - an algorithm to use for retaining this information;currently may only be FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT throws: IllegalArgumentException - if the root or owner is null, if an unsupportedalgorithm is requested,if the root is already a project directory,or if the root is already equal to or inside the owner'sproject directory (it may however be an ancestor) See Also: SourcesHelper |
markExternalOwner | public static void markExternalOwner(URI root, Project owner, int algorithm) throws IllegalArgumentException(Code) | | Mark an external URI (folder or file) as being owned by a particular project.
After this call is made, for the duration appropriate to the selected
algorithm, that folder or file and its ancestors will be considered owned
by the project (if any) matching the named project directory, except in
the case that a lower enclosing project directory can be found.
Typical usage would be to call this method for each external source root
of a project (if any) as soon as the project is loaded, if a transient
algorithm is selected, or only when the project is created, if a reliable
persistent algorithm is selected.
Parameters: root - an URI of a folder or a file which should be considered part of a project Parameters: owner - a project which should be considered to own that folder tree(any prior marked external owner is overridden),or null to cancel external ownership for this folder root Parameters: algorithm - an algorithm to use for retaining this information;currently may only be FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT throws: IllegalArgumentException - if the root or owner is null, if an unsupportedalgorithm is requested,if the root is already a project directory,or if the root is already equal to or inside the owner'sproject directory (it may however be an ancestor) See Also: SourcesHelper |
reset | static void reset()(Code) | | Intended for use from unit tests. Clears internal state such as
external file owners.
|
|
|