public final class VCSFileSystemUtils
extends java.lang.Object
Utility class for file system operations.
Modifier and Type | Method and Description |
---|---|
static java.net.URL[] |
canonicalizeURLs(java.net.URL[] urls)
Canonicalizes the given URLs and returns them in a new array.
|
static java.net.URL[] |
coalesceURLs(java.net.URL[] urls)
Coalesces the given URLs in such a manner that the selection is suitable for a recursive directory-based operation.
|
static ContentType |
getContentType(java.lang.String extension)
Gets the
ContentType for the given extension. |
static java.net.URL[] |
getContentTypeURLs(java.net.URL[] urls, ContentType contentType)
Gets the URLs, of those supplied, which have the given content type associated in the IDE.
|
static java.net.URL |
getDirectoryPathURL(java.net.URL url)
Gets the directory path-style URL representing the given URL.
|
static java.net.URL[] |
getParentURLs(java.net.URL url)
Gets all parent URLs for the given file.
|
static java.net.URL[] |
getParentURLs(java.net.URL[] urls)
Gets the set of all parent URLs for the given set of URLs.
|
static java.lang.String |
getPlatformPathName(java.net.URL url)
Gets the platform-dependent String representation of the URL.
|
static java.lang.String[] |
getURLFileNames(java.net.URL[] urls)
Gets the filenames (including extensions) of the given URLs.
|
static boolean |
isBaseURLFor(java.net.URL url1, java.net.URL url2)
Asks whether url1 represents a directory and url2 points to a location within url1's directory tree.
|
static boolean |
isContentTypeBinary(java.net.URL url)
Asks whether the given URL contains binary content, according to the IDE's content type registry.
|
static boolean |
isNonEditable(java.net.URL url) |
static java.lang.String[] |
listBinaryExtensions()
List all recognized binary file extensions registered with the IDE.
|
static java.util.Map<VCSHashURL,java.util.Collection<java.lang.String>> |
mapFilenamesByParent(java.net.URL[] urls)
Organizes the given URLs by their parent directories.
|
static java.util.Map<VCSHashURL,java.util.Collection<java.net.URL>> |
mapURLsByParent(java.net.URL[] urls)
Organizes the given URLs by their parent directories.
|
static java.net.URL |
newFileURL(java.lang.String filePath)
Creates a new URL using the "file" protocol.
|
static java.net.URL[] |
newTargetURLs(java.net.URL[] urls, java.net.URL target)
Creates new URLs for the target URL directory.
|
static java.io.InputStream |
openConflictsStreamAsContributor(java.net.URL url, java.lang.String charsetName)
Opens an
InputStream on the given URL, which contains diff3-style merge conflicts. |
static java.util.Map<java.net.URL,java.util.Collection<java.lang.String>> |
organizeFilenamesByParent(java.net.URL[] urls)
Deprecated.
replaced by
mapFilenamesByParent(java.net.URL[]) . It is bad practice to store URLs in Collections that require (or encourage) comparisons of keys or entries. URL.equals(Object) and URL.hashCode perform host comparison by name resolution through the DNS, which may be inordinately slow. The VCSHashURL wrapper class is provided to work around this problem. |
static java.util.Map<ContentType,java.util.Collection<java.net.URL>> |
organizeURLsByContentType(java.net.URL[] urls)
Organizes the given URLs by their content type.
|
static java.util.Map<java.net.URL,java.util.Collection<java.net.URL>> |
organizeURLsByParent(java.net.URL[] urls)
Deprecated.
replaced by
mapURLsByParent(java.net.URL[]) . It is bad practice to store URLs in Collections that require (or encourage) comparisons of keys or entries. URL.equals(Object) and URL.hashCode perform host comparison by name resolution through the DNS, which may be inordinately slow. The VCSHashURL wrapper class is provided to work around this problem. |
static void |
registerDecorator(java.lang.String protocol, URLFileSystemHelperDecorator decorator)
Registers the specified
URLFileSystemHelperDecorator as an element in the chain of objects that can handle URLFileSystem operations for URL s of the specified protocol . |
static void |
registerFileType(java.lang.String extension, ContentType contentType)
Registers a default file type against the given extension in the IDE.
|
static java.net.URL[] |
removeRefAndQueryParts(java.net.URL[] urls)
Removes the reference and query parts of the given URLs.
|
static java.net.URL |
searchSystemPath(java.lang.String name)
Searches the system environment path for a named executable URL.
|
static java.net.URL[] |
searchSystemPathFully(java.lang.String name)
Searches the full system environment path for all named executable URLs.
|
@Deprecated public static final java.util.Map<java.net.URL,java.util.Collection<java.net.URL>> organizeURLsByParent(java.net.URL[] urls)
mapURLsByParent(java.net.URL[])
. It is bad practice to store URLs in Collections that require (or encourage) comparisons of keys or entries. URL.equals(Object)
and URL.hashCode
perform host comparison by name resolution through the DNS, which may be inordinately slow. The VCSHashURL
wrapper class is provided to work around this problem.urls
- the URLs to organize.URL
-> Collection
), where Collection is a collection of URLs.public static final java.util.Map<VCSHashURL,java.util.Collection<java.net.URL>> mapURLsByParent(java.net.URL[] urls)
urls
- the URLs to organize.URL
-> Collection
), where Collection is a collection of URLs.@Deprecated public static final java.util.Map<java.net.URL,java.util.Collection<java.lang.String>> organizeFilenamesByParent(java.net.URL[] urls)
mapFilenamesByParent(java.net.URL[])
. It is bad practice to store URLs in Collections that require (or encourage) comparisons of keys or entries. URL.equals(Object)
and URL.hashCode
perform host comparison by name resolution through the DNS, which may be inordinately slow. The VCSHashURL
wrapper class is provided to work around this problem.urls
- the URLs to organize.URL
-> Collection
), where Collection is a collection of filenames.public static final java.util.Map<VCSHashURL,java.util.Collection<java.lang.String>> mapFilenamesByParent(java.net.URL[] urls)
urls
- the URLs to organize.URL
-> Collection
), where Collection is a collection of filenames.public static final java.lang.String[] getURLFileNames(java.net.URL[] urls)
urls
- the URLs whose filenames should be obtained.public static final java.net.URL[] canonicalizeURLs(java.net.URL[] urls)
urls
- the URLs to canonicalize.public static final java.net.URL searchSystemPath(java.lang.String name)
name
- the name of the executable file (minus extension) to search for.public static final java.net.URL[] searchSystemPathFully(java.lang.String name)
name
- the name of the executable files (minus extension) to search for.public static final java.net.URL[] getParentURLs(java.net.URL url)
url
- file.public static final java.net.URL[] getParentURLs(java.net.URL[] urls)
urls
-public static final boolean isBaseURLFor(java.net.URL url1, java.net.URL url2)
true
(unlike the URLFileSystem implementation).url1
- the potential base URL.url2
- the URL to test.public static final java.net.URL[] newTargetURLs(java.net.URL[] urls, java.net.URL target)
urls
- the source URLs on which new URLs are based.target
- the target URL directory.public static final java.net.URL newFileURL(java.lang.String filePath)
filePath
- the path for the URL to create.public static final java.lang.String getPlatformPathName(java.net.URL url)
url
- the URL for the path to return.public static final java.net.URL[] removeRefAndQueryParts(java.net.URL[] urls)
urls
- the URLs whose reference and query parts will be removed.public static final ContentType getContentType(java.lang.String extension)
ContentType
for the given extension.extension
- the file extension.public static final java.net.URL[] getContentTypeURLs(java.net.URL[] urls, ContentType contentType)
urls
- the URLs whose content types will be checked.contentType
- the content type to filter by.public static final java.util.Map<ContentType,java.util.Collection<java.net.URL>> organizeURLsByContentType(java.net.URL[] urls)
urls
- the URLs to organize.ContentType
-> Collection
), where Collection is a collection of URLs. Note that a null
ContentType key indicates that URLs do not have an associated registered file type.public static final void registerFileType(java.lang.String extension, ContentType contentType)
extension
- the extension to register.contentType
- the associated content type.public static final java.net.URL getDirectoryPathURL(java.net.URL url)
url
- the URL.public static final java.net.URL[] coalesceURLs(java.net.URL[] urls)
urls
- the URLs to coalesce.public static void registerDecorator(java.lang.String protocol, URLFileSystemHelperDecorator decorator)
URLFileSystemHelperDecorator
as an element in the chain of objects that can handle URLFileSystem
operations for URL
s of the specified protocol
.
If the protocol
is null
or the empty string or if decorator
is null
, this method does nothing.
protocol
- the protocol whose helper chain should be decorated.decorator
- the decorator instance.public static boolean isNonEditable(java.net.URL url)
public static final java.io.InputStream openConflictsStreamAsContributor(java.net.URL url, java.lang.String charsetName) throws java.io.IOException
InputStream
on the given URL, which contains diff3-style merge conflicts. The resulting stream is a partial reconstruction of the local contributor to the conflicts file, before the merge. It is the same as the contents of the conflicts file with all blocks from the local file selected, and blocks from the conflicting file ignored.url
- the URL to open.charsetName
- the encoding of the stream.InputStream
on the deconstructed conflicts file.java.io.IOException
- if an I/O error occurs while creating the input stream.public static final java.lang.String[] listBinaryExtensions()
public static final boolean isContentTypeBinary(java.net.URL url)
url
- the URL.ContentType.BINARY
.