Package qupath.lib.io
Class UriUpdater<T extends UriResource>
java.lang.Object
qupath.lib.io.UriUpdater<T>
- Type Parameters:
- T-
Helper class for updating URIs, for example whenever files have moved or projects have been transferred between computers.
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic classWrapper for a URI, providing access to aPathif available.static enumEnum representing the status of a URI, i.e.
- 
Method SummaryModifier and TypeMethodDescriptionintApply all current replacements, updating theUriResourceobjects.intGet a count of the items flagged as missing.intGet a count of the number of replacements for missing items.static <T extends UriResource>
 UriUpdater<T> create(Collection<T> resources) Create a new UriUpdater to support updating URIs for one or moreUriResourceobjects.static <T extends UriResource>
 UriUpdater<T> create(Collection<T> resources, Collection<UriUpdater.SingleUriItem> items, Map<UriUpdater.SingleUriItem, UriUpdater.SingleUriItem> replacements) Create a new UriUpdater using the specified collections.static <T extends UriResource>
 UriUpdater<T> create(T resource) Create a new UriUpdater to support updating URIs for a singleUriResource.static intfixUris(UriResource resource, Project<?> project) Attempt to fix any broken paths by updating URIs based upon the current project.getItems(UriUpdater.UriStatus status) Get all items with the specified status, or all items is status is null.Get all missing items.Get a map of all replacements.static StringlocateFile(String path, int searchDepth, Path... searchPaths) Attempt to update a file using the specified search paths.static URIlocateFile(URI uri, int searchDepth, Path... searchPaths) Attempt to update a URI to find an existing file using the specified search paths.makeReplacement(URI originalItem, URI updatedItem) Add a single replacement to the replacement map.Identify replacements for missing URIs by relativizing the URI.Identify replacements for missing URIs by relativizing paths.searchDepth(int maxDepth) Maximum search depth when usingsearchDepth(int)to match filenames in directories and subdirectories.searchPath(Path path) Search for filenames that match missing URIs, recursively up to the depth specified bysearchDepth(int).static UriResourceWrap one or more URIs in aUriResourceso they can be updated together.static UriResourcewrap(Collection<URI> uris) Wrap one or more URIs in aUriResourceso they can be updated together.
- 
Method Details- 
createCreate a new UriUpdater to support updating URIs for a singleUriResource.- Parameters:
- resource-
- Returns:
- Throws:
- IOException
 
- 
createpublic static <T extends UriResource> UriUpdater<T> create(Collection<T> resources) throws IOException Create a new UriUpdater to support updating URIs for one or moreUriResourceobjects.- Parameters:
- resources-
- Returns:
- Throws:
- IOException
 
- 
createpublic static <T extends UriResource> UriUpdater<T> create(Collection<T> resources, Collection<UriUpdater.SingleUriItem> items, Map<UriUpdater.SingleUriItem, UriUpdater.SingleUriItem> replacements) throws IOExceptionCreate a new UriUpdater using the specified collections. The main use of this is as a convenience to build a UI using observable collections.- Parameters:
- resources- collection of resources that may include URIs
- items- collection containing all the distinct URIs from resources, each as a- UriUpdater.SingleUriItem. Note that this collection will be regenerated, so any existing items in the collection will be removed.
- replacements- map used to store any replacements identified by the- UriUpdater. Note that any existing contents will be discarded.
- Returns:
- Throws:
- IOException
 
- 
wrapWrap one or more URIs in aUriResourceso they can be updated together. Any changes can then be requred from theUriResource.- Parameters:
- uris-
- Returns:
 
- 
wrapWrap one or more URIs in aUriResourceso they can be updated together. Note that the collection is not used directly. Any changes should be accessed from theUriResource.- Parameters:
- uris-
- Returns:
 
- 
locateFileAttempt to update a URI to find an existing file using the specified search paths.- Parameters:
- uri- the URI to search for
- searchDepth- the depth of the search (i.e. how many subdirectories)
- searchPaths- the base directories to search, in order
- Returns:
- a new URI corresponding to an existing file with the same name, or the original URI if no replacement was found or required
- Throws:
- IOException
 
- 
locateFilepublic static String locateFile(String path, int searchDepth, Path... searchPaths) throws IOException Attempt to update a file using the specified search paths.- Parameters:
- path- the path to a file that may or may not exist
- searchDepth- the depth of the search (i.e. how many subdirectories)
- searchPaths- the base directories to search, in order
- Returns:
- the path to a file with the same name as 'path' that does exist, or path unchanged if no existing file could be found.
- Throws:
- IOException
 
- 
fixUrisAttempt to fix any broken paths by updating URIs based upon the current project.- Parameters:
- resource- the resource to update
- project-
- Returns:
- number of URIs that were updated
 
- 
searchDepthMaximum search depth when usingsearchDepth(int)to match filenames in directories and subdirectories.- Parameters:
- maxDepth-
- Returns:
 
- 
relativeIdentify replacements for missing URIs by relativizing the URI. This is generally used to make corrections whenever a project has been moved.- Parameters:
- uriOriginal- the previous path (usually for the project)
- uriCurrent- the current path
- Returns:
 
- 
relativeIdentify replacements for missing URIs by relativizing paths. This is generally used to make corrections whenever a project has been moved.- Parameters:
- pathOriginal- the previous path (usually for the project)
- pathCurrent- the current path
- Returns:
 
- 
searchPathSearch for filenames that match missing URIs, recursively up to the depth specified bysearchDepth(int).- Parameters:
- path- the base directory within which to search
- Returns:
- See Also:
 
- 
makeReplacementAdd a single replacement to the replacement map.- Parameters:
- originalItem- current URI for a missing resource
- updatedItem- updated URI to use instead
- Returns:
 
- 
getReplacementsGet a map of all replacements.- Returns:
 
- 
applyReplacementsApply all current replacements, updating theUriResourceobjects.- Returns:
- Throws:
- IOException
 
- 
countMissingpublic int countMissing()Get a count of the items flagged as missing.- Returns:
 
- 
countReplacementspublic int countReplacements()Get a count of the number of replacements for missing items.- Returns:
 
- 
getMissingItemsGet all missing items.- Returns:
 
- 
getItemsGet all items with the specified status, or all items is status is null.- Parameters:
- status-
- Returns:
 
 
-