private void testPrimitiveRules(Message message, ValidationExceptionHandler<R> handler) throws HL7Exception { LOG.debug("Validating message against primitive type rules"); for (Iterator<Structure> iter = ReadOnlyMessageIterator .createPopulatedSegmentIterator(message); iter.hasNext();) { Segment s = (Segment) iter.next(); for (int field = 1; field <= s.numFields(); field++) { Type[] t = s.getField(field); for (int rep = 0; rep < t.length; rep++) { Location location = new Location(); location .withSegmentName(s.getName()) .withField(field) .withFieldRepetition(rep); testType(t[rep], handler, location); } } } }
private void testPrimitiveRules(Message message, ValidationExceptionHandler<R> handler) throws HL7Exception { LOG.debug("Validating message against primitive type rules"); for (Iterator<Structure> iter = ReadOnlyMessageIterator .createPopulatedSegmentIterator(message); iter.hasNext();) { Segment s = (Segment) iter.next(); for (int field = 1; field <= s.numFields(); field++) { Type[] t = s.getField(field); for (int rep = 0; rep < t.length; rep++) { Location location = new Location(); location .withSegmentName(s.getName()) .withField(field) .withFieldRepetition(rep); testType(t[rep], handler, location); } } } }
private void testType(Type type, ValidationExceptionHandler<R> handler, Location l) { if (type instanceof Composite) { Type[] components = ((Composite) type).getComponents(); for (int comp = 0; comp < components.length; comp++) { Location location = new Location(l).withComponent(comp + 1); testComponent(components[comp], handler, location); } } else if (type instanceof Varies) { testType(((Varies) type).getData(), handler, l); } else { testPrimitive((Primitive) type, handler, l); } }
private void testType(Type type, ValidationExceptionHandler<R> handler, Location l) { if (type instanceof Composite) { Type[] components = ((Composite) type).getComponents(); for (int comp = 0; comp < components.length; comp++) { Location location = new Location(l).withComponent(comp + 1); testComponent(components[comp], handler, location); } } else if (type instanceof Varies) { testType(((Varies) type).getData(), handler, l); } else { testPrimitive((Primitive) type, handler, l); } }