edu.wisc.trace.urcsdk.client
Class GenericClient

java.lang.Object
  extended by edu.wisc.trace.urcsdk.client.GenericClient
All Implemented Interfaces:
IClient

public class GenericClient
extends java.lang.Object
implements IClient

GenericClient is a Sample class that URCs may use in order to fully comply with the specification for URCs. Created on: Aug 31, 2004 Thread Safe: Yes Bugs: none filed.

Version:
$Revision: 1.21 $
Author:
Andrew Martin, Trace R&D Center Modified by Parikshit Thakur

Constructor Summary
GenericClient(java.net.URL codeBase)
          Creates a new GenericClient instance.
 
Method Summary
 void addListener(IClientListener listener)
          addListener sets the listener for the Client
 IClientTun bindToClientTun(java.lang.String tunClassName, java.util.Map<java.lang.String,java.lang.Object> parameterMap)
          Binds the Client a particular TUN, as mentioned in the arguments
 void closeSession(java.lang.String sessionId)
          closeSession closes session for the requested sessionId
 java.util.List<TargetMirror> getAvailableTargets()
          getAvailableTargets
 java.lang.String[] getElementIDs(java.lang.String sessionId)
          Returns an array of elementID's for the requested SessionID
 java.lang.String getElementRef(java.lang.String sessionId, java.lang.String elementId)
          getElementRef gets the ElementRef for the elementID
 java.lang.Object getElementState(java.lang.String sessionId, java.lang.String elementId)
          Get the latest value for an element
 java.lang.String getLabel(java.lang.String sessionId, java.lang.String elementId, java.lang.String stringURI)
          getLabel gets the Label for the particular elementID
 java.lang.String getLabelForCurrentValue(java.lang.String sessionId, java.lang.String elementId, java.lang.String stringURI)
          getLabelForCurrentValue gets the Label for the Current Value of the elementID
 java.lang.String getLabelForSocket(java.lang.String targetId, java.lang.String socketName)
          getLabelForSocket returns the label for the requested SocketName.
 java.lang.String getLabelForTarget(java.lang.String targetId)
          getLabelForTarget returns Label for requested TargetID.
 java.util.Locale getLocale()
          getLocale
 UserPreferences getPreferences()
          getPreferences retrieves the current preferences for resource retrieval, such as language, text/image, etc...
 java.lang.String getResource(java.lang.String sessionId, java.lang.String elementId, java.lang.String role)
          getResource indirect call to getResource
 java.lang.String getResource(java.lang.String targetId, java.lang.String elementRef, java.lang.String valueRef, java.lang.String opRef, java.lang.String role)
          getResource calls the getResource method of the ResourceManager
 java.lang.String getResourceForOperation(java.lang.String sessionId, java.lang.String elementId, java.lang.String role, java.lang.String opRef)
          getResourceForOperation indirect call to getResource
 java.lang.String getResourceForValue(java.lang.String sessionId, java.lang.String elementId, java.lang.String role, java.lang.String valRef)
          getResourceForValue indirect call to getResource
 ClientSession getSessionById(java.lang.String sessionId)
          Utility method
 java.lang.String[] getSocketIdsForTarget(java.lang.String targetId, java.lang.String filterSocketURI)
          Returns an array of SocketID's for requested TargetID.
 java.lang.String[] getSocketNamesForTarget(java.lang.String targetId, java.lang.String filterSocketURI)
          Returns an array of SocketID's for requested TargetID.
 java.lang.String getSocketUriForName(java.lang.String targetId, java.lang.String socketName)
          Returns an array of URI's for requested SocketName.
 java.lang.String[] getTargetIDs(java.lang.String filterTargetURI)
          getTargetIDs returns an array of TargetID's for available Targets.
 java.lang.String getTargetUriForId(java.lang.String targetId)
          getTargetUriForId returns the URI for requested TargetID.
 java.util.List<IClientTun> getTuns()
          Return a list of all TUNs registed with this Client.
 java.lang.Object getValue(java.lang.String sessionId, java.lang.String elementId)
          getValue returns the value of the particular elementID
 java.lang.Object[] getValues(java.lang.String sessionId)
          Returns an array of values for respective elementID's (as returned by getElementIDs) for the requested SessionID
 java.lang.String invokeCommandRequest(java.lang.String sessionId, java.lang.String elementId)
          invokeCommandRequest Called by the User Interface to modify value of a SocketElement.
 boolean isAvailable(java.lang.String sessionId, java.lang.String elementId)
          isAvailable
 boolean isReadable(java.lang.String sessionId, java.lang.String elementId)
          isReadable
 boolean isWritable(java.lang.String sessionId, java.lang.String elementId)
          isWritable
 java.lang.String openSessionRequest(java.lang.String targetId, java.lang.String socketName)
          Sends a request to the Target to open a Session
 void sessionAborted(ClientSession ses)
          sessionAborted called from the TunManager when a Session is aborted
 boolean setElementStateRequest(java.lang.String sessionId, java.lang.String elementId, java.lang.String value)
          Modify value of a SocketElement.
 void setLanguages(java.lang.String languages)
          setLanguages Sets the URC's currently available languages to the space-separated parameter languages.
 void setLocale(java.util.Locale locale)
          setLocale
 void setPreference(java.lang.String name, java.lang.String value)
          setPreference Sets a preference for the Client specified by name to a given value.
 void targetDiscarded(TargetMirror t)
          targetDiscarded is the overridable method for handling when a Target is discarded on a TUN registered with the URC.
 void targetDiscovered(TargetMirror t)
          targetDiscovered is the overridable method for handling when a Target is discovered on a TUN registered with the URC.
 void unbindClientTun(java.lang.String tunClassName)
          UnBind from a particular TUN
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenericClient

