public class CaseTag extends CommonTagSupport
case タグは、上位の switch タグの key とマッチした場合に、処理を行います。 case タグの以下の属性について、説明します。 match : switch_key.match( case_match ) でマッチした場合は、BODY が処理されます。 isDefault: trueに設定すると、どのcase にもマッチしなかった場合に処理されます(初期値:false) isBreak : 通常、最初にマッチした段階で、switch 処理を抜けます(初期値:true) isNull : trueに設定すると、switchのkeyが、null(またはゼロ文字列)の場合、マッチします(初期値:false)
●形式:<og:switch key="・・・" > <og:case match="A" > ・・・ </og:case> <og:case match="B" > ・・・ </og:case> <og:case match="C" > ・・・ </og:case> <og:case isDefault="true" > ・・・ </og:case> </og:switch> ●body:あり(EVAL_BODY_INCLUDE:BODYをインクルードし、{@XXXX} は解析しません) ●Tag定義: <og:case match 【TAG】switch-case のマッチ条件(case_match)を指定します isDefault 【TAG】どのcase にもマッチしなかった場合に処理する case 文かどうかを指定します(初期値:false) isBreak 【TAG】マッチした以降に継続処理を行わない(ブレイクする)かどうかを指定(初期値:true) isNull 【TAG】switchのkeyが、null(またはゼロ文字列)の場合、マッチするかどうか[true/false]を設定します(初期値:false) debug 【TAG】デバッグ情報を出力するかどうか[true/false]を指定します(初期値:false) > ... Body ... </og:case> ●使用例 <og:switch key="{@PARAM}" > <og:case match="A" > 処理A </og:case> <og:case match="B" > 処理B </og:case> <og:case match="C" > 処理C </og:case> <og:case isDefault="true" > 処理X </og:case> </og:switch> ・switch の key に対して、case の match に指定された値が、マッチ(switch_key.match( case_match )) した場合に、case の BODY 部分が処理されます。 マッチしなければ、BODY部は、スキップされます。 ・isDefault="true" の場合は、どれとも マッチしなかった場合に、実行されます。 ・Javaの switch-case 文は、最初に処理された case 以降を処理します。通常は、break を入れて 後続処理を実行されないようにしています。 この、switch-case タグは、caseタグの isBreak 属性で制御します。初期値が isBreak="true" に、 なっているため、通常は、どれかの case が実行された段階で、switchの処理は、終了されます。 isBreak="false" にすると、switchから抜けずに、継続して case との match を実行します。 この場合、Java等と異なるのは、直後のcase文が実行されるのではなく、あくまで match 作業が 継続されるということです。つまり、複数の case で処理を行いたい場合は、isBreak="false" に すると同時に、match 条件もそれぞれで、マッチするように設定する必要があります。 <og:switch key="{@PARAM}" > <og:case match="[1]" isBreak="false" > 処理A </og:case> <og:case match="[12]" isBreak="false" > 処理B </og:case> <og:case match="[123]" isBreak="false" > 処理C </og:case> <og:case isNull="true" > 処理X </og:case> <og:case isDefault="true" > 処理Y </og:case> </og:switch> ・上記指定では、isBreak="false" が指定されているため、マッチした後も継続して判定処理が実施されます。 ・上記例で言うと、PARAM が "1" の場合、上記3つともにマッチします。 ・isNull="true" は、switch の key が null の場合に成立します。(null とは、ゼロ文字列も含む)
5.2.3.0 (2010/12/01) 新規追加 |
BR, BUFFER_MIDDLE, CR
bodyContent
id, pageContext
EVAL_BODY_BUFFERED, EVAL_BODY_TAG
EVAL_BODY_AGAIN
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
コンストラクタと説明 |
---|
CaseTag()
デフォルトコンストラクター
|
修飾子とタイプ | メソッドと説明 |
---|---|
int |
doEndTag()
Taglibの終了タグが見つかったときに処理する doEndTag() を オーバーライドします。
|
int |
doStartTag()
Taglibの開始タグが見つかったときに処理する doStartTag() を オーバーライドします。
|
protected void |
release2()
タグリブオブジェクトをリリースします。
|
void |
setIsBreak(String flag)
【TAG】マッチした以降に継続処理を行わない(ブレイクする)かどうかを指定(初期値:true)。
|
void |
setIsDefault(String flag)
【TAG】どのcase にもマッチしなかった場合に処理する case 文かどうかを指定します(初期値:false)。
|
void |
setIsNull(String flag)
【TAG】switchのkeyが、null(またはゼロ文字列)の場合、マッチするかどうか[true/false]を設定します(初期値:false)。
|
void |
setMatch(String mkey)
【TAG】switch-case のマッチ条件(case_match)を指定します。
|
String |
toString()
このオブジェクトの文字列表現を返します。
|
add, add, addEventColumn, addEventColumn, check, commitTableObject, debugPrint, doAfterBody, doCatch, doFinally, get, getApplicationInfo, getAttributes, getBodyRawString, getBodyString, getContextAttribute, getContextPath, getCookie, getCSVParameter, getCSVParameter, getDataCondition, getDateFormat, getDBColumn, getDBFunctionName, getDocumentLink, getGUIInfo, getGUIInfoAttri, getHostName, getLabel, getLabelInterface, getLanguage, getLASTAttri, getLongLabel, getMsg, getMsglbl, getNVLAttri, getObject, getParameterNames, getParameterRows, getRequest, getRequestAttribute, getRequestCacheData, getRequestMethod, getRequestParameter, getRequestParameterValues, getRequestValue, getRequestValue, getRequestValues, getReservedParameter, getReservedValue, getResource, getSanitizedBodyString, getScope, getSessionAttribute, getSumRequestValue, getTagName, getTransaction, getUser, getUserEditInfo, getUserInfo, isAjaxSubmitRequest, isDebug, isNoTransitionRequest, isNull, jspPrint, makeUrl, removeContextAttribute, removeObject, removeRequestAttribute, removeSessionAttribute, set, setAjaxSubmitRequest, setCaseIf, setCaseKey, setCaseNN, setCaseNull, setCaseVal, setContextAttribute, setCookie, setDebug, setLanguage, setLbl, setNoTransitionRequest, setObject, setObject, setParameterNames, setParameterRows, setRequestAttribute, setRequestCacheData, setScope, setSessionAttribute, setUserInfo, startQueryTransaction, sys, sysBool, sysInt, useMainTrans, useQuotCheck, useTag, useXssCheck
doInitBody, getBodyContent, getPreviousOut, release, setBodyContent
findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, setPageContext, setParent, setValue
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getParent, setPageContext, setParent
public CaseTag()
6.4.2.0 (2016/01/29) PMD refactoring. Each class should declare at least one constructor. |
public int doStartTag()
doStartTag
インタフェース内 Tag
doStartTag
クラス内 CommonTagSupport
public int doEndTag()
doEndTag
インタフェース内 Tag
doEndTag
クラス内 CommonTagSupport
protected void release2()
release2
クラス内 CommonTagSupport
public void setMatch(String mkey)
mkey
- マッチ条件switch_key.match( case_match ) でマッチした場合は、BODY が処理されます。
public void setIsDefault(String flag)
flag
- デフォルト処理 [true:する/false:しない]trueに設定すると、どのcase にもマッチしなかった場合に処理されます このタグそのものがなにも出力しません。(つまり条件から消えます。) BODY 部に記述することが可能です。その場合は、value 属性になにも設定できません。 初期値は、false:default case 文ではない です。
public void setIsBreak(String flag)
flag
- ブレイク可否 [true:する/false:しない(=継続処理する)]true に設定すると、マッチした段階で、ブレイクします。 Javaの switch-case 文は、最初に処理された case 以降を処理します。通常は、break を入れて 後続処理を実行されないようにしています。 この、switch-case タグは、caseタグの break 属性で制御します。初期値が break="true" に、 なっているため、通常は、どれかの case が実行された段階で、switchの処理は、終了されます。 break="false" にすると、switchから抜けずに、継続して case との match を実行します。 この場合、Java等と異なるのは、直後のcase文が実行されるのではなく、あくまで match 作業が 継続されるということです。つまり、複数の case で処理を行いたい場合は、break="false" に すると同時に、match 条件もそれぞれで、マッチするように設定する必要があります。 初期値は、true:ブレイクする です。
public void setIsNull(String flag)
flag
- nullマッチ判定 [true:する/false:しない]trueに設定すると、switchのkeyが、null(またはゼロ文字列)の場合、マッチします。 初期値のfalse にすると、キーが null でない場合だけ、マッチ処理を実行します。 case の条件判定で使用されます。 初期値は、 false (null でない) です。
public String toString()
toString
クラス内 CommonTagSupport
Webアプリケーションフレームワーク openGionCopyright (c) 2009 The openGion Project.