Overview | Package | Class | Use | Tree | Serialized | Deprecated | Index | Help
| ABLE 2.3.0 07/13/2005 14:21:00
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.ibm.able.examples.ablebean
Class AbleFileWatcher

    java.lang.Object
      com.ibm.able.AbleObject
          com.ibm.able.examples.ablebean.AbleFileWatcher

All Implemented Interfaces:
  AbleBean, AbleDataBufferManager, AbleEventListener, AbleEventListenerManager, AbleEventQueueManager, AbleEventQueueProcessor, AblePropertyChangeManager, AbleSerializable, java.io.Serializable

public class AbleFileWatcher
extends AbleObject

This class is an example of a simple AbleBean created by extending AbleObject. It monitors specific files for any changes and also answers queries regarding file attributes.

See Also:
  Serialized Form

Field Summary
`static int` | `ACTION_ALERT` Display a dialog when any condition is true.
`static int` | `ACTION_EVENT` Send an event to a registered agent or bean when any condition is true.
`static int` | `ACTION_EXECUTE` Start a process when any condition is true.
`static int` | `ACTION_NONE` Take no action regardless of file condition.
`static int` | `FILE_DELETED` This condition indicates the file is to be watched for deletion.
`static int` | `FILE_MODIFIED` This condition indicates the file is to be watched for changes.
`static int` | `FILE_THRESHOLD` This condition indicates the file is to be watched for a size threshold.
`protected static long` | `serialVersionUID` Serialized version identifier in form YYYYMMDDVerRelModxx

Fields inherited from class com.ibm.able.AbleObject
`changed, chgSupport, comment, dataFlowEnabled, defaultName, destBufferConnections, eventQueue, fileName, inputBuffer, listeners, logger, name, outputBuffer, parent, properties, propertyConnectionMgr, sourceBufferConnections, state, stateChgSupport, trace`

Constructor Summary
`AbleFileWatcher()` Construct an AbleFileWatcher with a name of FileWatcher.
`AbleFileWatcher(java.lang.String theBeanName)` Construct an AbleFileWatcher with the provided bean name.
`AbleFileWatcher(java.lang.String theBeanName, java.lang.String theFileName)` Construct an AbleFileWatcher with the provided bean name and on the specified file.

Method Summary
`boolean` | `changed()` Check to see if the file being watched changed.
`boolean` | `checkCondition()` Check to see if the condition monitored is true.
`boolean` | `exists()` Check to see if the file being watched actually exists.
`int` | `getAction()` Set the type of action to take when the condition watched is true.
`java.lang.String` | `getCommand()` Get the command executed when the condition is true and the action selected is ACTION_EXECUTE.
`int` | `getCondition()` Get the file change condition.
`java.awt.Dialog` | `getDialog()` Get the Dialog to display when the condition is true and the action selected is ACTION_ALERT.
`java.lang.String` | `getDisplayString()` Return a string for display in a list box.
`long` | `getFileSize()`
`long` | `getThreshold()` Get the file size threshold.
`java.lang.String` | `getWatchFileName()` Set the file name and get a reference to the file.
`boolean` | `isDirectory()` Check to see if the file being watched is a directory.
`long` | `lastModified()` Return the timestamp of the last file modification.
`long` | `length()` Return the length of the file watched.
`void` | `process()` Check the file being watched for the condition of interest.
`void` | `processTimerEvent()` The timer has expired, so check the file being watched for the condition of interest.
`void` | `reset()` Reset the bean to a known initialized state.
`void` | `setAction(int theAction)` Set the type of action to take when the condition watched is true.
`void` | `setCommand(java.lang.String theCommand)` Set the command to execute when the condition is true and the action selected is ACTION_EXECUTE.
`void` | `setCondition(int theCondition)` Set the file watch condition.
`void` | `setDialog(java.awt.Dialog theDialog)` Set the Dialog to display when the condition is true and the action selected is ACTION_ALERT.
`void` | `setThreshold(long theThreshold)` Set the file size threshold condition.
`void` | `setWatchFileName(java.lang.String theName)` Set the file name and get a reference to the file.