public GenericClient(java.net.URL codeBase)
Creates a new GenericClient instance. After creating an instance, bindToTun() must be called for connecting to the Network

Method Detail

addListener

public void addListener(IClientListener listener)
Description copied from interface: IClient
addListener sets the listener for the Client

Specified by:
addListener in interface IClient
Parameters:
listener - an IClientListener value

setLocale

public void setLocale(java.util.Locale locale)
Description copied from interface: IClient
setLocale

Specified by:
setLocale in interface IClient
Parameters:
locale - - Sets the locale that the Client should use when generating its UI.

setPreference

public void setPreference(java.lang.String name,
                          java.lang.String value)
Description copied from interface: IClient
setPreference Sets a preference for the Client specified by name to a given value. Examples of preferences are "Language":"en", "RenderType":"text", etc.

Specified by:
setPreference in interface IClient
Parameters:
name - a String value: the key for a preference's value.
value - a String value: the value for a preference's key.

setLanguages

public void setLanguages(java.lang.String languages)
Description copied from interface: IClient
setLanguages Sets the URC's currently available languages to the space-separated parameter languages.

Specified by:
setLanguages in interface IClient
Parameters:
languages - a space-separated String value such as "en de ja".

getAvailableTargets

public java.util.List<TargetMirror> getAvailableTargets()
Description copied from interface: IClient
getAvailableTargets

Specified by:
getAvailableTargets in interface IClient
Returns:
A List<TargetMirror> of the currently connected Targets.

getTuns

public java.util.List<IClientTun> getTuns()
Description copied from interface: IClient
Return a list of all TUNs registed with this Client.

Specified by:
getTuns in interface IClient
Returns:
a List<IClientTun>

targetDiscarded

public void targetDiscarded(TargetMirror t)
Description copied from interface: IClient
targetDiscarded is the overridable method for handling when a Target is discarded on a TUN registered with the URC. It is called whenever a Target is removed (either voluntarily or forcibly) from a TUN. Any Target-lost cleanup code should be implemented within this method.

Specified by:
targetDiscarded in interface IClient
Parameters:
t - a TargetMirror value

targetDiscovered

public void targetDiscovered(TargetMirror t)
Description copied from interface: IClient
targetDiscovered is the overridable method for handling when a Target is discovered on a TUN registered with the URC. It is called whenever a Target is added to a TUN. Any Target-found init code should go here.

Specified by:
targetDiscovered in interface IClient
Parameters:
t - a TargetMirror value

sessionAborted

public void sessionAborted(ClientSession ses)
Description copied from interface: IClient
sessionAborted called from the TunManager when a Session is aborted

Specified by:
sessionAborted in interface IClient
Parameters:
ses - a ClientSession value

getPreferences

public UserPreferences getPreferences()
Description copied from interface: IClient
getPreferences retrieves the current preferences for resource retrieval, such as language, text/image, etc...

Specified by:
getPreferences in interface IClient
Returns:
an UserPreferences value

getLocale

public java.util.Locale getLocale()
Description copied from interface: IClient
getLocale

Specified by:
getLocale in interface IClient
Returns:
Locale

setElementStateRequest

public boolean setElementStateRequest(java.lang.String sessionId,
                                      java.lang.String elementId,
                                      java.lang.String value)
                               throws UrcException
Modify value of a SocketElement. This is common method used for changing the value of a variable and acknowledging a Notification.

