org.eclipse.birt.report.model.api.util
Class URIUtil

java.lang.Object
  extended byorg.eclipse.birt.report.model.api.util.URIUtil

public class URIUtil
extends java.lang.Object

Utility class to handle URI.


Field Summary
static java.lang.String FILE_SCHEMA
           
 
Constructor Summary
URIUtil()
           
 
Method Summary
static java.lang.String convertFileNameToURLString(java.lang.String filePath)
          Converts a filename to a valid URL string.
static java.net.URL getDirectory(java.lang.String filePath)
          Converts a filename to a valid URL.
static java.lang.String getLocalPath(java.lang.String uri)
          Checks uri is file path.
static java.lang.String getRelativePath(java.lang.String base, java.lang.String resource)
          Return the relative path for the given resource according to base.
static java.lang.String resolveAbsolutePath(java.lang.String base, java.lang.String relativePath)
          Return the relative path for the given resource according to base.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FILE_SCHEMA

public static final java.lang.String FILE_SCHEMA
See Also:
Constant Field Values
Constructor Detail

URIUtil

public URIUtil()
Method Detail

getLocalPath

public static java.lang.String getLocalPath(java.lang.String uri)
Checks uri is file path. If uri is an absolute uri and refers to a file, removes "file://" and returns the file path. If uri is relative uri and refers to a file, returns the uri. For other cases, returns null.

For examples, following uri are supported:

Parameters:
uri - the input uri
Returns:
the file path if uri refers to a file. Otherwise null.

convertFileNameToURLString

public static java.lang.String convertFileNameToURLString(java.lang.String filePath)
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

public static java.net.URL getDirectory(java.lang.String filePath)
Converts a filename to a valid URL. The filename can include directory information, either relative or absolute directory. And the file should be on the local disk.

Parameters:
filePath - the file name
Returns:
a valid URL

getRelativePath

public static java.lang.String getRelativePath(java.lang.String base,
                                               java.lang.String resource)
Return the relative path for the given resource according to base. Only handle file system. Network protocols such as http, ftp, etc. are not supported. If such cases happens, resource is returned.

The base value should be directory ONLY and does NOT contain file name and the format can be:

The spearator in the return path is platform-indepedent "/". Please note that the / in the end of directory will be striped in the return value.

Parameters:
base - the base directory
resource - the full path
Returns:
the relative path.

resolveAbsolutePath

public static java.lang.String resolveAbsolutePath(java.lang.String base,
                                                   java.lang.String relativePath)
Return the relative path for the given resource according to base. Only handle file system. Network protocols such as http, ftp, etc. are not supported.

The base value should be directory ONLY and does NOT contain file name and the format can be:

The spearator in the return path is platform-depedent.

Parameters:
base - the base directory
relativePath - the relative path
Returns:
the absolute path


Copyright © 2005 Actuate Corp. All rights reserved.