org.indy
Class IndyComponent

java.lang.Object
  |
  +--org.indy.BaseComponent
        |
        +--org.indy.IndyComponent
Direct Known Subclasses:
Connection, IdUDPBase, ServerIOHandler, SocksInfo, TCPClient, TCPServer

public abstract class IndyComponent
extends BaseComponent

IndyComponent is the ancestor of all Indy components which implement client or server functionality.

IndyComponent provides a convinient method to acess the local machine's host name with getLocalName(), and is also responsible for firing events to registered instances of IndyComponentListener to signal state change, input, and output operations in the component.

Version:
1.0
Author:
OTG
See Also:
IndyComponentListener

Inner Class Summary
static class IndyComponent.WorkMode
          An enumerated class representing the possible work types for siganalling work events in an IndyComponent.
 
Constructor Summary
IndyComponent()
           
 
Method Summary
 void addComponentListener(IndyComponentListener listener)
          Registers an IndyComponentListener to receive events from this component instance.
protected  void doBeginWork(IndyComponent.WorkMode workMode)
          Calls to signal the beginning of work of a given IndyComponent.WorkMode.
protected  void doBeginWork(IndyComponent.WorkMode workMode, int size)
          Called to indicate the beginning of work of the given IndyComponent.WorkMode.
protected  void doEndWork(IndyComponent.WorkMode workMode)
          Signals that a piece of work begun by doBeginWork has ended.
protected  void doStatus(Status status)
          Fires a status event with the given Status.
protected  void doStatus(Status status, java.lang.Object[] args)
          Fires a state change event for a given Status, taking an array of arguments for message formatting.
protected  void doWork(IndyComponent.WorkMode workMode, int count)
          Signals that a piece of work of the given IndyComponent.WorkMode is underway to the tune of count bytes.
static java.lang.String getLocalName()
          Returns the local host name of this machine.
 void removeComponentListener(IndyComponentListener listener)
          Unregisters an IndyComponentListener from this component.
 
Methods inherited from class org.indy.BaseComponent
getVersion
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IndyComponent

public IndyComponent()
Method Detail

getLocalName

public static final java.lang.String getLocalName()
                                           throws IndyUnknownHostException
Returns the local host name of this machine.

NOTE: This value is lazily created and then cached, so that, at present, changes to the host name will not update.

This method provides a shortcut for

     java.net.InetAddress.getLocalHost().getHostName();
  
Returns:
The host name of the local machine.
Throws:
IndyUnknownHostException - if, for some reason, the local host can not be resolved
SecurityExeption - if a security manager exists and checkConnect doesn't allow this operation.

doStatus

protected final void doStatus(Status status)
Fires a status event with the given Status. This is a shortcut for
     doStatus(status, new Object[0]);
  
Parameters:
status - The Status that represents the state being changed to.
See Also:
Status

doStatus

protected final void doStatus(Status status,
                              java.lang.Object[] args)
Fires a state change event for a given Status, taking an array of arguments for message formatting. The message formatting uses java.text.MessageFormat, and the appropriate resource string for the Status in question.
Parameters:
status - The Status being changed to.
args - Arguments to format the state change message with.

addComponentListener

public void addComponentListener(IndyComponentListener listener)
Registers an IndyComponentListener to receive events from this component instance.
Parameters:
listener - The IndyComponentListener to receive events from this component.
See Also:
IndyComponentListener

removeComponentListener

public void removeComponentListener(IndyComponentListener listener)
Unregisters an IndyComponentListener from this component.
Parameters:
listener - The IndyComponentListener to remove.
See Also:
IndyComponentListener

doBeginWork

protected void doBeginWork(IndyComponent.WorkMode workMode,
                           int size)
Called to indicate the beginning of work of the given IndyComponent.WorkMode. Calls can be nested, but each begin must have a corresponding end. Only the first beginWork in any nested set for a given WorkMode will fire a IndyComponentListener#onBeginWork(IndyComponent,WorkMode,int) event.
Parameters:
workMode - The WorkMode of this work.
size - The size of the work - viz. how many bytes are being read, written or processed.
See Also:
doBeginWork(WorkMode), doEndWork(WorkMode), doWork(WorkMode,int), IndyComponentListener, IndyComponentListener#onBeginWork(IndyComponent,WorkMode,int)

doBeginWork

protected final void doBeginWork(IndyComponent.WorkMode workMode)
Calls to signal the beginning of work of a given IndyComponent.WorkMode. See for more details. This method is a shortcut for
    doBeginWork(workMode,0);
  
Parameters:
workMode - The WorkMode describing the type of operation underway.
See Also:
doBeginWork(WorkMode,int), doEndWork(WorkMode), doWork(WorkMode,int), IndyComponentListener, IndyComponentListener#onBeginWork(IndyComponent,WorkMode,int)

doWork

protected final void doWork(IndyComponent.WorkMode workMode,
                            int count)
Signals that a piece of work of the given IndyComponent.WorkMode is underway to the tune of count bytes. This call will have no effect unless a corresponding call to begin work has been made; otherwise a onWork event will be fired to all interested parties.
Parameters:
workMode - The WorkMode that this work represents.
count - The number of bytes being processed.
See Also:
doBeginWork(WorkMode,int), doEndWork(WorkMode,int), IndyComponent.WorkMode, IndyComponentListener, IndyComponentListener.onWork(IndyComponent, IndyComponent.WorkMode, int)

doEndWork

protected final void doEndWork(IndyComponent.WorkMode workMode)
Signals that a piece of work begun by doBeginWork has ended. Each call to doBeginWork should have a corresponding call to doEndWork, and, as with doBeginWork only the innovation representing the outermost portion of work in a nested call will trigger an event, in this case IndyComponentListener#onEndWork(IndyComponent,WorkMode).
Parameters:
workMode - The WorkMode for which work is ending.
See Also:
doBeginWork(WorkMode,int), doBeginWork(WorkMode), doWork(WorkMode,int), IndyComponent.WorkMode, IndyComponentListener, IndyComponentListener#onEndWork(IndyComponent,WorkMode)


Copyright © 2002-2002 IndyJ. All Rights Reserved.