Package model

Examples of model.Message


            throw new HL7Exception("Can't process message of version '" + version + "' - version not recognized",
                    HL7Exception.UNSUPPORTED_VERSION_ID);
        }
       
        myValidator.validate(message, encoding.equals("XML"), version);       
        Message result = doParse(message, version);
        myValidator.validate(result);

        result.setParser(this);
       
        return result;
    }
View Full Code Here


                HL7Exception.UNSUPPORTED_VERSION_ID);
    }
    
    myValidator.validate(message, encoding.equals("XML"), version);
    
    Message result = doParseForSpecificPackage(message, version, packageName);
    
    myValidator.validate(result);
   
    result.setParser(this);
    
    return result;
  }
View Full Code Here

   * Instantiate a message type using a specific package name
   *
   * @see ModelClassFactory#getMessageClassInASpecificPackage(String, String, boolean, String)
   */
  protected Message instantiateMessageInASpecificPackage(String theName, String theVersion, boolean isExplicit, String packageName) throws HL7Exception {
    Message result = null;
    
    try {
      Class<? extends Message> messageClass = myFactory.getMessageClassInASpecificPackage(theName, theVersion, isExplicit, packageName);
      if (messageClass == null) {
        throw new ClassNotFoundException("Can't find message class in current package list: " + theName);
      }
     
      log.debug("Instantiating msg of class {}", messageClass.getName());
      Constructor<? extends Message> constructor = messageClass.getConstructor(new Class[]{ModelClassFactory.class});
      result = (Message) constructor.newInstance(new Object[]{myFactory});
    } catch (Exception e) {
      throw new HL7Exception("Couldn't create Message object of type " + theName,
      HL7Exception.UNSUPPORTED_MESSAGE_TYPE, e);
    }
    
    result.setValidationContext(myContext);
    
    return result;
  }
View Full Code Here

     */
    public static Segment makeControlMSH(String version, ModelClassFactory factory) throws HL7Exception {
        Segment msh = null;
       
        try {
            Message dummy = (Message) GenericMessage.getGenericMessageClass(version)
                .getConstructor(new Class[]{ModelClassFactory.class}).newInstance(new Object[]{factory});
           
            Class<?>[] constructorParamTypes = { Group.class, ModelClassFactory.class };
            Object[] constructorParamArgs = { dummy, factory };
            Class<? extends Segment> c = factory.getSegmentClass("MSH", version);
View Full Code Here

     * @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 {
        Message result = null;
       
        try {
            Class<? extends Message> messageClass = myFactory.getMessageClass(theName, theVersion, isExplicit);
            if (messageClass == null)
                throw new ClassNotFoundException("Can't find message class in current package list: "
                    + theName);
            log.debug("Instantiating msg of class {}", messageClass.getName());
            Constructor<? extends Message> constructor = messageClass.getConstructor(new Class[]{ModelClassFactory.class});
            result = constructor.newInstance(new Object[]{myFactory});
        } catch (Exception e) {           
            throw new HL7Exception("Couldn't create Message object of type " + theName,
                HL7Exception.UNSUPPORTED_MESSAGE_TYPE, e);
        }
       
        result.setValidationContext(myContext);
       
        return result;
    }
View Full Code Here

     */
    protected Message doParse(String message, String version) throws HL7Exception, EncodingNotSupportedException {

        // try to instantiate a message object of the right class
        MessageStructure structure = getStructure(message);
        Message m = instantiateMessage(structure.messageStructure, version, structure.explicitlyDefined);

        parse(m, message);

        return m;
    }
View Full Code Here

     */
    protected Message doParseForSpecificPackage(String message, String version, String packageName) throws HL7Exception, EncodingNotSupportedException {

        // try to instantiate a message object of the right class
        MessageStructure structure = getStructure(message);
        Message m = instantiateMessageInASpecificPackage(structure.messageStructure, version, structure.explicitlyDefined, packageName);

        parse(m, message);

        return m;
    }
View Full Code Here

       
        if (clazz.isAnnotationPresent(DoNotCacheStructure.class)) {
            Holder<StructureDefinition> previousLeaf = new Holder<StructureDefinition>();
            retVal = createStructureDefinition(theMessage, previousLeaf);
        } else {
          Message message = ReflectionUtil.instantiateMessage(clazz, getFactory());
          Holder<StructureDefinition> previousLeaf = new Holder<StructureDefinition>();
          retVal = createStructureDefinition(message, previousLeaf);
          myStructureDefinitions.put(clazz, retVal);
        }
       
View Full Code Here

        "AL1|1||^PORK^|\r" +
        "AL1|2||^PENICILLIN^|";
   
    GenericParser parser = new GenericParser();
    parser.setValidationContext(new NoValidation());
    Message msg = parser.parse(msgString);
    System.out.println(msg.getClass().getName());
     
  }
View Full Code Here

     */
    protected Message doParse(String message, String version) throws HL7Exception, EncodingNotSupportedException {
       
        //try to instantiate a message object of the right class
        MessageStructure structure = getStructure(message);
        Message m = instantiateMessage(structure.messageStructure, version, structure.explicitlyDefined);

        parse(m, message);

        return m;
    }
View Full Code Here

TOP

Related Classes of model.Message

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.