Cosminexus V9 BPM/ESB基盤 サービスプラットフォーム 開発ガイド 基本開発編
読み込み情報インターフェースを次に示します。
文字コード変換UOCを開発する場合,次のインターフェースの実装クラスを作成します。
図H-5 CSCOwnCodeReaderContext実装クラス
package jp.co.Hitachi.soft.csc.dt.uoc ;
public interface CSCOwnCodeReaderContext {
int getPosition() ;
int getLength() ;
boolean canSeparate() ;
}
| メソッド名 | 説明 |
|---|---|
| getPositionメソッド | 現在の文字位置または読み込めるデータのサイズを返すメソッドです。 |
| getLengthメソッド | 現在の文字長を返すメソッドです。 |
| canSeparateメソッド | 現在の文字をセパレータの解析対象とするかどうかを返すメソッドです。 |
データ変換の対象が可変長文字列で,かつバイナリフォーマット定義にセパレータが設定されている場合,データ変換はセパレータの解析処理を実行します。CSCOwnCodeReaderおよびCSCOwnCodeReaderContextの各メソッドの呼び出し順序を次の図に示します。
図H-6 CSCOwnCodeReaderおよびCSCOwnCodeReaderContextの各メソッドの呼び出し順序
public int getPosition()
public int getLength()
public boolean canSeparate()
文字コード変換UOCの開発時に発生する例外クラスを次に示します。
CSCOwnCodeReaderContextインターフェースの実装例(MS932)を次に示します。
public class CSCOwnCodeReaderContextImpl implements CSCOwnCodeReaderContext {
private final byte[] data ;
private int position = 0 ;
private int next = 0 ;
private int length = 0 ;
public CSCOwnCodeReaderContextImpl(
final byte[] data ) {
this.data = data ;
}
@Override
public int getPosition() {
return position ;
}
@Override
public int getLength() {
return length ;
}
@Override
public boolean canSeparate() {
// MS932はシフト(エスケープシーケンス)状態を持たず,
// セパレータの出現に制限がないため,常にtrueを返す
return true ;
}
public byte[] getData() {
return data ;
}
public void setPosition( int position ) {
this.position = position ;
}
public void setLength( int length ) {
this.length = length ;
}
public int getNextPosition() {
return this.next ;
}
public void setNextPosition( int position ) {
this.next = position ;
}
}
CSCOwnCodeReaderContextインターフェースの実装例(IBM漢字コード)を次に示します。
public class CSCOwnCodeReaderContextImpl implements CSCOwnCodeReaderContext {
private final byte[] data ;
private int position = 0 ;
private int length = 1 ;
private int next = 0 ;
private boolean canSeparate = true ;
public CSCOwnCodeReaderContextImpl( final byte[] data ) {
this.data = data ;
}
@Override
public int getPosition() {
return position ;
}
@Override
public int getLength() {
return length ;
}
@Override
public boolean canSeparate() {
return canSeparate ;
}
public byte[] getData() {
return data ;
}
public void setPosition( int position ) {
this.position = position ;
}
public void setLength( int length ) {
this.length = length ;
}
public void setCanSeparate( boolean canSeparate ) {
this.canSeparate = canSeparate ;
}
public int getNextPosition() {
return this.next ;
}
public void setNextPosition( int position ) {
this.next = position ;
}
}
All Rights Reserved. Copyright (C) 2012, 2019, Hitachi, Ltd.