wt.httpgw
Class URLData

java.lang.Object
  extended bywt.httpgw.URLData
All Implemented Interfaces:
Comparator

public class URLData
extends Object
implements Comparator

The URLData class is a data structure utilized by the URLFactory and other classes that need the capability to store explicitly the URL information necessary to construct URLs and HREFs in the Windchill environment. The standard URL object is not applicable since it has no mechanism to separate an application root from the package heirarchy.

The URLData class supports the Comparator interface and may be used with the collections framework to be sorted and searched. The Name member is used to compare objects and two objects are considered equal is they have the same Name.

Optionally resources and query strings may be stored as part of the web path in the URLData class.

The packagePath should be declared with the Windchill codebase leading the packagepath. For example, if the package path is defined as wt/clients with a codebase of Windchill then the package path should take on the form /Windchill/wt/clients/



Supported API: true
Extendable: false


Field Summary
static int HTTP_PORT
          Constant for HTTP port (ref: RFC793)
static String HTTP_PROTOCOL
           
static int HTTPS_PORT
          Constant for HTTPS port (ref: RFC793)
static String HTTPS_PROTOCOL
           
static boolean ignore_ports
           
private  boolean ivbDirectory
           
private  String ivCompletePackagePath
          The package path as a string with '/' separating elements.
private  String ivHostname
           
private  String ivName
           
private  String[] ivPackagePath
           
private  int ivPort
           
private  String ivProtocol
           
private  String ivQueryString
           
private  String ivResource
           
 
Constructor Summary
URLData()
           
URLData(String aName, String aProtocol, String aHostname, int aPort, String[] aPackagePath, String aResource, String aQueryString)
           
 
Method Summary
 void appendPackageToPackagePath(String aPath)
          This method will append a package to the Package Path of the URLData.
 int compare(Object anObject, Object aComparison)
          Implement the compare method to compare the name of the URLData to another URLData object.
 boolean equals(Object aComparison)
           
 String getFullyQualifiedName()
          Will return the Fully Qualified Name for the class.
 String getFullyQualifiedName(boolean showPort)
          Will return the Fully Qualified Name for the class.
 String getHostname()
          Retrieves the stored Hostname.
 String getName()
          Retrieve the Name of the URLData object
 String[] getPackagePath()
          Retrieves the stored Package Path
 String getPackagePathAsString()
          Retrieves the package path as a String.
 int getPackagePathSize()
           
 int getPort()
          Retrives the stored Port
 String getProtocol()
          Retrieve the stored Protocol
 String getQueryString()
          Retrieve the stored query String.
 String getRelativeDifference(URLData base)
          This method will return the relative difference between this URLData and a reference or baseline URLData object.
 String getResource()
          Retrieve the resource.
 URL getURL()
          Will return an URL representation of the URLData
 boolean isDirectory()
          Whether the URLData represents a directory.
 void setDirectory(boolean aDirectory)
           
 void setHostname(String aHostname)
           
 void setName(String aName)
           
 void setPackagePath(String aPackage)
          This method will take in a String which represents the package path for a given resource and create a proper package path for the URLData object.
 void setPackagePath(String[] aPackage)
           
 boolean setPackagePathAndResource(String aData, boolean setResource)
          Tokenizes along '/' and sets the package path for the URLdata If the path does not end in a '/' then the last token is set as resource
 void setPort(int aPort)
          Sets the port for the URLData object.
 void setProtocol(String aProtocol)
           
 void setQueryString(String aQuery)
           
 void setResource(String aResource)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ivName

private String ivName

ivHostname

private String ivHostname

ivPackagePath

private String[] ivPackagePath

ivCompletePackagePath

private String ivCompletePackagePath
The package path as a string with '/' separating elements. This member is updated automatically when a new PackagePath is set or added to the current package path.


ivProtocol

private String ivProtocol

ivQueryString

private String ivQueryString

ivResource

private String ivResource

ivPort

private int ivPort

ivbDirectory

private boolean ivbDirectory

HTTPS_PORT

public static final int HTTPS_PORT
Constant for HTTPS port (ref: RFC793)

See Also:
Constant Field Values

HTTP_PORT

public static final int HTTP_PORT
Constant for HTTP port (ref: RFC793)

See Also:
Constant Field Values

HTTPS_PROTOCOL

public static final String HTTPS_PROTOCOL
See Also:
Constant Field Values

