pamanager
Class FileAgent

java.lang.Object
  |
  +--ciagent.CIAgent
        |
        +--pamanager.FileAgent

public class FileAgent
extends CIAgent

The FileAgent class implements an agent that monitors a file to see if it was modified, deleted, or if its size exceeds a certain threshold.

See Also:
Serialized Form

Field Summary
protected  int action
           
protected  javax.swing.JDialog actionDialog
           
protected  java.lang.String actionString
           
static int ALERT
           
protected  int condition
           
static int DELETED
           
static int EVENT
           
static int EXECUTE
           
protected  java.io.File file
           
protected  java.lang.String fileName
           
protected  long lastChanged
           
static int MODIFIED
           
protected  java.lang.String parms
           
protected  int threshold
           
static int THRESHOLD
           
 
Fields inherited from class ciagent.CIAgent
agentPlatform, children, DEFAULT_ASYNCTIME, DEFAULT_SLEEPTIME, name, parent, traceLevel
 
Constructor Summary
FileAgent()
          Creates the agent.
FileAgent(java.lang.String name)
          Creates the agent with the specified name.
 
Method Summary
protected  boolean changed()
          Checks to see if the file has changed.
 int executeCmd(java.lang.String cmd)
          Executes the command string that was set up as a parameter for the EXECUTE action.
protected  boolean exists()
          Checks to see if the file exists.
 int getAction()
          Retrieves action this agent performs.
 java.lang.String getActionString()
          Retrieves the actionString this agent sends in events.
 int getCondition()
          Retrieves the condition being monitored.
 java.lang.String getFileName()
          Retrieves the name of the file being watched.
 java.lang.String getParms()
          Retrieve the parameters used by the agent when performing an action.
 java.lang.String getTaskDescription()
          Retrieves a description of the task this agent is performing.
 int getThreshold()
          Retrieves the threshold value.
 void initialize()
          Initializes the agent.
protected  long lastModified()
          Retrieves the time the file was last modified.
protected  long length()
          Retrieves the size of the file in bytes.
(package private)  void performAction()
          Peforms the ALERT, EXECUTE, or EVENT action.
 void process()
          Performs the default processing for this agent by checking the condition and performing the action is the condition is met.
 void processCIAgentEvent(CIAgentEvent e)
          Does nothing when an event is received.
 void processTimerPop()
          Performs the default processing for this agent when a timer pop occurs.
 void setAction(int action)
          Sets the action to be performed by this agent to ALERT, EXECUTE, or EVENT.
 void setActionString(java.lang.String actionString)
          Sets the action string to be sent by this agent in an EVENT.
 void setCondition(int cond)
          Sets the condition to be monitored to MODIFIED, DELETED, or THRESHOLD.
 void setDialog(javax.swing.JDialog dlg)
          Sets the dialog used by the agent when performing the ALERT or EXECUTE actions.
 void setFileName(java.lang.String fileName)
          Sets the name of the file to be watched.
 void setParms(java.lang.String params)
          Sets the parameters used when this agent performs an ALERT or EXECUTE action.
 void setThreshold(int thresh)
          Sets the threshold value.
 
Methods inherited from class ciagent.CIAgent
addAgent, addCIAgentEventListener, addPropertyChangeListener, getAgent, getAgentPlatform, getAgents, getAsyncTime, getChildren, getCustomizerClass, getDisplayName, getName, getParent, getSleepTime, getState, getTraceLevel, notifyCIAgentEventListeners, postCIAgentEvent, processAsynchronousEvents, removeAgent, removeCIAgentEventListener, removePropertyChangeListener, reset, resumeAgentProcessing, setAgentPlatform, setAsyncTime, setName, setParent, setSleepTime, setState, setTraceLevel, startAgentProcessing, stopAgentProcessing, suspendAgentProcessing, trace
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MODIFIED

public static final int MODIFIED

DELETED

public static final int DELETED

THRESHOLD

public static final int THRESHOLD

ALERT

public static final int ALERT

EXECUTE

public static final int EXECUTE

EVENT

public static final int EVENT

condition

protected int condition

action

protected int action

