com.sshtools.profile
Class ResourceProfile

java.lang.Object
  extended bycom.sshtools.profile.ResourceProfile

public class ResourceProfile
extends java.lang.Object

A ResourceProfile stores everything that is needed to be known for a SchemeHandler to be able to make a connection to a resource.

The most important field in a ResourceProfile is the URI. The URI will provide the primary details to connect a resource using a specified scheme. The scheme will probably map to some network protocol that performs the actual connection and optionally authentication.

Long term persistance is provided for using XML.

When used in an application context, it may be useful to store application specific properties along with a profile. A profile provides this using its Application Properties. The simple name / value pairs are will also be persisted in the XML representation of the profile. Several convenience methods for getting primitive types as well as strings are available.

Profiles may also hold an implementor of SchemeOptions. This interface allows scheme specific options that are more suited to an object orientated presentation rather than the simple name value pairs of application properties. SchemeOptions implemenations are also expected to provide long term persistance using XML and they will be provided with an XMLelement when the profile is read from storage.

Version:
$Revision: 1.1 $
Author:
$Author: richard $

Constructor Summary
ResourceProfile()
          Construct a new empty profile.
ResourceProfile(java.lang.String name, URI uri)
          Construct a new profile given a URI and a name
ResourceProfile(URI uri)
          Construct a new profile given a URI
 
Method Summary
 void addApplicationExtension(java.lang.String name)
          Add an application extension to the profile.
 void addResourceProfileListener(ResourceProfileListener l)
          Add a listener to the list that should be notified when something in the profile changes, or if the profile is loaded / saved.
 ProfileTransport createProfileTransport()
          Return a connected and authenticated ProfileTransport appropriate for this profile
 void fireProfileChanged()
           
 nanoxml.XMLElement getApplicationExtension(java.lang.String name)
          Get an application extension to the profile.
 java.lang.String getApplicationProperty(java.lang.String name, java.lang.String defaultValue)
          Return one of the properties as a String given its property name and a default value if the property does not exist is or invalid.
 boolean getApplicationPropertyBoolean(java.lang.String name, boolean defaultValue)
          Return one of the properties as an boolean given its property name and a default value if the property does not exist is or invalid.
 int getApplicationPropertyInt(java.lang.String name, int defaultValue)
          Return one of the properties as an int given its property name and a default value if the property does not exist is or invalid.
 java.util.Enumeration getApplicationPropertyKeys()
          Get an Enumeration of all the property keys
 java.lang.String getName()
          Get the name for this profile
 SchemeOptions getSchemeOptions()
          Get the SchemeOptions
 URI getURI()
          Get the URI for this resource
 boolean hasApplicationExtension(java.lang.String name)
          Determine whether an application extension XML element is available within the profile.
 boolean isNeedSave()
          Get whether anything has changed since the profile was last loaded or saved.
 void load(java.io.InputStream in)
          Load the profile given an input stream providing the XML data.
 void removeApplicationProperty(java.lang.String key)
          Remove a property givens its name.
 void removeResourceProfileListener(ResourceProfileListener l)
          Remove a listener from the list that should be notified when something in the profile changes, or if the profile is loaded / saved.
 void save(java.io.OutputStream in)
          Save the profile given an output stream to write the XML data to.
 void setApplicationProperty(java.lang.String name, boolean value)
          Set a property given its name and a value
 void setApplicationProperty(java.lang.String name, int value)
          Set a property given its name and a value
 void setApplicationProperty(java.lang.String name, java.lang.String value)
          Set a property given its name and a value
 void setName(java.lang.String name)
          Set the name for this profile
 void setNeedSave(boolean needSave)
          Set whether anything has changed since the profile was last loaded or saved.
 void setSchemeOptions(SchemeOptions options)
          Set scheme specific options for this profile.
 void setURI(URI uri)
          Set the URI for this resource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceProfile

public ResourceProfile()
Construct a new empty profile.


ResourceProfile

public ResourceProfile(URI uri)
Construct a new profile given a URI

Parameters:
uri - uri

ResourceProfile

public ResourceProfile(java.lang.String name,
                       URI uri)
Construct a new profile given a URI and a name

Parameters:
name - name
uri - uri
Method Detail

addResourceProfileListener

