Class FileOwnerQuery
There is a default implementation of 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 MultiFileLoader
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intSimplest algorithm for marking external file owners, which just keeps a cache of this information.static final ProjectPseudoproject indicating just that a directory is definitely unowned. -
Method Summary
Modifier and TypeMethodDescriptionstatic ProjectFind the project, if any, which "owns" the given URI.static ProjectgetOwner(org.openide.filesystems.FileObject file) Find the project, if any, which "owns" the given file.static voidmarkExternalOwner(URI root, Project owner, int algorithm) Mark an external URI (folder or file) as being owned by a particular project.static voidmarkExternalOwner(org.openide.filesystems.FileObject root, Project owner, int algorithm) Mark an external folder or file as being owned by a particular project.
-
Field Details
-
UNOWNED
Pseudoproject indicating just that a directory is definitely unowned. May be returned by eithergetOwneroverload ofFileOwnerQueryImplementation, in which case null is returned from eithergetOwneroverload here. May also be passed to eithermarkExternalOwneroverload, in which case the standard directory search will be pruned at this point with no result.- Since:
- 1.46
-
EXTERNAL_ALGORITHM_TRANSIENT
public static final int EXTERNAL_ALGORITHM_TRANSIENTSimplest algorithm for marking external file owners, which just keeps a cache of this information. The external marking may be persisted across VM sessions, despite the name.- See Also:
-
-
Method Details
-
getOwner
Find the project, if any, which "owns" the given file.- Parameters:
file- the file (generally on disk)- Returns:
- a project which contains it, or null if there is no known project containing it
-
getOwner
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 (thoughjar-protocol URIs are unwrapped as a convenience)- Returns:
- 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(org.openide.filesystems.FileObject root, Project owner, int algorithm) throws IllegalArgumentException 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 projectowner- 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 orUNOWNEDif the directory is known definitely to be unownedalgorithm- an algorithm to use for retaining this information; currently may only beEXTERNAL_ALGORITHM_TRANSIENT- Throws:
IllegalArgumentException- if the root or owner is null, if an unsupported algorithm is requested, if the root is already a project directory, or if the root is already equal to or inside the owner's project directory (it may however be an ancestor)- See Also:
-
markExternalOwner
public static void markExternalOwner(URI root, Project owner, int algorithm) throws IllegalArgumentException 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 projectowner- 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 rootalgorithm- an algorithm to use for retaining this information; currently may only beEXTERNAL_ALGORITHM_TRANSIENT- Throws:
IllegalArgumentException- if the root or owner is null, if an unsupported algorithm is requested, if the root is already a project directory, or if the root is already equal to or inside the owner's project directory (it may however be an ancestor)- See Also:
-