Methods inherited from class com.ibm.able.AbleObject
`addAbleEventListener, addDestBufferConnection, addPropertyChangeListener, addPropertyConnection, addSourceBufferConnection, addStateChangeListener, dataChanged, firePropertyChange, flushAbleEventQueue, getAbleEventListeners, getAbleEventProcessingEnabled, getAbleEventQueueSize, getComment, getDestBufferConnections, getFileName, getInputBuffer, getInputBuffer, getInputBufferAsString, getInputBufferAsStringArray, getInputBufferContents, getLogger, getName, getOutputBuffer, getOutputBuffer, getOutputBufferAsString, getOutputBufferAsStringArray, getOutputBufferContents, getParent, getProperties, getProperty, getPropertyChangeListeners, getPropertyConnectionManager, getSleepTime, getSourceBufferConnections, getState, getTraceLogger, handleAbleEvent, hasInputBuffer, hasOutputBuffer, init, init, isAbleEventPostingEnabled, isAbleEventProcessingEnabled, isChanged, isConnectable, isDataFlowEnabled, isTimerEventProcessingEnabled, notifyAbleEventListeners, process, processAbleEvent, processBufferConnections, processNoEventProcessingEnabledSituation, quitAll, quitEnabledEventProcessing, removeAbleEventListener, removeAllAbleEventListeners, removeAllBufferConnections, removeAllConnections, removeAllPropertyConnections, removeDestBufferConnection, removeProperty, removePropertyChangeListener, removePropertyConnection, removeSourceBufferConnection, removeStateChangeListener, restartEnabledEventProcessing, restoreFromFile, restoreFromFile, restoreFromSerializedFile, restoreFromStream, resumeAll, resumeEnabledEventProcessing, saveToFile, saveToFile, setAbleEventProcessingEnabled, setChanged, setComment, setDataFlowEnabled, setFileName, setInputBuffer, setInputBuffer, setLogger, setName, setOutputBuffer, setOutputBuffer, setParent, setProperties, setProperty, setSleepTime, setState, setTimerEventProcessingEnabled, setTraceLogger, sourceConnectionsOK, startEnabledEventProcessing, suspendAll, suspendEnabledEventProcessing`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### serialVersionUID

    protected static final long serialVersionUID

  Serialized version identifier in form YYYYMMDDVerRelModxx

  See Also:
    Constant Field Values

### FILE_MODIFIED

    public static final int FILE_MODIFIED

  This condition indicates the file is to be watched for changes.

  See Also:
    Constant Field Values

### FILE_DELETED

    public static final int FILE_DELETED

  This condition indicates the file is to be watched for deletion.

  See Also:
    Constant Field Values

### FILE_THRESHOLD

    public static final int FILE_THRESHOLD

  This condition indicates the file is to be watched for a size threshold.

  See Also:
    Constant Field Values

### ACTION_NONE

    public static final int ACTION_NONE

  Take no action regardless of file condition.

  See Also:
    Constant Field Values

### ACTION_ALERT

    public static final int ACTION_ALERT

  Display a dialog when any condition is true.

  See Also:
    Constant Field Values

### ACTION_EXECUTE

    public static final int ACTION_EXECUTE

  Start a process when any condition is true.

  See Also:
    Constant Field Values

### ACTION_EVENT

    public static final int ACTION_EVENT

  Send an event to a registered agent or bean when any condition is true.

  See Also:
    Constant Field Values

Constructor Detail

### AbleFileWatcher

    public AbleFileWatcher()
                    throws AbleException

  Construct an AbleFileWatcher with a name of FileWatcher.

### AbleFileWatcher

    public AbleFileWatcher(java.lang.String theBeanName)
                    throws AbleException

  Construct an AbleFileWatcher with the provided bean name.

Parameters:
  `theBeanName` - A String containing the name of the object.

### AbleFileWatcher

    public AbleFileWatcher(java.lang.String theBeanName,
                           java.lang.String theFileName)
                    throws AbleException

  Construct an AbleFileWatcher with the provided bean name and on the specified file.

Parameters:
  `theBeanName` - A String containing the name of the object.
  `theFileName` - A String containing the name of the file to watch.

Method Detail

### setAction

    public void setAction(int theAction)
                   throws AbleException

  Set the type of action to take when the condition watched is true.

  Parameters:
    `theAction` - An integer representing the action to take.
  Throws:
    `AbleException`
  See Also:
    `getAction()`

### getAction

    public int getAction()

  Set the type of action to take when the condition watched is true.

  Returns:
    An integer representing the file condition.
  See Also:
    `ACTION_NONE`, `ACTION_ALERT`, `ACTION_EXECUTE`, `ACTION_EVENT`

### setCommand

    public void setCommand(java.lang.String theCommand)
                    throws AbleException

  Set the command to execute when the condition is true and the action selected is ACTION_EXECUTE.

  Parameters:
    `theCommand` - A String containing the command to execute.
  Throws:
    `AbleException`

