final Type[] types = ((Composite) field).getComponents(); for (int i = 0; i < types.length; i++) { final Type type = types[i];
/** * Tests for extra components (i.e. any not defined in the profile) */ protected List<ValidationException> checkUndefinedComponents(Composite comp, int numInProfile) { List<ValidationException> exList = new ArrayList<>(); StringBuilder extra = new StringBuilder(); for (int i = numInProfile; i < comp.getComponents().length; i++) { try { String s = comp.getComponent(i).encode(); if (s.length() > 0) { extra.append(s).append(enc.getComponentSeparator()); } } catch (HL7Exception de) { exList.add(new ValidationException(de)); } } profileViolatedWhen(extra.toString().length() > 0, exList, COMPONENT_NOT_DEFINED_IN_PROFILE, extra.toString()); return exList; }
datatypeElement.getLocalName(), compNum); Type nextComponent = datatypeObject.getComponent(compNum); parse(nextComponent, nextElement); compNum++; Type[] children = datatypeObject.getComponents(); for (int i = 0; i < children.length; i++) { NodeList matchingElements = datatypeElement.getElementsByTagNameNS(NS, makeElementName( NodeList matchingElements = datatypeElement.getElementsByTagNameNS(NS, makeElementName(datatypeObject, children.length + nextExtraCmpIndex + 1)); if (matchingElements.getLength() > 0) { parse(datatypeObject.getExtraComponents().getComponent(nextExtraCmpIndex), (Element) matchingElements.item(0)); foundExtraComponent = true;
public Type getComponent(int number) throws DataTypeException { Type type = getDelegate().getComponent(number); return unmodifiableType(type); }
@Override public boolean end(Composite type, Location location) throws HL7Exception { return !type.isEmpty() && super.end(type, location); }
/** Returns the expected XML element name for the given child of the given Composite */ private String makeElementName(Composite composite, int child) { return composite.getName() + "." + child; }
/** Tests for extra components (ie any not defined in the profile) */ protected void checkExtraComponents(Composite comp, int numInProfile, List<HL7Exception> exList) throws ProfileException { StringBuilder extra = new StringBuilder(); for (int i = numInProfile; i < comp.getComponents().length; i++) { try { String s = PipeParser.encode(comp.getComponent(i), enc); if (s.length() > 0) { extra.append(s).append(enc.getComponentSeparator()); } } catch (DataTypeException de) { throw new ProfileException("Problem testing against profile", de); } } if (extra.length() > 0) { exList.add(new XElementPresentException( "The following components are not defined in the profile: " + extra.toString())); } }
datatypeElement.getLocalName(), compNum); Type nextComponent = datatypeObject.getComponent(compNum); parse(nextComponent, nextElement); compNum++; Type[] children = datatypeObject.getComponents(); for (int i = 0; i < children.length; i++) { NodeList matchingElements = datatypeElement.getElementsByTagNameNS(NS, makeElementName( NodeList matchingElements = datatypeElement.getElementsByTagNameNS(NS, makeElementName(datatypeObject, children.length + nextExtraCmpIndex + 1)); if (matchingElements.getLength() > 0) { parse(datatypeObject.getExtraComponents().getComponent(nextExtraCmpIndex), (Element) matchingElements.item(0)); foundExtraComponent = true;
public Type getComponent(int number) throws DataTypeException { Type type = getDelegate().getComponent(number); return unmodifiableType(type); }
@Override public final boolean start(Composite type, Location location) throws HL7Exception { return !type.isEmpty() && super.start(type, location); }
/** Returns the expected XML element name for the given child of the given Composite */ private String makeElementName(Composite composite, int child) { return composite.getName() + "." + child; }
public HapiField(final Type type) { this.value = PipeParser.encode(type, EncodingCharacters.defaultInstance()); final List<HL7Component> componentList = new ArrayList<>(); if (type instanceof Composite) { final Composite composite = (Composite) type; for (final Type component : composite.getComponents()) { componentList.add(new HapiField(component)); } } final ExtraComponents extra = type.getExtraComponents(); if (extra != null && extra.numComponents() > 0) { final String singleFieldValue; if (type instanceof Primitive) { singleFieldValue = ((Primitive) type).getValue(); } else { singleFieldValue = this.value; } componentList.add(new SingleValueField(singleFieldValue)); for (int i = 0; i < extra.numComponents(); i++) { componentList.add(new HapiField(extra.getComponent(i))); } } this.components = Collections.unmodifiableList(componentList); }
/** Tests for extra components (ie any not defined in the profile) */ protected void checkExtraComponents(Composite comp, int numInProfile, List<HL7Exception> exList) throws ProfileException { StringBuilder extra = new StringBuilder(); for (int i = numInProfile; i < comp.getComponents().length; i++) { try { String s = PipeParser.encode(comp.getComponent(i), enc); if (s.length() > 0) { extra.append(s).append(enc.getComponentSeparator()); } } catch (DataTypeException de) { throw new ProfileException("Problem testing against profile", de); } } if (extra.length() > 0) { exList.add(new XElementPresentException( "The following components are not defined in the profile: " + extra.toString())); } }
private static void setFirstComponentPrimitiveValue(Varies v, String theValue) throws DataTypeException { Composite c = (Composite) v.getData(); Type firstComponent = c.getComponent(0); setFirstComponentPrimitiveValue(firstComponent, theValue); }
@Override public final boolean start(Composite type, Location location) throws HL7Exception { return !type.isEmpty() && super.start(type, location); }
public Type[] getComponents() { Type[] types = getDelegate().getComponents(); Type[] unmodifiableTypes = new Type[types.length]; if (types.length > 0) { for (int i = 0; i < types.length; i++) { unmodifiableTypes[i] = unmodifiableType(types[i]); } } return unmodifiableTypes; }
/** * Returns an array containing the subcomponents within the first component of this Varies * object only if there are more than one of them. Otherwise, returns null. */ private static Type[] getFirstComponentSubcomponentsOnlyIfMoreThanOne(Varies v) throws DataTypeException { if (v.getData() instanceof Composite) { Composite c = (Composite) v.getData(); Type firstComponent = c.getComponent(0); if (firstComponent instanceof Varies) { Varies firstComponentVaries = (Varies) firstComponent; if (firstComponentVaries.getData() instanceof Composite) { return ((Composite)firstComponentVaries.getData()).getComponents(); } } } return null; } }
private static void setFirstComponentPrimitiveValue(Varies v, String theValue) throws DataTypeException { Composite c = (Composite) v.getData(); Type firstComponent = c.getComponent(0); setFirstComponentPrimitiveValue(firstComponent, theValue); }
@Override public boolean end(Composite type, Location location) throws HL7Exception { return !type.isEmpty() && super.end(type, location); }
public Type[] getComponents() { Type[] types = getDelegate().getComponents(); Type[] unmodifiableTypes = new Type[types.length]; if (types.length > 0) { for (int i = 0; i < types.length; i++) { unmodifiableTypes[i] = unmodifiableType(types[i]); } } return unmodifiableTypes; }