helper
Class URLHelper
java.lang.Object
|
+--helper.URLHelper
- public class URLHelper
- extends Object
It collects some static helper functons to handle URLs.
Sometimes it's neccessary to convert URL from/to system pathes.
Or from string to strutural notations (e.g. com.sun.star.util.URL).
And sometimes java had another notation then the office it has.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
URLHelper
public URLHelper()
getFileURLFromSystemPath
public static String getFileURLFromSystemPath(File aSystemPath)
- Because the office need URLs for loading/saving documents
we must convert used system pathes.
And java use another notation for file URLs ... correct it.
- Parameters:
aSystemPath
- represent the file in system notation- Returns:
- [String]
a file url which represent the given system path
getFileURLFromSystemPath
public static String getFileURLFromSystemPath(String sSystemPath)
- The same as getFileURLFromSystemPath() before but uses string parameter instead
of a File type. It exist to supress converting of neccessary parameters in the
outside code. But of course getFileURLFromSystemPath(File) will be a little bit faster
then this method ...
- Parameters:
sSystemPath
- represent the file in system notation- Returns:
- [String]
a file url which represent the given system path
getURLWithProtocolFromSystemPath
public static String getURLWithProtocolFromSystemPath(File aSystemPath,
File aBasePath,
String sServerURL)
- Does the same as getFileURLFromSystemPath() before ... but uses
the given protocol string (e.g."http://") insted of "file:///".
- Parameters:
aSystemPath
- represent the file in system notationaBasePath
- define the base path of the aSystemPath value,
which must be replaced with the value of "sServerPath".sServerURL
- Will be used to replace sBasePath.- Returns:
- [String]
an url which represent the given system path
and uses the given protocol
getURLWithProtocolFromSystemPath
public static String getURLWithProtocolFromSystemPath(String sSystemPath,
String sBasePath,
String sServerPath)
- The same as getURLWithProtocolFromSystemPath() before but uses string parameter instead
of a File types. It exist to supress converting of neccessary parameters in the
outside code. But of course getURLWithProtocolFromSystemPath(File,File,String) will be
a little bit faster then this method ...
- Parameters:
sSystemPath
- represent the file in system notationsBasePath
- define the base path of the aSystemPath value,
which must be replaced with the value of "sServerPath".sServerPath
- Will be used to replace sBasePath.- Returns:
- [String]
an url which represent the given system path
and uses the given protocol
parseURL
public static URL parseURL(XURLTransformer xParser,
String sURL)
- This convert an URL (formated as a string) to a struct com.sun.star.util.URL.
It use a special service to do that: the URLTransformer.
Because some API calls need it and it's not allowed to set "Complete"
part of the util struct only. The URL must be parsed.
- Parameters:
sURL
- URL for parsing in string notation- Returns:
- [com.sun.star.util.URL]
URL in UNO struct notation
getSystemFilesFromDir
public static Vector getSystemFilesFromDir(String sStartDir)
- Return a name list of all available files of a directory.
We filter pure sub directories names. All other files
are returned as full qualified URL strings. So they can be
used for further purposes. One parameter define the start directory,
another one describe the url protocol, which the return URL names should have.
- Parameters:
sDir
- the start directory, which should include all test files- Returns:
- [Vector]
a filtered list of java File objects of all available files of the start dir
and all accessable sub directories.