fileName

protected java.lang.String fileName

file

protected java.io.File file

lastChanged

protected long lastChanged

threshold

protected int threshold

actionDialog

protected javax.swing.JDialog actionDialog

actionString

protected java.lang.String actionString

parms

protected java.lang.String parms
Constructor Detail

FileAgent

public FileAgent()
Creates the agent.

FileAgent

public FileAgent(java.lang.String name)
Creates the agent with the specified name.
Parameters:
name - the String that contains the name of the agent
Method Detail

getTaskDescription

public java.lang.String getTaskDescription()
Retrieves a description of the task this agent is performing.
Returns:
the display string
Overrides:
getTaskDescription in class CIAgent

setFileName

public void setFileName(java.lang.String fileName)
Sets the name of the file to be watched.
Parameters:
fileName - the String that contains the name of the file

getFileName

public java.lang.String getFileName()
Retrieves the name of the file being watched.
Returns:
the name of the file

setCondition

public void setCondition(int cond)
Sets the condition to be monitored to MODIFIED, DELETED, or THRESHOLD.
Parameters:
cond - the integer that represents the condition being checked

getCondition

public int getCondition()
Retrieves the condition being monitored.
Returns:
the integer that represents the condition being monitored (0=MODIFIED, 1=DELETED, 2=THRESHOLD)

setThreshold

public void setThreshold(int thresh)
Sets the threshold value.
Parameters:
thresh - the threshold value

getThreshold

public int getThreshold()
Retrieves the threshold value.
Returns:
the threshold value

setAction

public void setAction(int action)
Sets the action to be performed by this agent to ALERT, EXECUTE, or EVENT.
Parameters:
action - the integer that represents the action

getAction

public int getAction()
Retrieves action this agent performs.
Returns:
the integer that represents the action (0=ALERT, 1=EXECUT, 2=EVENT)

setActionString

public void setActionString(java.lang.String actionString)
Sets the action string to be sent by this agent in an EVENT.
Parameters:
actionString - the integer that represents the action

getActionString

public java.lang.String getActionString()
Retrieves the actionString this agent sends in events.
Returns:
the String that is sent in the action field of an event.

setParms

public void setParms(java.lang.String params)
Sets the parameters used when this agent performs an ALERT or EXECUTE action.
Parameters:
params - the String that contains the parameters for the action

getParms

public java.lang.String getParms()
Retrieve the parameters used by the agent when performing an action.
Returns:
the String that contains the parameter

setDialog

public void setDialog(javax.swing.JDialog dlg)
Sets the dialog used by the agent when performing the ALERT or EXECUTE actions.
Parameters:
dlg - the JDialog that is used with an ALERT or EXECUTE action

initialize

public void initialize()
Initializes the agent.
Overrides:
initialize in class CIAgent

process

public void process()
Performs the default processing for this agent by checking the condition and performing the action is the condition is met.
Overrides:
process in class CIAgent

processCIAgentEvent

public void processCIAgentEvent(CIAgentEvent e)
Does nothing when an event is received.
Parameters:
e - the CIAgentEvent received by this agent
Overrides:
processCIAgentEvent in class CIAgent

processTimerPop

public void processTimerPop()
Performs the default processing for this agent when a timer pop occurs.
Overrides:
processTimerPop in class CIAgent

performAction

void performAction()
Peforms the ALERT, EXECUTE, or EVENT action.

executeCmd

public int executeCmd(java.lang.String cmd)
Executes the command string that was set up as a parameter for the EXECUTE action.
Parameters:
the - String that contains the command to be executed in the proper format for the platform on which this agent is running
cmd - the String object
Returns:
the integer that represents the exit value of the command process

exists

protected boolean exists()
Checks to see if the file exists.
Returns:
true if the file exists or false if the file does not exist

changed

protected boolean changed()
Checks to see if the file has changed.
Returns:
true if the file has changed or false if the file has not changed

length

protected long length()
Retrieves the size of the file in bytes.
Returns:
the size of the file in bytes

lastModified

protected long lastModified()
Retrieves the time the file was last modified.
Returns:
the time the file was modified