ccs.cpc
Class VFileUrl

java.lang.Object
  extended by ccs.cpc.VFileUrl

public class VFileUrl
extends java.lang.Object

In various places, it's common to want to express a VFile (as well as a certain amount of other red tape) as a URL. This first kicked in for the browser interface, and has now spread to the XSPF support (which is itself going to be used in several different places). This class encapsulates the translation, which is non-trivial. A VFileUrl is immutable. The complete format is:

<authority>/<deviceID>/<viewerID>/<actionID>/<filepath>


Constructor Summary
VFileUrl(java.lang.String urlpath, java.lang.String query, CpCmdr cpc, java.util.Set<java.lang.String> loseFolders, java.util.List<java.lang.String> loseFiles)
          Construct and resolve a VFile from a URL.
VFileUrl(VDevice vd, java.lang.String viewerID, java.lang.String actionID, java.lang.String filepath)
          Construct a URL for something other than a vfile, eg. a ControlHandler call.
VFileUrl(VFile vf, java.lang.String viewerID)
          Construct a URL path from a VFile.
 
Method Summary
 java.lang.String getActionID()
          The "action ID" embedded in the URL.
 VDevice getDevice()
           
 java.lang.String getDeviceID()
          Return the device ID.
 VFile getFile()
           
 java.lang.String getFilepath()
           
 java.lang.String getViewerID()
          The "viewer ID" embedded in the URL.
 java.lang.String toUrlPath()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VFileUrl

public VFileUrl(java.lang.String urlpath,
                java.lang.String query,
                CpCmdr cpc,
                java.util.Set<java.lang.String> loseFolders,
                java.util.List<java.lang.String> loseFiles)
         throws java.io.IOException
Construct and resolve a VFile from a URL.

Parameters:
urlpath - The path component of the URL. If there's a query, shove that on as well.
query - The query string, if any. Null is OK.
cpc - The CPC instance (used to resolve VDevices).
loseFolders - Optional. If a folder could not be resolved, an indicative string is added to this list. For user reporting. This is queried to avoid duplicate reports, so the implementation should provide fast lookups.
loseFiles - Optional. If a file could not be resolved, an indicative string is added to this list. For user reporting.
Throws:
java.io.IOException

VFileUrl

public VFileUrl(VFile vf,
                java.lang.String viewerID)
Construct a URL path from a VFile.

Parameters:
vf - The VFile to encode.
viewerID - The viewer ID, if relevant. If not, null.

VFileUrl

public VFileUrl(VDevice vd,
                java.lang.String viewerID,
                java.lang.String actionID,
                java.lang.String filepath)
Construct a URL for something other than a vfile, eg. a ControlHandler call.

Method Detail

getDeviceID

public java.lang.String getDeviceID()
Return the device ID. When a URL refers to a file on a device which isn't mounted, the device ID will still be defined.

Returns:
The device ID.

getViewerID

public java.lang.String getViewerID()
The "viewer ID" embedded in the URL. Viewer IDs are only defined when the URL is being used directly with the browser interface: it's used to do tracking. In other circumstances (eg. with XSPF result sets) it's the dummy value "_".

Returns:
The viewer ID.

getActionID

public java.lang.String getActionID()
The "action ID" embedded in the URL. This is only used when the URL is being handled directly by the browser bnterface. For normal files, the action ID is "q". The other defined value is "a" which retrieves frame furniture used for the on-screen buttons provided in the browser interface.

Returns:
The action ID

getFilepath

public java.lang.String getFilepath()
Returns:
The part of the URL path which actually maps to a file path on a VDevice (as opposed to the various prefixes for this and that). This should only be needed by the browser interface's ControlHandler - everything else will use the resolved VFile directly.

getDevice

public VDevice getDevice()
Returns:
The VDevice this URL refers to, if it's mounted; else null. The device ID will be set even if this is not.

getFile

public VFile getFile()
Returns:
The VFile this URL refers to, if it exists; else null. Always null if getDevice is null.

toUrlPath

public java.lang.String toUrlPath()
Returns:
The URL path component corresponding to the current VFile.