All Packages Class Hierarchy This Package Previous Next Index
Class com.ibm.tspaces.URLCopy
java.lang.Object
|
+----com.ibm.tspaces.URLCopy
- public class URLCopy
- extends Object
- implements Serializable
URLCopy implements support for copying data (from a file or website)
to and from a TupleSpace. This will allow the
data pointed to by the URL to be passed from client to client
thru a TSpaces server.
A typical use would be for a client to construct a URL that
points to a local file. The client would then construct a URLCopy
object and write this to TSpaces in a tuple.
URL url = new URL("file:/c:/file.txt");
URLCopy copy = new URLCopy(url);
ts.write("File",copy);
When passed to the TSpaces server, the actual contents of
the file addressed by the URL will be bundled up and sent to
the server where it will be stored in an appropriate database.
If another TSpaces client then reads or takes the Tuple, the
resulting URLCopy object can be used to access and store the data
on the local client using the "copyToLocal(Directory)" method
To obtain and access a copy of the URL data on the local client
Tuple tup = ts.read(...);
URLCopy copy = (URLCopy)tup.getField(2).getValue();
copy.copyToLocal("c:/temp"); // where to put it
URL url = copy.getURL();
// At this point the URL would be "file:/c:/temp/file.txt"
By default, the copyToLocal method then removes the data from the
object. This can be overriden with optional parameter on
copyToLocal(String fileFolder, boolean KeepData)
- Author:
- John Thomas
- See Also:
- TupleSpace, URL, Serializable
-
URLCopy()
-
-
URLCopy(String)
- URLCopy Constructor
This constructor takes a filename and builds a URL used to call the
real constructor.
-
URLCopy(URL)
- URLCopy Constructor
This constructor can only be used on a TSpaces client to
create the original URLCopy object.
-
copyToLocal(String)
- copyToLocal will copy the URL data from the Server to a local file
-
copyToLocal(String, boolean)
- copyToLocal will copy the URL data from the Server to a local file
-
equals(Object)
- Provide a proper equals(Object other) method for URLCopy.
-
getFileName()
- getSFileName will return the original file name based on the original URL.
-
getOriginalURL()
- getOriginalURL will return the URL used to create the object.
-
getServerURL()
- getServerURL will return the URL pointing to the data on the Server.
-
getURL()
- getURL will return a URL that points to a valid copy of the URL data.
-
isCopyOK()
- isCopyOK will return true if the File was sucessfull written to the
T Spaces Server.
-
main(String[])
- Test the URLCopy Object.
-
setRetention(long)
- setRetetion will set the time to keep the file on the server
before making it elgible for deletion by a cleanup process.
-
toString()
- Debug helper that displays the current object status
URLCopy
public URLCopy(String filepath) throws MalformedURLException
- URLCopy Constructor
This constructor takes a filename and builds a URL used to call the
real constructor.
This constructor can only be used on a TSpaces client to
create the original URLCopy object.
We need to do more checking of the filename!!!!!!
URLCopy
public URLCopy(URL url) throws MalformedURLException
- URLCopy Constructor
This constructor can only be used on a TSpaces client to
create the original URLCopy object.
We need to do more checking of the filename!!!!!!
URLCopy
public URLCopy()
getURL
public URL getURL()
- getURL will return a URL that points to a valid copy of the URL data.
- Returns:
- s It may return:
- Original URL if it has not yet been copied to another file.
- URL -> Local copy if client has copied it to a local file.
getOriginalURL
public URL getOriginalURL()
- getOriginalURL will return the URL used to create the object.
- Returns:
- s URL used to create the object
isCopyOK
public boolean isCopyOK()
- isCopyOK will return true if the File was sucessfull written to the
T Spaces Server. It will return false if not. The most common
cause for it not to be written would be that the Server is not running
the TSFileStore component.
- Returns:
- s true if File was written to the server
getServerURL
public URL getServerURL()
- getServerURL will return the URL pointing to the data on the Server.
- Returns:
- s URL at the TupleSpace server
getFileName
public String getFileName()
- getSFileName will return the original file name based on the original URL.
- Returns:
- s file name
setRetention
public void setRetention(long retentionPeriod)
- setRetetion will set the time to keep the file on the server
before making it elgible for deletion by a cleanup process.
- Parameters:
- Retention - time in milliseconds
copyToLocal
public void copyToLocal(String folder)
- copyToLocal will copy the URL data from the Server to a local file
- Parameters:
- folder - specifies the folder where the data is to be placed.
copyToLocal
public void copyToLocal(String folder,
boolean keep)
- copyToLocal will copy the URL data from the Server to a local file
- Parameters:
- folder - specifies the folder where the data is to be placed.
- keep - specifies if the file should be kept on the server.
equals
public boolean equals(Object other)
- Provide a proper equals(Object other) method for URLCopy.
This will return true if all of the following conditions are true:
- (Object other) is an instance of URLCopy
- The original URLs match i.e. _OriginalURL.equals(other.getOriginalURL()
- Parameters:
- Object - other is the URLCopy object to compare this to
- Returns:
- s true if they are equal
- Overrides:
- equals in class Object
toString
public String toString()
- Debug helper that displays the current object status
- Overrides:
- toString in class Object
main
public static void main(String argv[])
- Test the URLCopy Object.
All Packages Class Hierarchy This Package Previous Next Index