HTTP_PROTOCOL

public static final String HTTP_PROTOCOL
See Also:
Constant Field Values

ignore_ports

public static boolean ignore_ports
Constructor Detail

URLData

public URLData()

URLData

public URLData(String aName,
               String aProtocol,
               String aHostname,
               int aPort,
               String[] aPackagePath,
               String aResource,
               String aQueryString)
Method Detail

getPackagePathSize

public int getPackagePathSize()

getURL

public URL getURL()
           throws MalformedURLException
Will return an URL representation of the URLData

Returns:
an URL representing the URLData
Throws:
MalformedURLException - if the URLData object's members do not create a valid URL.

getFullyQualifiedName

public String getFullyQualifiedName()
Will return the Fully Qualified Name for the class. This will take on the form:

The port will NOT be inserted if it is one of the default ports (80 or 443 (for https)).

Returns:
The fully qualified name

getFullyQualifiedName

public String getFullyQualifiedName(boolean showPort)
Will return the Fully Qualified Name for the class. This may or may not contain the standard port numbers (80 and 443) as defined by the switch in the following format:

Parameters:
showPort - Whether to show the standard ports (80 and 443)
Returns:
The fully qualified name.

compare

public int compare(Object anObject,
                   Object aComparison)
Implement the compare method to compare the name of the URLData to another URLData object. The names are checked lexiographically and will return a negative integer if the current object is before the comparing object, zero if they are equal or positive if the comparing object appears before the current object.

Specified by:
compare in interface Comparator
Parameters:
anObject - The object to compare the current object to.
Returns:
negative if the current object is before the compared object, zero if equal, and positive if after.
Throws:
ClassCastException - thrown if a non URLData object is attempted to be compared.

equals

public boolean equals(Object aComparison)
Specified by:
equals in interface Comparator

getRelativeDifference

public String getRelativeDifference(URLData base)
This method will return the relative difference between this URLData and a reference or baseline URLData object. If the protocol, port or hostname is different on the base than the current URLData object a fully qualified name will be returned. The package path will return the difference from the base package path. For example, if the base package path is set to wt/clients/ and the current object represents a link in the wt/admin/ directory the package path will be set to "../admin/". Any resource or query strings will be appended to the end.

Parameters:
base - The base URLData object representing the RequestURI or reference object for the current object.
Returns:
The relative difference as a String object.

getHostname

public final String getHostname()
Retrieves the stored Hostname.


getPackagePath

public final String[] getPackagePath()
Retrieves the stored Package Path

Returns:
The package path.

getPackagePathAsString

public final String getPackagePathAsString()
Retrieves the package path as a String.

Returns:
The package path.

getProtocol

public final String getProtocol()
Retrieve the stored Protocol

Returns:
the Protocol

getPort

public final int getPort()
Retrives the stored Port

Returns:
The port.

getQueryString

public final String getQueryString()
Retrieve the stored query String.


getResource

public final String getResource()
Retrieve the resource.


getName

public final String getName()
Retrieve the Name of the URLData object


isDirectory

public final boolean isDirectory()
Whether the URLData represents a directory.

Returns:
whether the URLData is a directory.

setDirectory

public final void setDirectory(boolean aDirectory)

setHostname

public final void setHostname(String aHostname)

setPackagePath

public final void setPackagePath(String aPackage)
This method will take in a String which represents the package path for a given resource and create a proper package path for the URLData object.

Parameters:
aPackage - The package path to split up. ('/' is the separator)

setPackagePathAndResource

public final boolean setPackagePathAndResource(String aData,
                                               boolean setResource)
Tokenizes along '/' and sets the package path for the URLdata If the path does not end in a '/' then the last token is set as resource

Parameters:
aData - The input String.
setResource - whether to set resource string.
Returns:
boolean whether the resource was set

setPackagePath

public final void setPackagePath(String[] aPackage)

appendPackageToPackagePath

public final void appendPackageToPackagePath(String aPath)
This method will append a package to the Package Path of the URLData.


setPort

public final void setPort(int aPort)
Sets the port for the URLData object.

If no Port is set (ie. it is -1) the standard http port will be used.

Parameters:
aPort - The port to set.

setProtocol

public final void setProtocol(String aProtocol)

setQueryString

public final void setQueryString(String aQuery)

setResource

public final void setResource(String aResource)

setName

public final void setName(String aName)