Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.flexstor.flexdbserver.util
Class PathBuilder  view PathBuilder download PathBuilder.java

java.lang.Object
  extended bycom.flexstor.flexdbserver.util.PathBuilder

public abstract class PathBuilder
extends java.lang.Object

PathBuilder is a utility class that constructs a file path based on the server, location and file name passed as arguments to its methods and the remote file protocol specified in the flexstordb.properties configuration file. In addition to passing the server, location and file name as arguments, PathBuilder supports the creation of file paths for assets represented as AssetRecordData and DisguiseAssetRecordData objects; in such cases, these objects are the single argument that PathBuilder's methods take. To construct a file path, PathBuilder first checks if the server property refers to a local or remote server; if local, it creates a path consistent with the operating system; if remote, it uses the appserver.remoteFileProtocol from the flexstordb.properties file and constructs the path as "file_protocol://server_name.domain/path/to/asset". This class was created as support for the Services Framework Specifications.


Constructor Summary
PathBuilder()
           
 
Method Summary
static java.lang.String addFileSeparators(java.lang.String sPath, boolean addLeading, boolean addTrailing)
          It analyzes the path and adds a leading and a trailing file separator if requested.
static java.lang.String constructFilePath(com.flexstor.common.data.AssetRecordData record)
          Creates a file path based on the information in AssetRecordData.
static java.lang.String constructFilePath(com.flexstor.common.data.ejb.disguiserecord.DisguiseAssetRecordData record)
          Creates a file path based on the information in DisguiseAssetRecordData.
static java.lang.String constructFilePath(java.lang.String sLocation, java.lang.String sFileName)
          Creates a file path based on the arguments passed.
static java.lang.String constructFilePath(java.lang.String sServer, java.lang.String sLocation, java.lang.String sFileName)
          Creates a file path based on the arguments passed.
static java.lang.String constructFilePath(java.lang.String sProtocol, java.lang.String sServer, java.lang.String sLocation, java.lang.String sFileName)
          Creates a file path based on the arguments passed.
private static java.lang.String constructPath(boolean bForceURL, java.lang.String sProtocol, java.lang.String sServer, java.lang.String sLocation, java.lang.String sFileName)
          Creates a file path based on the arguments passed.
static java.lang.String constructPath(java.lang.String sServer, java.lang.String sPath, boolean addTrailingSeparator)
          Creates a path based on the arguments passed.
static java.lang.String constructPath(java.lang.String sProtocol, java.lang.String sServer, java.lang.String sPath, boolean bAddTrailingSeparator)
          Creates a path based on the arguments passed.
static java.lang.String constructURLFilePath(com.flexstor.common.data.AssetRecordData record)
          Creates a file path based on the AssetRecordData passed.
static java.lang.String constructURLFilePath(java.lang.String sProtocol, java.lang.String sServer, java.lang.String sLocation, java.lang.String sFileName)
          Creates a file path based on the arguments passed.
static java.lang.String constructURLPath(java.lang.String sServer, java.lang.String sPath, boolean bAddTrailingSeparator)
          Creates a path based on the arguments passed.
static java.lang.String constructURLPath(java.lang.String sProtocol, java.lang.String sServer, java.lang.String sPath, boolean bAddTrailingSeparator)
          Creates a path based on the arguments passed.
private static java.lang.String getRemoteFileProtocol()
          Returns the remote file protocol defined in the flexstordb.properties file.
private static java.lang.String getRightLocation(char separatorChar, java.lang.String sLocation)
          Returns the location with the right file separator for the operating system in use.
static java.lang.String removeFileSeparators(java.lang.String sPath, boolean removeLeading, boolean removeTrailing)
          It analyzes the path and removes the leading and a trailing file separator if requested.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PathBuilder

public PathBuilder()
Method Detail

constructFilePath

public static java.lang.String constructFilePath(com.flexstor.common.data.AssetRecordData record)
Creates a file path based on the information in AssetRecordData. If the server in the record represents a remote server, this call will return a url with the proper remote file protocol as defined in the flexstordb.properties file.


constructFilePath

public static java.lang.String constructFilePath(com.flexstor.common.data.ejb.disguiserecord.DisguiseAssetRecordData record)
Creates a file path based on the information in DisguiseAssetRecordData. If the server in the record represents a remote server, this call will return a url with the proper remote file protocol as defined in the flexstordb.properties file.


constructFilePath

public static java.lang.String constructFilePath(java.lang.String sProtocol,
                                                 java.lang.String sServer,
                                                 java.lang.String sLocation,
                                                 java.lang.String sFileName)
Creates a file path based on the arguments passed. This call will return a url String if the server is remote, otherwise it will return a local String. If the protocol or the server is null or an empty String, it will return a local path. If the server argument is just the server name, this call will find its corresponding DNS representation in the database. If the server argument represents a DNS, it will use it as it is.


constructFilePath

public static java.lang.String constructFilePath(java.lang.String sServer,
                                                 java.lang.String sLocation,
                                                 java.lang.String sFileName)
