com.artima.place
Class URLFactory

java.lang.Object
  |
  +--com.artima.place.URLFactory
All Implemented Interfaces:
Presentable, java.io.Serializable

public final class URLFactory
extends java.lang.Object
implements java.io.Serializable, Presentable

Jini service that produces a URL or array of URLs. This service can be used to wrap existing file-based resources in a network mobile service object. An appropriate service UI can then be used to present the file to a user.

If this service produces an array of URLs, each URL must represent a different way to access the same resource. If a network partition, crashed server, or some other problem prevents the first URL from being successfully used, the second URL can be tried. If that one doesn't work, the third can be tried, and so on.

See Also:
Serialized Form

Constructor Summary
URLFactory(URLString url)
          Creates a URLFactory with passed String URL.
URLFactory(URLString[] urls)
          Construct a URLFactory with an array of URLStrings.
 
Method Summary
 int getLength()
          Returns the number of URLs contained in this URLFactory.
 ServicePresenter getServicePresenter()
          Gets the ServicePresenter for this Presentable service.
 URLString getURL()
          Returns the first URLString in the list of URLStrings contained in this URLFactory.
 URLString[] getURLs()
          Returns an array containing in order the URLStrings contained in this URLFactory.
 java.util.List getURLsAsList()
          Returns a List of the URLStrings.
 void setServicePresenter(ServicePresenter servicePresenter)
          Sets the ServicePresenter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

URLFactory

public URLFactory(URLString url)
Creates a URLFactory with passed String URL.
Parameters:
url - the URL to be contained in this URLFactory
Throws:
NullPointerException - if passed url reference is null

URLFactory

public URLFactory(URLString[] urls)
Construct a URLFactory with an array of URLStrings.
Parameters:
urls - the URLs to be contained in this URLFactory
Throws:
NullPointerException - if passed urls array is null
java.lang.IllegalArgumentException - if passed urls array is empty
Method Detail

getURL

public URLString getURL()
Returns the first URLString in the list of URLStrings contained in this URLFactory.
Returns:
the first URLString in the list.

getURLs

public URLString[] getURLs()
Returns an array containing in order the URLStrings contained in this URLFactory.
Returns:
the URLStrings, in order, contained in this URLFactory.

getURLsAsList

public java.util.List getURLsAsList()
Returns a List of the URLStrings. Returns a List containing in order the URLStrings contained in this URLFactory.
Returns:
the URLStrings, in order, contained in this URLFactory.

getLength

public int getLength()
Returns the number of URLs contained in this URLFactory.
Returns:
the number of URLs contained in this URLFactory.

getServicePresenter

public ServicePresenter getServicePresenter()
Gets the ServicePresenter for this Presentable service. This method will return the object passed to the setServicePresenter method in its most recent invocation. If the setServicePresenter method has not yet been invoked, this method will return the default ServicePresenter returned by the ServicePresenter.getDefault method.

This method could be called by a service or client UI for a Presentable service, when the UI detects that the user wishes to activate a link. The UI can delegate the actual activation activation of that link to the ServicePresenter returned by this method.

Specified by:
getServicePresenter in interface Presentable
Returns:
the ServicePresenter to which this service may wish to delegate link activations

setServicePresenter

public void setServicePresenter(ServicePresenter servicePresenter)
Sets the ServicePresenter. This method would usually be invoked by the client to pass in a the service presenter context object to the Presentable service, before attaching a service or client UI.
Specified by:
setServicePresenter in interface Presentable
Parameters:
presenter - the ServicePresenter to which this service may wish to delegate link activations