ca.uhn.hl7v2.conf.check
Class DefaultValidator

java.lang.Object
  extended by ca.uhn.hl7v2.conf.check.DefaultValidator
All Implemented Interfaces:
Validator

public class DefaultValidator
extends java.lang.Object
implements Validator

A default conformance validator.

Author:
Bryan Tripp

Constructor Summary
DefaultValidator()
          Creates a new instance of DefaultValidator
 
Method Summary
static void main(java.lang.String[] args)
           
protected  HL7Exception testCardinality(int reps, int min, int max, java.lang.String usage, java.lang.String name)
          Checks cardinality and creates an appropriate exception if out of bounds.
 HL7Exception[] testComponent(Type type, Component profile, java.lang.String profileID)
           
 HL7Exception[] testField(Type type, Field profile, boolean escape, java.lang.String profileID)
           
 HL7Exception[] testGroup(Group group, AbstractSegmentContainer profile, java.lang.String profileID)
          Tests a group against a group section of a profile.
 HL7Exception testLength(Type type, int maxLength)
          Tests whether the given type falls within a maximum length.
 HL7Exception[] testSegment(Segment segment, Seg profile, java.lang.String profileID)
          Tests a segment against a segment section of a profile.
 HL7Exception[] testStructure(Structure s, ProfileStructure profile, java.lang.String profileID)
          Tests a structure (segment or group) against the corresponding part of a profile.
 HL7Exception[] testType(Type type, AbstractComponent profile, java.lang.String encoded, java.lang.String profileID)
          Tests a Type against the corresponding section of a profile.
 HL7Exception[] validate(Message message, StaticDef profile)
          Validates the given message against the given static definition from a conformance profile.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultValidator

public DefaultValidator()
Creates a new instance of DefaultValidator

Method Detail

validate

public HL7Exception[] validate(Message message,
                               StaticDef profile)
                        throws ProfileException,
                               HL7Exception
Description copied from interface: Validator
Validates the given message against the given static definition from a conformance profile. Conformance profiles are XML representations of domain-specific constraints on a message (see HL7 2.5 section 2.12).

Specified by:
validate in interface Validator
Returns:
a list of exceptions representing points of non-conformance (may not be a complete list)
Throws:
ProfileException - if a problem is encountered that interferes with evaluation
HL7Exception
See Also:
Validator.validate(ca.uhn.hl7v2.model.Message, ca.uhn.hl7v2.conf.spec.message.StaticDef)

testGroup

public HL7Exception[] testGroup(Group group,
                                AbstractSegmentContainer profile,
                                java.lang.String profileID)
                         throws ProfileException
Tests a group against a group section of a profile.

Throws:
ProfileException

testCardinality

protected HL7Exception testCardinality(int reps,
                                       int min,
                                       int max,
                                       java.lang.String usage,
                                       java.lang.String name)
Checks cardinality and creates an appropriate exception if out of bounds. The usage code is needed because if min cardinality is > 0, the min # of reps is only required if the usage code is 'R' (see HL7 v2.5 section 2.12.6.4).

Parameters:
reps - the number of reps
min - the minimum number of reps
max - the maximum number of reps (-1 means *)
usage - the usage code
name - the name of the repeating structure (used in exception msg)
Returns:
null if cardinality OK, exception otherwise

testStructure

public HL7Exception[] testStructure(Structure s,
                                    ProfileStructure profile,
                                    java.lang.String profileID)
                             throws ProfileException
Tests a structure (segment or group) against the corresponding part of a profile.

Throws:
ProfileException

testSegment

public HL7Exception[] testSegment(Segment segment,
                                  Seg profile,
                                  java.lang.String profileID)
                           throws ProfileException
Tests a segment against a segment section of a profile.

Throws:
ProfileException

testType

public HL7Exception[] testType(Type type,
                               AbstractComponent profile,
                               java.lang.String encoded,
                               java.lang.String profileID)
Tests a Type against the corresponding section of a profile.

Parameters:
encoded - optional encoded form of type (if you want to specify this -- if null, default pipe-encoded form is used to check length and constant val)

testLength

public HL7Exception testLength(Type type,
                               int maxLength)
Tests whether the given type falls within a maximum length.

Returns:
null of OK, an HL7Exception otherwise

testField

public HL7Exception[] testField(Type type,
                                Field profile,
                                boolean escape,
                                java.lang.String profileID)
                         throws ProfileException
Throws:
ProfileException

testComponent

public HL7Exception[] testComponent(Type type,
                                    Component profile,
                                    java.lang.String profileID)
                             throws ProfileException
Throws:
ProfileException

main

public static void main(java.lang.String[] args)


Copyright © 2001-2011 University Health Network. All Rights Reserved.