Creates a file path based on the arguments passed. This call will return a url String if the server is remote, otherwise it will return a local String. The protocol to be used will be the one defined in the flexstordb.properties file. If the server is null or an empty String, it will return a local path. If the server argument is just the server name, this call will find its corresponding DNS representation in the database. If the server argument represents a DNS, it will use it as it is.


constructFilePath

public static java.lang.String constructFilePath(java.lang.String sLocation,
                                                 java.lang.String sFileName)
Creates a file path based on the arguments passed. It will always create a local path.


constructURLFilePath

public static java.lang.String constructURLFilePath(com.flexstor.common.data.AssetRecordData record)
Creates a file path based on the AssetRecordData passed. This call will return a url String, regardless whether the server represents a remote or local server.


constructURLFilePath

public static java.lang.String constructURLFilePath(java.lang.String sProtocol,
                                                    java.lang.String sServer,
                                                    java.lang.String sLocation,
                                                    java.lang.String sFileName)
Creates a file path based on the arguments passed. This call will always return a url String regardless whether the server represents a remote or local server, except if the protocol is null or an empty String, in which case a local path is returned. If the server argument is just the server name, this call will find its corresponding DNS representation in the database. If the server argument represents a DNS, it will use it as it is.


constructPath

public static java.lang.String constructPath(java.lang.String sProtocol,
                                             java.lang.String sServer,
                                             java.lang.String sPath,
                                             boolean bAddTrailingSeparator)
Creates a path based on the arguments passed. This call will return a url String if the server is remote, otherwise it will return a local String. If the protocol or the server is null or an empty String, it will return a local path. If the server argument is just the server name, this call will find its corresponding DNS representation in the database. If the server argument represents a DNS, it will use it as it is. The path return does not contain a file separator at the end, since this tool does not make distintion between a file or a directory.


constructURLPath

public static java.lang.String constructURLPath(java.lang.String sProtocol,
                                                java.lang.String sServer,
                                                java.lang.String sPath,
                                                boolean bAddTrailingSeparator)
Creates a path based on the arguments passed. This call will always return a url String regardless whether the server represents a remote or local server, except if the protocol is null or an empty String, in which case a local path is returned. If the server argument is just the server name, this call will find its corresponding DNS representation in the database. If the server argument represents a DNS, it will use it as it is. The path return does not contain a file separator at the end, since this tool does not make distintion between a file or a directory.


constructURLPath

public static java.lang.String constructURLPath(java.lang.String sServer,
                                                java.lang.String sPath,
                                                boolean bAddTrailingSeparator)
Creates a path based on the arguments passed. This call will always return a url String regardless whether the server represents a remote or local server. If the server argument is just the server name, this call will find its corresponding DNS representation in the database. If the server argument represents a DNS, it will use it as it is. The path return does not contain a file separator at the end, since this tool does not make distintion between a file or a directory.


constructPath

public static java.lang.String constructPath(java.lang.String sServer,
                                             java.lang.String sPath,
                                             boolean addTrailingSeparator)
Creates a path based on the arguments passed. This call will return a url String if the server is remote, otherwise it will return a local String. If the server is null or an empty String, it will return a local path. If the server argument is just the server name, this call will find its corresponding DNS representation in the database. If the server argument represents a DNS, it will use it as it is. The path return does not contain a file separator at the end, since this tool does not make distintion between a file or a directory.


addFileSeparators

public static java.lang.String addFileSeparators(java.lang.String sPath,
                                                 boolean addLeading,
                                                 boolean addTrailing)
It analyzes the path and adds a leading and a trailing file separator if requested. A leading slash will be added if the path is not a url and only if it doesn't contain one already. It will add a trailing slash if the path doesn't contain a slash already.


removeFileSeparators

public static java.lang.String removeFileSeparators(java.lang.String sPath,
                                                    boolean removeLeading,
                                                    boolean removeTrailing)
It analyzes the path and removes the leading and a trailing file separator if requested.


constructPath

private static java.lang.String constructPath(boolean bForceURL,
                                              java.lang.String sProtocol,
                                              java.lang.String sServer,
                                              java.lang.String sLocation,
                                              java.lang.String sFileName)
Creates a file path based on the arguments passed. This call will return a url String if the server is remote, otherwise it will return a local String. If the protocol or the server is null or an empty String, it will return a local path. If the server argument is just the server name, this call will find its corresponding DNS representation in the database. If the server argument represents a DNS, it will use it as it is. The path return does not contain a file separator at the end, since this tool does not make distintion between a file or a directory.


getRemoteFileProtocol

private static java.lang.String getRemoteFileProtocol()
Returns the remote file protocol defined in the flexstordb.properties file. If one is not defined, default to "flex".


getRightLocation

private static java.lang.String getRightLocation(char separatorChar,
                                                 java.lang.String sLocation)
Returns the location with the right file separator for the operating system in use.