Package gov.nasa.pds.tools.util
Class Utility
java.lang.Object
gov.nasa.pds.tools.util.Utility
public class Utility extends Object
Utility class.
- Author:
- mcayanan
-
Field Summary
Fields Modifier and Type Field Description static HashMap<String,ValidationTarget>
cachedTargets
-
Constructor Summary
Constructors Constructor Description Utility()
-
Method Summary
Modifier and Type Method Description static boolean
canRead(String url)
static boolean
canRead(URL url)
static String
fixSlashes(String sysid)
Replace backslashes with forward slashes.static URL
getParent(URL url)
static ValidationTarget
getValidationTarget(URL target)
Returns a ValidationTarget for the specified target URL.static boolean
isDir(String url)
static boolean
isDir(URL url)
static String
makeAbsolute(String base, String sysid)
Construct an absolute URI from a relative one, using the current base URI.static InputSource
openConnection(URL url)
static InputStream
openConnection(URLConnection conn)
Method that opens a connection.static String
removeLastSlash(String url)
static boolean
supportXincludes()
Convenience method for disabling xinclude support throughout the core library.static URL
toURL(String target)
static List<URL>
toURL(List<String> targets)
-
Field Details
-
cachedTargets
-
-
Constructor Details
-
Utility
public Utility()
-
-
Method Details
-
getValidationTarget
Returns a ValidationTarget for the specified target URL. If a cached target already exists in the cache, then that is returned, otherwise a new ValidationTarget is returned. -
openConnection
Method that opens a connection. Supports redirects.- Parameters:
conn
- URL Connection- Returns:
- input stream.
- Throws:
IOException
- If an error occurred while opening the stream.
-
openConnection
- Throws:
IOException
-
toURL
- Throws:
MalformedURLException
-
toURL
- Throws:
MalformedURLException
-
isDir
-
isDir
-
getParent
-
canRead
-
canRead
-
removeLastSlash
-
supportXincludes
public static boolean supportXincludes()Convenience method for disabling xinclude support throughout the core library.- Returns:
-
fixSlashes
Replace backslashes with forward slashes. (URLs always use forward slashes.)- Parameters:
sysid
- The input system identifier.- Returns:
- The same system identifier with backslashes turned into forward slashes.
-
makeAbsolute
Construct an absolute URI from a relative one, using the current base URI.- Parameters:
sysid
- The (possibly relative) system identifier- Returns:
- The system identifier made absolute with respect to the
current
#base
. - Throws:
MalformedURLException
-