@Override public String toString() { return "Component[" + getName() + "]"; }
protected List<HL7Exception> doTestComponent(Type type, Component profile, String profileID, boolean theValidateChildren) throws ProfileException, HL7Exception { List<HL7Exception> exList = new ArrayList<HL7Exception>(); exList.addAll(testType(type, profile, null, profileID)); // test children if (profile.getSubComponents() > 0 && !profile.getUsage().equals("X") && (!type.isEmpty())) { if (Composite.class.isAssignableFrom(type.getClass())) { Composite comp = (Composite) type; if (theValidateChildren) { for (int i = 1; i <= profile.getSubComponents(); i++) { SubComponent childProfile = profile.getSubComponent(i); try { Type child = comp.getComponent(i - 1); exList.addAll(testType(child, childProfile, null, profileID)); } catch (DataTypeException de) { exList.add(new ProfileNotHL7CompliantException( "More subcomponents in profile than allowed in message: " + de.getMessage())); } } } checkExtraComponents(comp, profile.getSubComponents(), exList); } else { exList.add(new ProfileNotFollowedException("A component has primitive type " + type.getClass().getName() + " but the profile defines subcomponents")); } } return exList; }
/** Parses a component profile */ private AbstractComponent<?> parseComponentProfile(Element elem, boolean isSubComponent) throws ProfileException { AbstractComponent<?> comp = null; if (isSubComponent) { log.debug(" Parsing subcomp profile: " + elem.getAttribute("Name")); comp = new SubComponent(); } else { log.debug(" Parsing comp profile: " + elem.getAttribute("Name")); comp = new Component(); int childIndex = 1; NodeList children = elem.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node n = children.item(i); if (n.getNodeType() == Node.ELEMENT_NODE) { Element child = (Element) n; if (child.getNodeName().equalsIgnoreCase("SubComponent")) { SubComponent subcomp = (SubComponent) parseComponentProfile(child, true); ((Component) comp).setSubComponent(childIndex++, subcomp); } } } } parseAbstractComponentData(comp, elem); return comp; }
protected List<HL7Exception> doTestComponent(Type type, Component profile, String profileID, boolean theValidateChildren) throws ProfileException, HL7Exception { List<HL7Exception> exList = new ArrayList<HL7Exception>(); exList.addAll(testType(type, profile, null, profileID)); // test children if (profile.getSubComponents() > 0 && !profile.getUsage().equals("X") && (!type.isEmpty())) { if (Composite.class.isAssignableFrom(type.getClass())) { Composite comp = (Composite) type; if (theValidateChildren) { for (int i = 1; i <= profile.getSubComponents(); i++) { SubComponent childProfile = profile.getSubComponent(i); try { Type child = comp.getComponent(i - 1); exList.addAll(testType(child, childProfile, null, profileID)); } catch (DataTypeException de) { exList.add(new ProfileNotHL7CompliantException( "More subcomponents in profile than allowed in message: " + de.getMessage())); } } } checkExtraComponents(comp, profile.getSubComponents(), exList); } else { exList.add(new ProfileNotFollowedException("A component has primitive type " + type.getClass().getName() + " but the profile defines subcomponents")); } } return exList; }
/** Parses a component profile */ private AbstractComponent<?> parseComponentProfile(Element elem, boolean isSubComponent) throws ProfileException { AbstractComponent<?> comp = null; if (isSubComponent) { log.debug(" Parsing subcomp profile: " + elem.getAttribute("Name")); comp = new SubComponent(); } else { log.debug(" Parsing comp profile: " + elem.getAttribute("Name")); comp = new Component(); int childIndex = 1; NodeList children = elem.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node n = children.item(i); if (n.getNodeType() == Node.ELEMENT_NODE) { Element child = (Element) n; if (child.getNodeName().equalsIgnoreCase("SubComponent")) { SubComponent subcomp = (SubComponent) parseComponentProfile(child, true); ((Component) comp).setSubComponent(childIndex++, subcomp); } } } } parseAbstractComponentData(comp, elem); return comp; }
@Override public String toString() { return "Component[" + getName() + "]"; }