public void addResourceProfileListener(ResourceProfileListener l)
Add a listener to the list that should be notified when something in the profile changes, or if the profile is loaded / saved.

Parameters:
l - listener to add

removeResourceProfileListener

public void removeResourceProfileListener(ResourceProfileListener l)
Remove a listener from the list that should be notified when something in the profile changes, or if the profile is loaded / saved.

Parameters:
l - listener to remove

createProfileTransport

public ProfileTransport createProfileTransport()
                                        throws ProfileException,
                                               java.io.IOException,
                                               AuthenticationException
Return a connected and authenticated ProfileTransport appropriate for this profile

Returns:
ProfileTransport
Throws:
ProfileException - if there is any problem with the profile
java.io.IOException - if the transport cannot connect
AuthenticationException - if the transport cannot authenticate

getSchemeOptions

public SchemeOptions getSchemeOptions()
Get the SchemeOptions

Returns:
scheme options

setSchemeOptions

public void setSchemeOptions(SchemeOptions options)
Set scheme specific options for this profile.

Parameters:
options - scheme specific options to add

setName

public void setName(java.lang.String name)
Set the name for this profile

Parameters:
name - name

getName

public java.lang.String getName()
Get the name for this profile

Returns:
name

setURI

public void setURI(URI uri)
Set the URI for this resource

Parameters:
uri - resource URI

getURI

public URI getURI()
Get the URI for this resource

Returns:
resource URI

load

public void load(java.io.InputStream in)
          throws java.io.IOException
Load the profile given an input stream providing the XML data.

Parameters:
in - instream providing XML data for profile
Throws:
java.io.IOException - if profile cannot be loaded

save

public void save(java.io.OutputStream in)
          throws java.io.IOException
Save the profile given an output stream to write the XML data to.

Throws:
java.io.IOException - if profile cannot be written

getApplicationPropertyInt

public int getApplicationPropertyInt(java.lang.String name,
                                     int defaultValue)
Return one of the properties as an int given its property name and a default value if the property does not exist is or invalid.

Parameters:
name - property name
defaultValue - default value
Returns:
value

getApplicationPropertyBoolean

public boolean getApplicationPropertyBoolean(java.lang.String name,
                                             boolean defaultValue)
Return one of the properties as an boolean given its property name and a default value if the property does not exist is or invalid.

Parameters:
name - property name
defaultValue - default value
Returns:
value

getApplicationProperty

public java.lang.String getApplicationProperty(java.lang.String name,
                                               java.lang.String defaultValue)
Return one of the properties as a String given its property name and a default value if the property does not exist is or invalid.

Parameters:
name - property name
defaultValue - default value
Returns:
value

setApplicationProperty

public void setApplicationProperty(java.lang.String name,
                                   java.lang.String value)
Set a property given its name and a value

Parameters:
name - property name
value - value

setApplicationProperty

public void setApplicationProperty(java.lang.String name,
                                   int value)
Set a property given its name and a value

Parameters:
name - property name
value - value

setApplicationProperty

public void setApplicationProperty(java.lang.String name,
                                   boolean value)
Set a property given its name and a value

Parameters:
name - property name
value - value

getApplicationPropertyKeys

public java.util.Enumeration getApplicationPropertyKeys()
Get an Enumeration of all the property keys

Returns:
Enumeration of property keys

removeApplicationProperty

public void removeApplicationProperty(java.lang.String key)
Remove a property givens its name.

Parameters:
key - name

hasApplicationExtension

public boolean hasApplicationExtension(java.lang.String name)
Determine whether an application extension XML element is available within the profile.

Parameters:
name -
Returns:

getApplicationExtension

public nanoxml.XMLElement getApplicationExtension(java.lang.String name)
Get an application extension to the profile.

Parameters:
name -
Returns:

addApplicationExtension

public void addApplicationExtension(java.lang.String name)
Add an application extension to the profile.

Parameters:
name -

isNeedSave

public boolean isNeedSave()
Get whether anything has changed since the profile was last loaded or saved.

Returns:
Returns true if the profile needs saving.

setNeedSave

public void setNeedSave(boolean needSave)
Set whether anything has changed since the profile was last loaded or saved.

Parameters:
needSave - true if the profile needs saving.

fireProfileChanged

public void fireProfileChanged()


Copyright © 2003-2004 3SP LTD. All Rights Reserved.