Specified by:
setElementStateRequest in interface IClient
Parameters:
sessionId -
elementId -
value -
Returns:
a boolean value
Throws:
UrcException

invokeCommandRequest

public java.lang.String invokeCommandRequest(java.lang.String sessionId,
                                             java.lang.String elementId)
                                      throws UrcException
Description copied from interface: IClient
invokeCommandRequest Called by the User Interface to modify value of a SocketElement. Method used for invoking a Command

Specified by:
invokeCommandRequest in interface IClient
Parameters:
sessionId - a String value
elementId - a String value
Returns:
a String value
Throws:
UrcException

getTargetUriForId

public java.lang.String getTargetUriForId(java.lang.String targetId)
Description copied from interface: IClient
getTargetUriForId returns the URI for requested TargetID.

Specified by:
getTargetUriForId in interface IClient
Parameters:
targetId - String
Returns:
a String value

getLabelForTarget

public java.lang.String getLabelForTarget(java.lang.String targetId)
Description copied from interface: IClient
getLabelForTarget returns Label for requested TargetID.

Specified by:
getLabelForTarget in interface IClient
Parameters:
targetId - String
Returns:
a String value

getSocketIdsForTarget

public java.lang.String[] getSocketIdsForTarget(java.lang.String targetId,
                                                java.lang.String filterSocketURI)
                                         throws UrcException
Description copied from interface: IClient
Returns an array of SocketID's for requested TargetID.

Specified by:
getSocketIdsForTarget in interface IClient
Parameters:
targetId - String
filterSocketURI - String is a filter for selection of SocketID's
Returns:
String[]
Throws:
UrcException

getSocketNamesForTarget

public java.lang.String[] getSocketNamesForTarget(java.lang.String targetId,
                                                  java.lang.String filterSocketURI)
                                           throws UrcException
Description copied from interface: IClient
Returns an array of SocketID's for requested TargetID.

Specified by:
getSocketNamesForTarget in interface IClient
Parameters:
targetId - String
filterSocketURI - String is a filter for selection of SocketID's
Returns:
String[]
Throws:
UrcException

getSocketUriForName

public java.lang.String getSocketUriForName(java.lang.String targetId,
                                            java.lang.String socketName)
                                     throws UrcException
Description copied from interface: IClient
Returns an array of URI's for requested SocketName.

Specified by:
getSocketUriForName in interface IClient
Parameters:
targetId - String
socketName - String
Returns:
String[]
Throws:
UrcException

getLabelForSocket

public java.lang.String getLabelForSocket(java.lang.String targetId,
                                          java.lang.String socketName)
                                   throws UrcException
Description copied from interface: IClient
getLabelForSocket returns the label for the requested SocketName.

Specified by:
getLabelForSocket in interface IClient
Parameters:
targetId - String
socketName - String
Returns:
String
Throws:
UrcException

getResource

public java.lang.String getResource(java.lang.String targetId,
                                    java.lang.String elementRef,
                                    java.lang.String valueRef,
                                    java.lang.String opRef,
                                    java.lang.String role)
Description copied from interface: IClient
getResource calls the getResource method of the ResourceManager

Specified by:
getResource in interface IClient
Parameters:
targetId - String
elementRef - String
valueRef - String
opRef - String
role - String
Returns:
String

getSessionById

public ClientSession getSessionById(java.lang.String sessionId)
Description copied from interface: IClient
Utility method

Specified by:
getSessionById in interface IClient
Parameters:
sessionId - a String value
Returns:
a ClientSession value

getElementIDs

public java.lang.String[] getElementIDs(java.lang.String sessionId)
Description copied from interface: IClient
Returns an array of elementID's for the requested SessionID

Specified by:
getElementIDs in interface IClient
Parameters:
sessionId - String
Returns:
String[]

getValues

public java.lang.Object[] getValues(java.lang.String sessionId)
Description copied from interface: IClient
Returns an array of values for respective elementID's (as returned by getElementIDs) for the requested SessionID

Specified by:
getValues in interface IClient
Parameters:
sessionId - String
Returns:
Object[]

getValue

public java.lang.Object getValue(java.lang.String sessionId,
                                 java.lang.String elementId)
Description copied from interface: IClient
getValue returns the value of the particular elementID

Specified by:
getValue in interface IClient
Parameters:
sessionId - String
elementId - String
Returns:
Object

getElementRef

public java.lang.String getElementRef(java.lang.String sessionId,
                                      java.lang.String elementId)
Description copied from interface: IClient
getElementRef gets the ElementRef for the elementID

Specified by:
getElementRef in interface IClient
Parameters:
sessionId - String
elementId - String
Returns:
String

