org.jactr.core.production.action
Class AddAction

java.lang.Object
  extended by org.jactr.core.production.action.DefaultAction
      extended by org.jactr.core.production.action.AddAction
All Implemented Interfaces:
IAction, IBufferAction, ISlotContainer
Direct Known Subclasses:
ProxyAction

public class AddAction
extends DefaultAction
implements IBufferAction, ISlotContainer

AddAction represents the consequence of adding a chunk to a buffer. It can add an existing chunk to a buffer, add a chunk that is referenced by a variable name, or to create a new chunk in the buffer.

Author:
harrison

Constructor Summary
AddAction()
          default constructor equivalent to AddAction("goal", null)
AddAction(java.lang.String bufferName, java.lang.Object ref)
           
AddAction(java.lang.String bufferName, java.lang.Object ref, java.util.Collection<? extends ISlot> slots)
          add a chunk (ref) to bufferName buffer
 
Method Summary
 void addSlot(ISlot s)
          In addition to adding chunks to a buffer, the IChunk?s slot values can be changed at the same time.
 IAction bind(java.util.Map<java.lang.String,java.lang.Object> bindings)
          Bind is called during the creation of an instantiation of a produciton.
 void dispose()
          Description of the Method
 double fire(IInstantiation instantiation, double firingTime)
          Description of the Method
 java.lang.String getBufferName()
          return the name of the buffer that the chunk will be added to
 IChunk getChunk()
          return the chunk to be added if it was specified.
 java.lang.String getChunkName()
          return the variable name of the chunk if it has been specified, null otherwise
 IChunkType getChunkType()
          return the chunktype of the to-be created chunk if it has been specified, null otherwise
 java.lang.Object getReferant()
          Gets the referant attribute of the AddAction object
 java.util.Collection<? extends ISlot> getSlots()
          Return all the slots that this addaction will attempt to set for the to be added chunk.
 java.util.Collection<ISlot> getSlots(java.util.Collection<ISlot> slots)
           
 void removeSlot(ISlot s)
          Remove a specific slot from the addaction.
 void setBufferName(java.lang.String name)
          override the constructor and set the buffer name
 void setChunk(IChunk c)
          set the chunk that will be added to the buffer
 void setChunkName(java.lang.String name)
          set the variable name of the chunk to be added.
 void setChunkType(IChunkType ct)
          set the chunktype of the chunk to be created
 void setReferant(java.lang.Object o)
          Sets the referant attribute of the AddAction object
 java.lang.String toString()
          Description of the Method
 
Methods inherited from class org.jactr.core.production.action.DefaultAction
resolve
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AddAction

public AddAction()
default constructor equivalent to AddAction("goal", null)

Since:

AddAction

public AddAction(java.lang.String bufferName,
                 java.lang.Object ref,
                 java.util.Collection<? extends ISlot> slots)
add a chunk (ref) to bufferName buffer

Parameters:
bufferName - name of the buffer to insert into
ref - IChunk, IChunkType, chunkName, or variable name
Since:

AddAction

public AddAction(java.lang.String bufferName,
                 java.lang.Object ref)
Method Detail

toString

public java.lang.String toString()
Description of the Method

Overrides:
toString in class java.lang.Object
Returns:
Description of the Returned Value
Since:

dispose

public void dispose()
Description of the Method

Specified by:
dispose in interface IAction
Overrides:
dispose in class DefaultAction
Since:

getReferant

public java.lang.Object getReferant()
Gets the referant attribute of the AddAction object

Returns:
The referant value
Since:

setReferant

public void setReferant(java.lang.Object o)
Sets the referant attribute of the AddAction object

Parameters:
o - The new referant value
Since:

bind

public IAction bind(java.util.Map<java.lang.String,java.lang.Object> bindings)
             throws CannotInstantiateException
Description copied from interface: IAction
Bind is called during the creation of an instantiation of a produciton. By the time this gets called, we know that all the conditions are matched and all the variables have been assigned. This method merely creates a copy of this action and applies those bindings. the IAction returned by this method will be the actual one that is fired. Normally, an action should not change the contents of variableBindings

Specified by:
bind in interface IAction
Returns:
Throws:
CannotInstantiateException

getBufferName

public java.lang.String getBufferName()
return the name of the buffer that the chunk will be added to

Specified by:
getBufferName in interface IBufferAction
Returns:
The bufferName value
Since:

setBufferName

public void setBufferName(java.lang.String name)
override the constructor and set the buffer name

Specified by:
setBufferName in interface IBufferAction
Parameters:
name - The new bufferName value
Since:

setChunkType

public void setChunkType(IChunkType ct)
set the chunktype of the chunk to be created

Parameters:
ct - The new chunkType value
Since:

setChunkName

public void setChunkName(java.lang.String name)
set the variable name of the chunk to be added. This must be a valid variable name and must be previously defined by a condition or another action

Parameters:
name - The new chunkName value
Since:

setChunk

public void setChunk(IChunk c)
set the chunk that will be added to the buffer

Parameters:
c - The new chunk value
Since:

getChunkName

public java.lang.String getChunkName()
return the variable name of the chunk if it has been specified, null otherwise

Returns:
The chunkName value
Since:

getChunkType

public IChunkType getChunkType()
return the chunktype of the to-be created chunk if it has been specified, null otherwise

Returns:
The chunkType value
Since:

getChunk

public IChunk getChunk()
return the chunk to be added if it was specified.

Returns:
The chunk value
Since:

getSlots

public java.util.Collection<? extends ISlot> getSlots()
Return all the slots that this addaction will attempt to set for the to be added chunk.

Specified by:
getSlots in interface ISlotContainer
Returns:
The slots value
Since:

getSlots

public java.util.Collection<ISlot> getSlots(java.util.Collection<ISlot> slots)
Specified by:
getSlots in interface ISlotContainer

addSlot

public void addSlot(ISlot s)
In addition to adding chunks to a buffer, the IChunk?s slot values can be changed at the same time. This prevents the need to an additional action just to change the slot values. The slot added will be used to modify the same named slot in the chunk.

Specified by:
addSlot in interface ISlotContainer
Parameters:
s - The feature to be added to the ISlot attribute
Since:

removeSlot

public void removeSlot(ISlot s)
Remove a specific slot from the addaction.

Specified by:
removeSlot in interface ISlotContainer
Parameters:
s - Description of Parameter
Since:

fire

public double fire(IInstantiation instantiation,
                   double firingTime)
Description copied from class: DefaultAction
Description of the Method

Specified by:
fire in interface IAction
Specified by:
fire in class DefaultAction
Parameters:
instantiation - Description of the Parameter
firingTime - when this production was fired
Returns:
Description of the Return Value