/** * {@inheritDoc } */ public Class<? extends Message> getMessageClass(String name, String version, boolean isExplicit) throws HL7Exception { if (!isExplicit) { name = getMessageStructureForEvent(name, Version.versionOf(version)); } String key = "message" + name + version; Class<? extends Message> retVal = cache.get(key); if (retVal != null) return retVal; retVal = findClass("message", name, version); if (retVal == null) { retVal = delegate.getMessageClass(name, version, isExplicit); } if (retVal != null) cache.putIfAbsent(key, retVal); return retVal; }
/** * {@inheritDoc } */ public Class<? extends Message> getMessageClass(String name, String version, boolean isExplicit) throws HL7Exception { if (!isExplicit) { name = getMessageStructureForEvent(name, Version.versionOf(version)); } String key = "message" + name + version; Class<? extends Message> retVal = cache.get(key); if (retVal != null) return retVal; retVal = findClass("message", name, version); if (retVal == null) { retVal = delegate.getMessageClass(name, version, isExplicit); } if (retVal != null) cache.putIfAbsent(key, retVal); return retVal; }
/** * Note that the validation context of the resulting message is set to this parser's validation * context. The validation context is used within Primitive.setValue(). * * @param theName name of the desired structure in the form XXX_YYY * @param theVersion HL7 version (e.g. "2.3") * @param isExplicit true if the structure was specified explicitly in MSH-9-3, false if it was * inferred from MSH-9-1 and MSH-9-2. If false, a lookup may be performed to find an * alternate structure corresponding to that message type and event. * @return a Message instance * @throws HL7Exception if the version is not recognized or no appropriate class can be found or * the Message class throws an exception on instantiation (e.g. if args are not as * expected) */ protected Message instantiateMessage(String theName, String theVersion, boolean isExplicit) throws HL7Exception { Class<? extends Message> messageClass = getFactory().getMessageClass(theName, theVersion, isExplicit); if (messageClass == null) throw new HL7Exception("Can't find message class in current package list: " + theName); return ReflectionUtil.instantiateMessage(messageClass, getFactory()); }
/** * Note that the validation context of the resulting message is set to this parser's validation * context. The validation context is used within Primitive.setValue(). * * @param theName name of the desired structure in the form XXX_YYY * @param theVersion HL7 version (e.g. "2.3") * @param isExplicit true if the structure was specified explicitly in MSH-9-3, false if it was * inferred from MSH-9-1 and MSH-9-2. If false, a lookup may be performed to find an * alternate structure corresponding to that message type and event. * @return a Message instance * @throws HL7Exception if the version is not recognized or no appropriate class can be found or * the Message class throws an exception on instantiation (e.g. if args are not as * expected) */ protected Message instantiateMessage(String theName, String theVersion, boolean isExplicit) throws HL7Exception { Class<? extends Message> messageClass = getFactory().getMessageClass(theName, theVersion, isExplicit); if (messageClass == null) throw new HL7Exception("Can't find message class in current package list: " + theName); return ReflectionUtil.instantiateMessage(messageClass, getFactory()); }
public Message newMessage(String eventType, String triggerEvent, Version version) throws HL7Exception { try { String structure = getModelClassFactory().getMessageStructureForEvent(eventType + "_" + triggerEvent, version); Class<? extends Message> messageClass = getModelClassFactory().getMessageClass(structure, version.getVersion(), false); Message msg = newMessage(messageClass); ((AbstractMessage) msg).initQuickstart(eventType, triggerEvent, "P"); return msg; } catch (IOException e) { throw new HL7Exception(e); } }
public Message newMessage(String eventType, String triggerEvent, Version version) throws HL7Exception { try { String structure = getModelClassFactory().getMessageStructureForEvent(eventType + "_" + triggerEvent, version); Class<? extends Message> messageClass = getModelClassFactory().getMessageClass(structure, version.getVersion(), false); Message msg = newMessage(messageClass); ((AbstractMessage) msg).initQuickstart(eventType, triggerEvent, "P"); return msg; } catch (IOException e) { throw new HL7Exception(e); } }
private Message instantiateACK() throws HL7Exception { ModelClassFactory mcf = getParser() != null ? getParser().getFactory() : new DefaultModelClassFactory(); Version version = Version.versionOf(getVersion()); Message out = null; if (version != null && version.available()) { Class<? extends Message> clazz = mcf.getMessageClass("ACK", version.getVersion(), false); if (clazz != null) { out = ReflectionUtil.instantiateMessage(clazz, mcf); } } if (out == null) { out = new GenericMessage.UnknownVersion(mcf); } if (out instanceof GenericMessage) { if (!ArrayUtil.contains(out.getNames(), "MSA")) { out.addNonstandardSegment("MSA"); } if (!ArrayUtil.contains(out.getNames(), "ERR")) { out.addNonstandardSegment("ERR"); } } return out; }
private Message instantiateACK() throws HL7Exception { ModelClassFactory mcf = getParser() != null ? getParser().getFactory() : new DefaultModelClassFactory(); Version version = Version.versionOf(getVersion()); Message out = null; if (version != null && version.available()) { Class<? extends Message> clazz = mcf.getMessageClass("ACK", version.getVersion(), false); if (clazz != null) { out = ReflectionUtil.instantiateMessage(clazz, mcf); } } if (out == null) { out = new GenericMessage.UnknownVersion(mcf); } if (out instanceof GenericMessage) { if (!ArrayUtil.contains(out.getNames(), "MSA")) { out.addNonstandardSegment("MSA"); } if (!ArrayUtil.contains(out.getNames(), "ERR")) { out.addNonstandardSegment("ERR"); } } return out; }