In addition, a leading "~", followed by either the standard
file-separator character or "/", is replaced with the user's home
directory. The sequence "~~" at the start of a component will be
replaced by a single "~". All subsequent "~" characters in that
component are left as is. The method
getURLs(File,String,String)
and
getURLs(File,String,String, Appendable)
will
treat a leading "..." followed by the file separator or "/" as
a shorthand for a specified directory. The programs scrunner and
lsnof set that directory to the one containing the BZDev library's
JAR file.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic URL[]
Parse a list of URLs or file names, separated by "|", given a directory.static URL[]
Parse a list of URLs or file names, separated by "|", given a directory.static URL[]
getURLs
(File dir, String urlPath, String threeDotDir, Appendable output) Parse list of URLs or file names, separated by "|", given a directory with an optional file-name test.static URL[]
Parse a list of URLs or file names, separated by "|".static String[]
Parse a path of URLs or file names that are separated by "|".
-
Constructor Details
-
URLPathParser
public URLPathParser()
-
-
Method Details
-
getURLs
Parse a list of URLs or file names, separated by "|". Relative files are resolved using the current working directory. In addition, for each URL, a leading~~
will be replaced with~
, and~
followed by the filename separator will be replaced with the user's home directory followed by the filename separator (in this case, a security exception will be thrown if the caller does not have permission to acesss the system propertyuser.home
).- Parameters:
urlPath
- the string representation of multiple URLs or files, separated by "|"- Returns:
- an array of URLs
- Throws:
MalformedURLException
- if there was a syntax error
-
getURLs
Parse a list of URLs or file names, separated by "|", given a directory. Relative files are resolved using the current working directory. If the argument urlPath is an empty string, the array returned will have a length of 0. In addition, for each URL, a leading~~
will be replaced with~
, and~
followed by the filename separator will be replaced with the user's home directory followed by the filename separator (in this case, a security exception will be thrown if the caller does not have permission to acesss the system propertyuser.home
).- Parameters:
dir
- the directory against which to resolve relative files; null indicates the current working directoryurlPath
- the string representation of multiple URLs or files, separated by "|"- Returns:
- an array of URLs
- Throws:
MalformedURLException
- a URL was malformed
-
getURLs
public static URL[] getURLs(File dir, String urlPath, String threeDotDir) throws MalformedURLException, SecurityException Parse a list of URLs or file names, separated by "|", given a directory.When the third argument
threeDotDir
is not null, some substitutions may be performed The string "...", if it starts a file name as opposed to a URL and is followed by the name separator ("/" on Unix), will be replaced with the directory given by the third argument when that argument is not null. In addition,~~
will be replaced with~
, and~
followed by the filename separator will be replaced with the user's home directory followed by the filename separator (in this case, a security exception will be thrown if the caller does not have permission to acesss the system propertyuser.home
).A file component is not tested to see if the file (or directory) exists and is readable by the application. If the argument urlPath is an empty string, the array returned will have a length of 0. Relative files are resolved using the current working directory.
- Parameters:
dir
- the directory against which to resolve relative files; null indicates the current working directoryurlPath
- the string representation of multiple URLs or files, separated by "|"threeDotDir
- the directory that will replace a leading file-name component equal to "..."; null for no replacement- Returns:
- an array of URLs
- Throws:
MalformedURLException
- a URL was malformedSecurityException
- a security exception occurred (most likely because the system property user.home could not be accessed)
-
getURLs
public static URL[] getURLs(File dir, String urlPath, String threeDotDir, Appendable output) throws MalformedURLException, SecurityException Parse list of URLs or file names, separated by "|", given a directory with an optional file-name test.When the third argument
threeDotDir
is not null, some substitutions may be performed The string "...", if it starts a file name as opposed to a URL and is followed by the name separator ("/" on Unix), will be replaced with the directory given by the third argument when that argument is not null. In addition, for each URL, a leading~~
will be replaced with~
, and~
followed by the filename separator will be replaced with the user's home directory followed by the filename separator (in this case, a security exception will be thrown if the caller does not have permission to acesss the system propertyuser.home
). If the argument is an empty string, the array returned will have a length of 0. Relative files are resolved using the current working directory.- Parameters:
dir
- the directory against which to resolve relative files; null indicates the current working directoryurlPath
- the string representation of multiple URLs or files, separated by "|"threeDotDir
- the directory that will replace a leading file-name component equal to "..."; null for no replacementoutput
- an Appendable to log output for a file-name test; null a file-name test is not wanted- Returns:
- an array of URLs
- Throws:
MalformedURLException
- a URL was malformedSecurityException
- a security exception occurred (most likely because the system property user.home could not be accessed)
-
split
Parse a path of URLs or file names that are separated by "|". When an odd number of "|" characters is found, all but the last are kept as part of a the current path component. Each string in the array of strings that is returned can be passed to on the getURLs method, which will then return an array whose length is 1. If the argument is an empty string, the array returned will have a length of 0.This method does not treat "~" as a special character.
- Parameters:
urlPath
- a string containing the URLs or file names.- Returns:
- an array of strings providing the paths or URLs.
-