2007-09-19

利用ColdFusion组件实现状态模式

来源: 开发者 作者: 评论 0 条
 
<cfargument name="stateName" type="string" required="true" />
<cftry>
<cfreturn variables.stateMappings[arguments.stateName] />
<cfcatch type="any">
<cfthrow message="No state with a mapping of '#arguments.stateName#' could be found." />
</cfcatch>
</cftry>
</cffunction>

<cffunction name="getCurrentState" access="private" returntype="AbstractContentState" output="false" roles="" hint="I return the currentState.">
<cfreturn variables.instance.currentState />
</cffunction>

<cffunction name="setCurrentState" access="private" returntype="void" output="false" roles="" hint="I set the currentState.">
<cfargument name="currentState" type="AbstractContentState" required="true" hint="currentState" />
<cfset variables.instance.currentState = arguments.currentState />
</cffunction>

</cfcomponent>

列表 F
<cfcomponent output="false">

<cffunction name="init" access="public" returntype="AbstractContentState" hint="Constructor.">
<cfargument name="stateName" type="string" required="true" />
<cfset setStateName(arguments.stateName) />
<cfreturn this />
</cffunction>

<cffunction name="save" access="public" returntype="void" output="true" hint="">
<cfthrow message="State '#getStateName()#' does not implement the save method." />
</cffunction>

<cffunction name="approve" access="public" returntype="void" output="true" hint="">
<cfthrow message="State '#getStateName()#' does not implement the approve method." />
</cffunction>

<cffunction name="deploy" access="public" returntype="void" output="true" hint="">
<cfthrow message="State '#getStateName()#' does not implement the deploy method." />
</cffunction>

<cffunction name="makeDraft" access="public" returntype="void" output="true" hint="">
<cfthrow message="State '#getStateName()#' does not implement the makeDraft method." />
</cffunction>

<cffunction name="getStateName" access="private" returntype="string" output="false" roles="" hint="I return the stateName.">
<cfreturn variables.instance.stateName />
</cffunction>
共9页: 上一页 [1] [2] [3] [4] [5] 6 [7] [8] [9] 下一页

(本文仅表明作者个人观点,不代表本站及其管理员立场.) 推荐 收藏 投稿 打印 返回 关闭
上一篇:Python介绍  
下一篇:Java语言中常见的十大误解
    评论加载中…
 推荐文章
     

网站首页  -  网站地图 -   站长论坛  -  网站投稿  -    -  网站管理
Copyright © 2008 芜湖站长站 All Rights Reserved 皖ICP备07500611号