AnnounceCommand

Package: MachII.framework.commands
Inherits from: framework.EventCommand
An EventCommand for announcing an event.

<!--- License: Copyright 2006 Mach-II Corporation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Copyright: Mach-II Corporation Author: Ben Edwards (ben@ben-edwards.com) $Id: AnnounceCommand.cfc 4352 2006-08-29 20:35:15Z pfarrell $ Created version: 1.0.0 Updated version: 1.1.0 --->

Method Summary
public AnnounceCommand init(string eventName, [boolean copyEventArgs="true"])

Used by the framework for initialization.

public boolean execute(Event event, EventContext eventContext)

Executes the command.

private string getEventName()
private boolean isCopyEventArgs()
private void setCopyEventArgs([boolean copyEventArgs="true"])
private void setEventName(string eventName)
Methods inherited from framework.EventCommand:   setParameter , getParameter , setParameters
Method Detail
execute

public boolean execute( Event event, EventContext eventContext )

Executes the command.

Parameters:
Event event
EventContext eventContext

Code:

	<cffunction name="execute" access="public" returntype="boolean" output="false"
		hint="Executes the command.">
		<cfargument name="event" type="MachII.framework.Event" required="true" />
		<cfargument name="eventContext" type="MachII.framework.EventContext" required="true" />
		
		<cfset var eventArgs = "" />
		<cfif isCopyEventArgs()>
			<cfset eventArgs = event.getArgs() />
		<cfelse>
			<cfset eventArgs = StructNew() />
		</cfif>
		
		<cfset arguments.eventContext.announceEvent(getEventName(), eventArgs) />
		
		<cfreturn true />
	</cffunction> 

getEventName

private string getEventName( )

Parameters:

Code:

	<cffunction name="getEventName" access="private" returntype="string" output="false">
		<cfreturn variables.eventName />
	</cffunction> 

init

public AnnounceCommand init( string eventName, [boolean copyEventArgs="true"] )

Used by the framework for initialization.

Parameters:
string eventName
[boolean copyEventArgs="true"]

Code:

	<cffunction name="init" access="public" returntype="AnnounceCommand" output="false"
		hint="Used by the framework for initialization.">
		<cfargument name="eventName" type="string" required="true" />
		<cfargument name="copyEventArgs" type="boolean" required="false" default="true" />
		
		<cfset setEventName(arguments.eventName) />
		<cfset setCopyEventArgs(arguments.copyEventArgs) />
		
		<cfreturn this />
	</cffunction> 

isCopyEventArgs

private boolean isCopyEventArgs( )

Parameters:

Code:

	<cffunction name="isCopyEventArgs" access="private" returntype="boolean" output="false">
		<cfreturn variables.copyEventArgs />
	</cffunction> 

setCopyEventArgs

private void setCopyEventArgs( [boolean copyEventArgs="true"] )

Parameters:
[boolean copyEventArgs="true"]

Code:

	<cffunction name="setCopyEventArgs" access="private" returntype="void" output="false">
		<cfargument name="copyEventArgs" type="boolean" required="false" default="true" />
		<cfset variables.copyEventArgs = arguments.copyEventArgs />
	</cffunction> 

setEventName

private void setEventName( string eventName )

Parameters:
string eventName

Code:

	<cffunction name="setEventName" access="private" returntype="void" output="false">
		<cfargument name="eventName" type="string" required="true" />
		<cfset variables.eventName = arguments.eventName />
	</cffunction>