Class URIUtil
java.lang.Object
org.eclipse.birt.report.model.api.util.URIUtil
Utility class to handle URI.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
convertFileNameToURLString
(String filePath) Converts a filename to a valid URL string.static URL
getDirectory
(String filePath) Deprecated.not supportedstatic URL
getDirectory
(URL url) Deprecated.not supportedstatic String
getLocalPath
(String uri) Checksuri
is file path.static String
getRelativePath
(String base, String resource) Return the relative path for the givenresource
according tobase
.static boolean
isValidResourcePath
(String resourceDir) Tests whether the input string is a valid resource directory.static String
resolveAbsolutePath
(String base, String relativePath) Gets the absolute path for the givenbase
andrelativePath
.
-
Field Details
-
FILE_SCHEMA
File schema.- See Also:
-
-
Constructor Details
-
URIUtil
public URIUtil()
-
-
Method Details
-
getLocalPath
Checksuri
is file path. Ifuri
is an absolute uri and refers to a file, removes "file://" and returns the file path. Ifuri
is relative uri and refers to a file, returns theuri
. For other cases, returns null.For examples, following uri are supported:
- file://C:/disk/test/data.file
- /C:/disk/test/data.file
- /usr/local/disk/test/data.file
- C:\\disk\\test/data.file
- C:/disk/test/data.file
- ./test/data.file
- Parameters:
uri
- the input uri- Returns:
- the file path if
uri
refers to a file. Otherwise null.
-
convertFileNameToURLString
Converts a filename to a valid URL string. The filename can include directory information, either relative or absolute directory.- Parameters:
filePath
- the file name- Returns:
- a valid URL String
-
getDirectory
Deprecated.not supportedReturns the directory of the given file name in a valid URL. The filename can include directory information, either relative or absolute directory. And the file should be on the local disk. The parameter filePath should be decoded. If the filePath is encoded, it should be converted to URL and call getDirectory as the parameter.- Parameters:
filePath
- the file name- Returns:
- a valid URL
-
getDirectory
Deprecated.not supportedReturns the directory of the given file name in a valid URL.The filename can include directory information, either relative or absolute directory. And the file should be on the local disk. The url has been encoded.- Parameters:
url
- the url of the file.- Returns:
- a valid URL
-
getRelativePath
Return the relative path for the givenresource
according tobase
. Only handle file system and valid url syntax.The
base
value should be directory ONLY and does NOT contain file name and the format can be:- ./../hello/
- C:\\hello\..\
- /C:/../hello/
/
in the end of directory will be striped in the return value.- Parameters:
base
- the base directoryresource
- the full path- Returns:
- the relative path.
-
resolveAbsolutePath
Gets the absolute path for the givenbase
andrelativePath
.The
base
value should be directory ONLY and does NOT contain file name and the format can be:- ./../hello/
- C:\\hello\..\
- /C:/../hello/
- Parameters:
base
- the base directoryrelativePath
- the relative path- Returns:
- the absolute path
-
isValidResourcePath
Tests whether the input string is a valid resource directory.- Parameters:
resourceDir
- the resource directory- Returns:
true
if the input string is a valid resource directory,false
otherwise.- Throws:
MalformedURLException
-