第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

HAPI - 也是規(guī)范的自定義模型類?

HAPI - 也是規(guī)范的自定義模型類?

紅糖糍粑 2023-03-09 14:10:03
我有一個(gè)應(yīng)用程序當(dāng)前使用帶有自定義消息類型和 Z 段類的自定義模型。例如,我的 v25 包中有一個(gè) DFT_P03 類,它擴(kuò)展了 AbstractMessage 并聲明了段,也在同一個(gè)包中,如下所示:private void init(ModelClassFactory factory) {    try     {        this.add(MSH.class, true, false);        this.add(PID.class, false, false);        this.add(PV1.class, false, false);        this.add(FT1.class, false, false);        this.add(ZPM.class, false, false);    }     catch (HL7Exception e)     {}}這就是我創(chuàng)建 HapiContext 的方式,它指向同一個(gè)包:public void initializeHAPI(){    try    {        ModelClassFactory cmf = new CustomModelClassFactory("com.somepackage.somelibraryname.hl7.custommodel");        MinLowerLayerProtocol mllp = new MinLowerLayerProtocol();        mllp.setCharset(StandardCharsets.ISO_8859_1.name());        hapiContext = new DefaultHapiContext();        hapiContext.setValidationContext(ValidationContextFactory.noValidation());        hapiContext.getPipeParser().getParserConfiguration().setUnexpectedSegmentBehaviour(UnexpectedSegmentBehaviourEnum.ADD_INLINE);        hapiContext.setModelClassFactory(cmf);        hapiContext.setLowerLayerProtocol(mllp);        logEntryService.logInfo(LogEntrySource.SERVICE, LogEntryType.CORE, "Successfully initialized HAPI framework", logger);    }    catch (Exception ex)    {        logEntryService.logError(LogEntrySource.SERVICE, LogEntryType.CORE, "Error initializing HAPI framework : "             + ex.getMessage(), logger);    }}只要我在 MSH.12 中使用 2.5 發(fā)送消息,一切都會(huì)完美無缺。我想將 CanonicalModelClassFactory 集成到其中,以便它可以將較低版本解析為 v2.5 消息,而不會(huì)在我嘗試將消息解析為我的 v2.5 DFT_P03 類時(shí)拋出 ClassCastException。我已經(jīng)閱讀了我能找到的關(guān)于此的所有信息,不幸的是,沒有一個(gè)將它與 CustomModelClassFactory 結(jié)合使用。我實(shí)際上創(chuàng)建了自己的 CustomModelClassFactory 類,它擴(kuò)展了 CanonicalClassModelFactory 并修改了構(gòu)造函數(shù)鏈:public CustomModelClassFactory() {    this((Map<String, String[]>)null);}請(qǐng)注意委托模型被設(shè)置為 CanonicalModelClassFactory 和 super("2.5") 調(diào)用。遺憾的是,在嘗試解析除 v2.5 DFT 消息之外的任何其他內(nèi)容時(shí),這仍然會(huì)拋出 ClassCastException。關(guān)于如何將這兩種行為整合在一起的任何想法?
查看完整描述

1 回答

?
慕尼黑8549860

TA貢獻(xiàn)1818條經(jīng)驗(yàn) 獲得超11個(gè)贊

我們找到了一種結(jié)合這兩種行為的方法。


public class CustomModelCanonicalClassFactory extends CustomModelClassFactory {

private String customVersion;


   public CustomModelCanonicalClassFactory(String packageName, String version){

        super(packageName);

        if (version == null || !Version.supportsVersion(version)) {

            throw new IllegalArgumentException("Unknown version: " + version);

        }

        this.customVersion = version;

    }


}

然后覆蓋你需要的所有方法,將顯式版本提供給 super#method



    @Override

    public Class<? extends Message> getMessageClass(String name, String version, boolean isExplicit) throws HL7Exception {

        return super.getMessageClass(name, this.customVersion, isExplicit);

    }


    @Override

    public Class<? extends Group> getGroupClass(String name, String version) throws HL7Exception {

        return super.getGroupClass(name, this.customVersion);

    }

最好的問候,帕特里克


查看完整回答
反對(duì) 回復(fù) 2023-03-09
  • 1 回答
  • 0 關(guān)注
  • 127 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)