You need to obtain the PipeParser from the HapiContext where you attached the ModelClassFactory to.
ModelClassFactory cfm=*new* CustomModelClassFactory("com.hss.customodel"); HapiContext context=*new* DefaultHapiContext(cfm); Parser pipeParser = context.getPipeParser(); Message m=pipeParser.parse(ackMessageString); System.*out*.println("My message is "+m.printStructure()); Now the Parser should use your custom structures. Christian 2015-10-22 17:05 GMT+02:00 Davies, Brian <brian.dav...@mckesson.com>: > I am using the HAPI version 2.5 library. > > //instantiate a PipeParser, which handles the "traditional encoding" > > ModelClassFactory cfm=*new* CustomModelClassFactory( > "com.hss.customodel"); > > Parser pipeParser = *new* PipeParser(cfm); > > *int* count=0; > > HapiContext context=*new* DefaultHapiContext(cfm); > > context.setModelClassFactory(cfm); > > *try*{ > > Message m=pipeParser.parse(ackMessageString); > > System.*out*.println("My message is "+m.printStructure()); > > > > }*catch*(Exception e){ > > e.printStackTrace(); > > } > > > > The logs show that the DefaultModelFactory is being used instead of the > CustomModelFactory. Further proof is that I can change the package name to > one that doesn’t exist with no exceptions thrown. > > > > > > Here is a sample of the log output: > > > > 10:03:20,649 DEBUG [main] DefaultModelClassFactory:330 - Loaded: > ca.uhn.hl7v2.model.v25.message.MFN_M01 class: class > ca.uhn.hl7v2.model.v25.message.MFN_M01 > > 10:03:20,696 DEBUG [main] MessageIterator:178 - Creating non standard > segment ZP1 on group: MF > > 10:03:20,696 DEBUG [main] DefaultModelClassFactory:326 - Trying to load: > ca.uhn.hl7v2.model.v25.segment.ZP1 > > 10:03:20,696 DEBUG [main] DefaultModelClassFactory:334 - Failed to load: > ca.uhn.hl7v2.model.v25.segment.ZP1 > > > > > > Many thanks. > > > ------------------------------------------------------------------------------ > > _______________________________________________ > Hl7api-devel mailing list > Hl7api-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/hl7api-devel > >
------------------------------------------------------------------------------
_______________________________________________ Hl7api-devel mailing list Hl7api-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/hl7api-devel