getLabel

public java.lang.String getLabel(java.lang.String sessionId,
                                 java.lang.String elementId,
                                 java.lang.String stringURI)
Description copied from interface: IClient
getLabel gets the Label for the particular elementID

Specified by:
getLabel in interface IClient
Parameters:
sessionId - String
elementId - String
Returns:
String

getLabelForCurrentValue

public java.lang.String getLabelForCurrentValue(java.lang.String sessionId,
                                                java.lang.String elementId,
                                                java.lang.String stringURI)
Description copied from interface: IClient
getLabelForCurrentValue gets the Label for the Current Value of the elementID

Specified by:
getLabelForCurrentValue in interface IClient
Parameters:
sessionId - String
elementId - String
Returns:
String

getResource

public java.lang.String getResource(java.lang.String sessionId,
                                    java.lang.String elementId,
                                    java.lang.String role)
Description copied from interface: IClient
getResource indirect call to getResource

Specified by:
getResource in interface IClient
Parameters:
sessionId - String
elementId - String
role - String
Returns:
String

getResourceForValue

public java.lang.String getResourceForValue(java.lang.String sessionId,
                                            java.lang.String elementId,
                                            java.lang.String role,
                                            java.lang.String valRef)
Description copied from interface: IClient
getResourceForValue indirect call to getResource

Specified by:
getResourceForValue in interface IClient
Parameters:
sessionId - String
elementId - String
role - String
valRef - String
Returns:
String

getResourceForOperation

public java.lang.String getResourceForOperation(java.lang.String sessionId,
                                                java.lang.String elementId,
                                                java.lang.String role,
                                                java.lang.String opRef)
Description copied from interface: IClient
getResourceForOperation indirect call to getResource

Specified by:
getResourceForOperation in interface IClient
Parameters:
sessionId - String
elementId - String
role - String
opRef - String
Returns:
String

isWritable

public boolean isWritable(java.lang.String sessionId,
                          java.lang.String elementId)
Description copied from interface: IClient
isWritable

Specified by:
isWritable in interface IClient
Parameters:
sessionId - String
elementId - String
Returns:
boolean

isReadable

public boolean isReadable(java.lang.String sessionId,
                          java.lang.String elementId)
Description copied from interface: IClient
isReadable

Specified by:
isReadable in interface IClient
Parameters:
sessionId - String
elementId - String
Returns:
boolean

isAvailable

public boolean isAvailable(java.lang.String sessionId,
                           java.lang.String elementId)
Description copied from interface: IClient
isAvailable

Specified by:
isAvailable in interface IClient
Parameters:
sessionId - String
elementId - String
Returns:
boolean

getTargetIDs

public java.lang.String[] getTargetIDs(java.lang.String filterTargetURI)
Description copied from interface: IClient
getTargetIDs returns an array of TargetID's for available Targets.

Specified by:
getTargetIDs in interface IClient
Parameters:
filterTargetURI - String is a filter for selection of TargetID's
Returns:
String[]

closeSession

public void closeSession(java.lang.String sessionId)
                  throws UrcException
Description copied from interface: IClient
closeSession closes session for the requested sessionId

Specified by:
closeSession in interface IClient
Parameters:
sessionId - String
Throws:
UrcException

openSessionRequest

public java.lang.String openSessionRequest(java.lang.String targetId,
                                           java.lang.String socketName)
                                    throws UrcException
Description copied from interface: IClient
Sends a request to the Target to open a Session

Specified by:
openSessionRequest in interface IClient
Parameters:
targetId - String
socketName - String
Returns:
String sessionId
Throws:
UrcException

bindToClientTun

public IClientTun bindToClientTun(java.lang.String tunClassName,
                                  java.util.Map<java.lang.String,java.lang.Object> parameterMap)
                           throws UrcException
Binds the Client a particular TUN, as mentioned in the arguments

Parameters:
tunClassName - Fully qualified Tun Class Name
parameterMap -
Returns:
IClientTun reference
Throws:
UrcException

unbindClientTun

public void unbindClientTun(java.lang.String tunClassName)
                     throws UrcException
UnBind from a particular TUN

Parameters:
tunClassName - Fully qualified Tun Class Name
Throws:
UrcException

getElementState

public java.lang.Object getElementState(java.lang.String sessionId,
                                        java.lang.String elementId)
                                 throws UrcException
Get the latest value for an element

Parameters:
sessionId -
elementId -
Throws:
UrcException


Copyright © 2006 Trace R&D Center, University of Wisconsin-Madison. All Rights Reserved.