EventArgCommand

Package: MachII.framework.commands
Inherits from: framework.EventCommand
An EventCommand for putting an event arg into the current 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: EventArgCommand.cfc 4352 2006-08-29 20:35:15Z pfarrell $ Created version: 1.0.0 Updated version: 1.1.0 --->

Method Summary
public EventArgCommand init(string argName, [string argValue=""], [string argVariable=""])

Used by the framework for initialization.

public boolean execute(Event event, EventContext eventContext)

Executes the command.

private string getArgName()
private string getArgValue()
private string getArgVariable()
private any getArgVariableValue()
private boolean isArgValueDefined()
private boolean isArgVariableDefined()
private void setArgName(string argName)
private void setArgValue(string argValue)
private void setArgVariable(string argVariable)
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"
		hint="Executes the command.">
		<cfargument name="event" type="MachII.framework.Event" required="true" />
		<cfargument name="eventContext" type="MachII.framework.EventContext" required="true" />
		
		<cfset var value = "" />
		
		<cfif isArgVariableDefined()>
			<cfset value = getArgVariableValue() />
		<cfelseif isArgValueDefined()>
			<cfset value = getArgValue() />
		<cfelse>
			<cfset value = "" />
		</cfif>
		
		<cfset arguments.event.setArg(getArgName(), value) />
		
		<cfreturn true />
	</cffunction> 

getArgName

private string getArgName( )

Parameters:

Code:

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

getArgValue

private string getArgValue( )

Parameters:

Code:

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

getArgVariable

private string getArgVariable( )

Parameters:

Code:

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

getArgVariableValue

private any getArgVariableValue( )

Parameters:

Code:

	<cffunction name="getArgVariableValue" access="private" returntype="any" output="false">
		<cfset var value = "" />
		<cfif IsDefined(getArgVariable())>
			<cfset value = Evaluate(getArgVariable()) />
		</cfif>
		<cfreturn value />
	</cffunction> 

init

public EventArgCommand init( string argName, [string argValue=""], [string argVariable=""] )

Used by the framework for initialization.

Parameters:
string argName
[string argValue=""]
[string argVariable=""]

Code:

	<cffunction name="init" access="public" returntype="EventArgCommand" output="false"
		hint="Used by the framework for initialization.">
		<cfargument name="argName" type="string" required="true" />
		<cfargument name="argValue" type="string" required="false" default="" />
		<cfargument name="argVariable" type="string" required="false" default="" />
		
		<cfset setArgName(arguments.argName) />
		<cfset setArgValue(arguments.argValue) />
		<cfset setArgVariable(arguments.argVariable) />
		
		<cfreturn this />
	</cffunction> 

isArgValueDefined

private boolean isArgValueDefined( )

Parameters:

Code:

	<cffunction name="isArgValueDefined" access="private" returntype="boolean" output="false">
		<cfreturn NOT getArgValue() EQ '' />
	</cffunction> 

isArgVariableDefined

private boolean isArgVariableDefined( )

Parameters:

Code:

	<cffunction name="isArgVariableDefined" access="private" returntype="boolean" output="false">
		<cfreturn NOT getArgVariable() EQ '' />
	</cffunction> 

setArgName

private void setArgName( string argName )

Parameters:
string argName

Code:

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

setArgValue

private void setArgValue( string argValue )

Parameters:
string argValue

Code:

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

setArgVariable

private void setArgVariable( string argVariable )

Parameters:
string argVariable

Code:

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