Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2014 the original author or authors.
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 package org.openehealth.ipf.commons.ihe.hl7v2.definitions;
 
This factory creates HapiContext instances that are required to derive ca.uhn.hl7v2.parser.ModelClassFactory and ca.uhn.hl7v2.validation.ValidationContext valid for the given HL7v2 transaction.

By default, the HapiContext defines the transaction-specific conformance profile and profile store, and disables validation during parsing.

 
 public class HapiContextFactory {
 
     private static IDGenerator idGenerator = new FileBasedHiLoGenerator();

    
Allows to globally set the ca.uhn.hl7v2.util.idgenerator.IDGenerator that generates IDs for new HL7 messages from new HapiContext instances. This does not affect the ID generation of already created HapiContexts nor does it do any cleanup of the previous generator.

Parameters:
generator global ID generator
 
     public static synchronized void setIdGenerator(IDGenerator generator) {
          = generator;
     }

    
Returns a default HapiContext

Returns:
default HapiContext
 
     public static HapiContext createHapiContext() {
         return new DefaultHapiContext();
     }

    
Returns a HapiContext for the provided model class factory

Parameters:
modelClassFactory model clas factory
Returns:
HapiContext
 
     public static HapiContext createHapiContext(ModelClassFactory modelClassFactory) {
         return createHapiContext(
                 modelClassFactory,
                 new DefaultValidationWithoutTNBuilder(),
                 ProfileStoreFactory.getProfileStore());
     }

    
Returns a HapiContext for the provided HL7v2 transaction, using a default HL7 model

Parameters:
transactions profile enumeration
Returns:
HapiContext
 
     public static HapiContext createHapiContext(HL7v2Transactions transactions) {
         return createHapiContext(
                 new DefaultModelClassFactory(),
                 transactions);
     }


    
Returns a HapiContext for the provided HL7v2 transaction, using a custom HL7 model.

Parameters:
modelClassFactory transaction-specific model-class factory
transactions profile enumeration
Returns:
HapiContext
    public static HapiContext createHapiContext(ModelClassFactory modelClassFactoryHL7v2Transactions transactions) {
        return createHapiContext(
                modelClassFactory,
                new ConformanceProfileBasedValidationBuilder(transactions),
                new GazelleProfileStore());
    }

    

Parameters:
modelClassFactory transaction-specific model-class factory
validationRuleBuilder validation rule builder
profileStore profile store
Returns:
HapiContext
    public static HapiContext createHapiContext(ModelClassFactory modelClassFactoryValidationRuleBuilder validationRuleBuilderProfileStore profileStore) {
        HapiContext context = new DefaultHapiContext(modelClassFactory);
        context.setProfileStore(profileStore);
        context.setValidationRuleBuilder(validationRuleBuilder);
        context.getParserConfiguration().setValidating(false);
        return context;
    }
New to GrepCode? Check out our FAQ X