### getCommand

    public java.lang.String getCommand()

  Get the command executed when the condition is true and the action selected is ACTION_EXECUTE.

  Returns:
    A String containing the command to execute.

### setCondition

    public void setCondition(int theCondition)
                      throws AbleException

  Set the file watch condition. Generally this value is expected to be calculated.

  Parameters:
    `theCondition` - An int representing the watch condition.
  Throws:
    `AbleException`
  See Also:
    `getCondition()`

### getCondition

    public int getCondition()

  Get the file change condition.

  Returns:
    An integer representing the file condition.
  See Also:
    `FILE_DELETED`, `FILE_MODIFIED`, `FILE_THRESHOLD`

### setDialog

    public void setDialog(java.awt.Dialog theDialog)
                   throws AbleException

  Set the Dialog to display when the condition is true and the action selected is ACTION_ALERT.

  Parameters:
    `theDialog` - A Dialog to display.
  Throws:
    `AbleException`

### getDialog

    public java.awt.Dialog getDialog()

  Get the Dialog to display when the condition is true and the action selected is ACTION_ALERT.

  Returns:
    A Dialog to display.

### setWatchFileName

    public void setWatchFileName(java.lang.String theName)
                          throws AbleException

  Set the file name and get a reference to the file.

  Parameters:
    `theName` - A String containing the path and name of the file to watch.
  Throws:
    `AbleException`

### getWatchFileName

    public java.lang.String getWatchFileName()

  Set the file name and get a reference to the file.

### getFileSize

    public long getFileSize()

### setThreshold

    public void setThreshold(long theThreshold)
                      throws AbleException

  Set the file size threshold condition. The watch condition is true if the file size exceeds this value.

  Parameters:
    `theThreshold` - A long containing the file size threshold.
  Throws:
    `AbleException`

### getThreshold

    public long getThreshold()

  Get the file size threshold.

  Returns:
    A long representing the file size threshold.

### reset

    public void reset()
               throws AbleException

  Reset the bean to a known initialized state.

  Specified by:
    `reset` in interface `AbleBean`
  Overrides:
    `reset` in class `AbleObject`
  Throws:
    `AbleException` - If an error occurs.
  See Also:
    `AbleBean.reset()`

### process

    public void process()
                 throws AbleException

  Check the file being watched for the condition of interest. If the condition occurred, perform the action specified.

  Specified by:
    `process` in interface `AbleBean`
  Overrides:
    `process` in class `AbleObject`
  Throws:
    `An` - exception is thrown if an action fails.
    `AbleException`
  See Also:
    `AbleObject.inputBuffer`, `AbleObject.outputBuffer`, `AbleBean.process()`

### processTimerEvent

    public void processTimerEvent()
                           throws AbleException

  The timer has expired, so check the file being watched for the condition of interest. If the condition occurred, perform the action specified.

  Specified by:
    `processTimerEvent` in interface `AbleEventQueueProcessor`
  Overrides:
    `processTimerEvent` in class `AbleObject`
  Throws:
    `An` - exception is thrown if an action fails.
    `AbleException` - If an error occurs.

### checkCondition

    public boolean checkCondition()

  Check to see if the condition monitored is true.

  Returns:
    boolean A boolean value which indicates whether the desired condition is true.

### getDisplayString

    public java.lang.String getDisplayString()

  Return a string for display in a list box. This displays the object name and state information.

  Returns:
    String containing the object name, file being watched, and condition.

### changed

    public boolean changed()

  Check to see if the file being watched changed.

  Returns:
    boolean A boolean indicating whether the file changed since the last call.

### exists

    public boolean exists()

  Check to see if the file being watched actually exists.

  Returns:
    boolean A boolean indicating whether the file exits.

### isDirectory

    public boolean isDirectory()

  Check to see if the file being watched is a directory.

  Returns:
    boolean A boolean indicating whether the file watched is a directory.

### lastModified

    public long lastModified()

  Return the timestamp of the last file modification.

  Returns:
    long A long containing the timestamp of the last file modification.

### length

    public long length()

  Return the length of the file watched.

  Returns:
    long A long containing the number of bytes in the file watched.

Overview | Package | Class | Use | Tree | Serialized | Deprecated | Index | Help
| ABLE 2.3.0 07/13/2005 14:21:00
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

(C) Copyright IBM Corporation 1999, 2005