Package com.ctc.wstx.util
Class URLUtil
java.lang.Object
com.ctc.wstx.util.URLUtil
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final PatternWhile URIs that contain pipe are wrong, we'll work around that for [WSTX-275]. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static StringcleanSystemId(String sysId) static InputStreaminputStreamFromURL(URL url) Method that tries to get a stream (ideally, optimal one) to read from the specified URL.static OutputStreamoutputStreamFromURL(URL url) Method that tries to get a stream (ideally, optimal one) to write to the resource specified by given URL.private static voidthrowIOException(Exception mex, String sysId) Helper method that tries to fully convert strange URL-specific exception to more general IO exception.static URLHelper method that will convert given file into equivalent URL.static URIuriFromSystemId(String sysId) static URLMethod that tries to create and return URL that denotes current working directory.static URLurlFromSystemId(String sysId) Method that tries to figure out how to create valid URL from a system id, without additional contextual information.static URLurlFromSystemId(String sysId, URL ctxt)
-
Field Details
-
URI_WINDOWS_FILE_PATTERN
While URIs that contain pipe are wrong, we'll work around that for [WSTX-275].
-
-
Constructor Details
-
URLUtil
private URLUtil()
-
-
Method Details
-
urlFromSystemId
Method that tries to figure out how to create valid URL from a system id, without additional contextual information. If we could use URIs this might be easier to do, but they are part of JDK 1.4, and preferably code should only require 1.2 (or maybe 1.3)- Throws:
IOException
-
uriFromSystemId
- Throws:
IOException- Since:
- 4.1
-
urlFromSystemId
- Throws:
IOException
-
urlFromCurrentDir
Method that tries to create and return URL that denotes current working directory. Usually used to create a context, when one is not explicitly passed.- Throws:
IOException
-
inputStreamFromURL
Method that tries to get a stream (ideally, optimal one) to read from the specified URL. Currently it just means creating a simple file input stream if the URL points to a (local) file, and otherwise relying on URL classes input stream creation method.- Throws:
IOException
-
outputStreamFromURL
Method that tries to get a stream (ideally, optimal one) to write to the resource specified by given URL. Currently it just means creating a simple file output stream if the URL points to a (local) file, and otherwise relying on URL classes input stream creation method.- Throws:
IOException
-
toURL
Helper method that will convert given file into equivalent URL. Encapsulated as a separate method to allow for working around problems with deprecation ofFile.toURL()method.- Throws:
IOException
-
cleanSystemId
-
throwIOException
Helper method that tries to fully convert strange URL-specific exception to more general IO exception. Also, to try to use JDK 1.4 feature without creating requirement, uses reflection to try to set the root cause, if we are running on JDK1.4- Throws:
IOException
-