カスタム画面認識の例

以下に、カスタム画面認識を実行するビジネス・ロジックの例を示します。このビジネス・ロジック・クラスは、ブランクで区切られたコード・ページ番号のリストを 設定値としてとり、設定値にリストされた値のいずれかとコード・ページが一致した場合に 画面を認識します。タグ構文は次のとおりです。
<customreco id="company.project.customlogic.CodePageValidate::[settings]" optional="false" invertmatch="false" />
例えば、次のタグを説明ブロックに挿入することができます。
<customreco id="company.project.customlogic.CodePageValidate::037 434 1138" optional="false" invertmatch="false" />

この場合は、コード・ページが 037、434、または 1138 であるときに 画面が認識されます。

////////////////////////////////////////////////////////////////////////////////
//  This sample is provided AS IS.
//  Permission to use, copy and modify this software for any purpose and
//  without fee is hereby granted. provided that the name of IBM not be used in
//  advertising or publicity pertaining to distribution of the software without
//  specific written permission.
//
//  IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SAMPLE, INCLUDING ALL
//  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL IBM
//  BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
//  DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
//  IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
//  OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SAMPLE.
////////////////////////////////////////////////////////////////////////////////
package company.project.customlogic;

import java.util.StringTokenizer;
import java.lang.Integer;
import com.ibm.eNetwork.ECL.ECLPS;
import com.ibm.eNetwork.ECL.ECLScreenDesc;
import com.ibm.hats.common.IBusinessLogicInformation;
import com.ibm.hats.common.HostScreen;
import com.ibm.hats.common.customlogic.AbstractCustomScreenRecoListener;

public class CodePageValidate extends AbstractCustomScreenRecoListener {

/**
 * @see com.ibm.hats.common.customlogic.AbstractCustomScreenRecoListener
 * #isRecognized(java.lang.String, com.ibm.hats.common.IBusinessLogicInformation,
 *       com.ibm.eNetwork.ECL.ECLPS,  com.ibm.eNetwork.ECL.ECLScreenDesc)
	 */
	public boolean isRecognized(
		String settings,
		IBusinessLogicInformation bli,
		ECLPS ps,
		ECLScreenDesc screenDescription) {
		HostScreen hs=bli.getHostScreen();
		int int_codepage=hs.GetCodePage();
		if(settings!=null)
		{
			StringTokenizer tokenizer = new StringTokenizer(settings);
			while( tokenizer.hasMoreTokens() )
			{   
				int int_token= Integer.valueOf(tokenizer.nextToken()).intValue();
				if ( int_token==int_codepage )
				{    
					 return true;
				}
			}
		}
		return false;
	}

}