org.nukesoft.bot2.lineproc
Class DynamicLoadLPContext

java.lang.Object
  |
  +--org.nukesoft.bot2.lineproc.DynamicLoadLPContext
All Implemented Interfaces:
LineProcContext

public class DynamicLoadLPContext
extends Object
implements LineProcContext

The DynamicLoadLPContext provides an internal implementation of the LineProcContext interface. It handles loading of the external LineProc class, as well as context maintnance. For each conversational dialog, there exists exactly one DynamicLoadLPContext. The context will reload a different LineProc if asked to do so by the LineProc. This keeps LineProc manipulation out of the Dialog implementation.

Author:
Ryan Michela

Constructor Summary
DynamicLoadLPContext(String defaultLibBindID)
          Createst a DynamicLoadLPContext object and register a callback and an initial LineProc.
 
Method Summary
 void bindCallback(LineProcContextCallback callback)
          Binds a local callback.
 boolean bindConversation(String dialogID)
          Executes a conversation bind.
 Set getComPortBindIDs()
          Returns a set of comm port bind IDs.
 Set getConversations()
          Returns a list of active conversations.
 String getIdentity()
          Returns the dialog identity string.
 Set getLineProcBindIDs()
          Returns a set of line proc bind IDs.
 String getRemoteScreenName()
          Returns the foreign screen name attached to this context.
 String getWarningLevel()
          Returns the current warning level.
 void handleIM(IM message)
          Forewards an incomming IM to the LineProc.
 void handleWarn(String screenName)
          Forewards an incomming warning to the LineProc.
 void initiateConversation(String commPortBindID, String remoteScreenName, String salutation)
          Intitiates a conversation.
 void interject(String dialogID, String interjection)
          Interjects into another dialog.
 String lastLoadedLineProc()
          Returns the bind ID to the last loaded line processor.
 boolean loadNewLineProc(String lineProcBindID)
          Loads a new line processor.
 boolean loadNewLineProcOnPeer(String dialogID, String lineProcBindID)
          Tells a peer to load a new line processor.
 void sendIM(IM message)
          Sends an IM.
 void sendWarning(String screenName, boolean anonymous)
          Sends a warning.
 void shutdown()
          Shuts down the current loaded line processor.
 boolean unbindConversation(String dialogID)
          Executes a conversation unbind.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DynamicLoadLPContext

public DynamicLoadLPContext(String defaultLibBindID)
Createst a DynamicLoadLPContext object and register a callback and an initial LineProc.

Parameters:
defaultLibBindID - The initial line proc bind ID to load.
Method Detail

bindCallback

public void bindCallback(LineProcContextCallback callback)
Binds a local callback.

Parameters:
callback - The callback.

sendIM

public void sendIM(IM message)
Sends an IM.

Specified by:
sendIM in interface LineProcContext
Parameters:
message - The IM to send.
See Also:
LineProcContext.sendIM(org.nukesoft.bot2.core.IM)

sendWarning

public void sendWarning(String screenName,
                        boolean anonymous)
Sends a warning.

Specified by:
sendWarning in interface LineProcContext
Parameters:
screenName - The sceen name to warn.
anonymous - If true, send an anonymous warning.
See Also:
LineProcContext.sendWarning(java.lang.String, boolean)

handleIM

public void handleIM(IM message)
Forewards an incomming IM to the LineProc.

Parameters:
message - The message to foreward.

handleWarn

public void handleWarn(String screenName)
Forewards an incomming warning to the LineProc.

Parameters:
screenName - The screen name that did the warning.

loadNewLineProc

public boolean loadNewLineProc(String lineProcBindID)
Loads a new line processor.

Specified by:
loadNewLineProc in interface LineProcContext
Parameters:
lineProcBindID - Bind ID of the line processor to load.
Returns:
TRUE if success, FALSE if otherwise.
See Also:
LineProcContext.loadNewLineProc(java.lang.String)

loadNewLineProcOnPeer

public boolean loadNewLineProcOnPeer(String dialogID,
                                     String lineProcBindID)
Tells a peer to load a new line processor.

Specified by:
loadNewLineProcOnPeer in interface LineProcContext
Parameters:
dialogID - The peer to manipulate.
lineProcBindID - The line proc to load.
Returns:
TRUE if success, FALSE if otherwise.
See Also:
LineProcContext.loadNewLineProcOnPeer(java.lang.String, java.lang.String)

lastLoadedLineProc

public String lastLoadedLineProc()
Returns the bind ID to the last loaded line processor.

Specified by:
lastLoadedLineProc in interface LineProcContext
Returns:
Path.
See Also:
LineProcContext.lastLoadedLineProc()

getWarningLevel

public String getWarningLevel()
Returns the current warning level.

Specified by:
getWarningLevel in interface LineProcContext
Returns:
Integer string containing warning level if warning is supported on the supporting network. "N/A" if warning is not.
See Also:
LineProcContext.getWarningLevel()

getConversations

public Set getConversations()
Returns a list of active conversations.

Specified by:
getConversations in interface LineProcContext
Returns:
Set of Strings with fully qualified conversation names in the format CommPortBindName~ForeignScreenName.
See Also:
LineProcContext.getConversations()

bindConversation

public boolean bindConversation(String dialogID)
Executes a conversation bind.

Specified by:
bindConversation in interface LineProcContext
Parameters:
dialogID - The dialog to bind to.
See Also:
LineProcContext.bindConversation(java.lang.String)

unbindConversation

public boolean unbindConversation(String dialogID)
Executes a conversation unbind.

Specified by:
unbindConversation in interface LineProcContext
Parameters:
dialogID - The dialog to unbind from.
See Also:
LineProcContext.unbindConversation(java.lang.String)

getIdentity

public String getIdentity()
Returns the dialog identity string.

Specified by:
getIdentity in interface LineProcContext
Returns:
Identity string in the form CommPortBindName~ForeignScreenName.
See Also:
LineProcContext.getIdentity()

getRemoteScreenName

public String getRemoteScreenName()
Description copied from interface: LineProcContext
Returns the foreign screen name attached to this context. That is, the screen name of the person at the other end of the line.

Specified by:
getRemoteScreenName in interface LineProcContext
Returns:
The remote screen name.

shutdown

public void shutdown()
Shuts down the current loaded line processor.


getComPortBindIDs

public Set getComPortBindIDs()
Returns a set of comm port bind IDs.

Specified by:
getComPortBindIDs in interface LineProcContext
Returns:
A set of Strings.
See Also:
LineProcContext.getComPortBindIDs()

getLineProcBindIDs

public Set getLineProcBindIDs()
Returns a set of line proc bind IDs.

Specified by:
getLineProcBindIDs in interface LineProcContext
Returns:
A set of Strings.
See Also:
LineProcContext.getLineProcBindIDs()

initiateConversation

public void initiateConversation(String commPortBindID,
                                 String remoteScreenName,
                                 String salutation)
Intitiates a conversation.

Specified by:
initiateConversation in interface LineProcContext
Parameters:
commPortBindID - The commPort to use for the dialog.
remoteScreenName - The screen name to initiate a conversation with.
salutation - The salutation to send them.
See Also:
LineProcContext.initiateConversation(java.lang.String, java.lang.String, java.lang.String)

interject

public void interject(String dialogID,
                      String interjection)
Interjects into another dialog.

Specified by:
interject in interface LineProcContext
Parameters:
dialogID - The name of the dialog to interject into.
interjection - The text to interject with.
See Also:
LineProcContext.interject(java.lang.String, java.lang.String)