@Override public String toString() { return getClass().getSimpleName() + "[" + getElementName() + "]"; }
private List<String> addNameToList(List<String> theCurrentList, BaseRuntimeChildDefinition theChildDefinition) { if (theChildDefinition == null) return null; if (theCurrentList == null || theCurrentList.isEmpty()) return new ArrayList<>(Arrays.asList(theChildDefinition.getElementName())); List<String> newList = new ArrayList<>(theCurrentList); newList.add(theChildDefinition.getElementName()); return newList; }
private static int findIndex(List<BaseRuntimeChildDefinition> theChildren, String theName, boolean theDefaultAtEnd) { int index = theDefaultAtEnd ? theChildren.size() : -1; for (ListIterator<BaseRuntimeChildDefinition> iter = theChildren.listIterator(); iter.hasNext(); ) { if (iter.next().getElementName().equals(theName)) { index = iter.previousIndex(); break; } } return index; }
public CompositeChildElement(CompositeChildElement theParent, BaseRuntimeChildDefinition theDef, boolean theSubResource) { myDef = theDef; myParent = theParent; myResDef = null; mySubResource = theSubResource; if (ourLog.isTraceEnabled()) { if (theParent != null) { StringBuilder path = theParent.buildPath(); if (path != null) { path.append('.'); path.append(myDef.getElementName()); ourLog.trace(" * Next path: {}", path.toString()); } } } }
protected void throwExceptionForUnknownChildType(BaseRuntimeChildDefinition nextChild, Class<? extends IBase> theType) { if (nextChild instanceof BaseRuntimeDeclaredChildDefinition) { StringBuilder b = new StringBuilder(); b.append(nextChild.getElementName()); b.append(" has type "); b.append(theType.getName()); b.append(" but this is not a valid type for this element"); if (nextChild instanceof RuntimeChildChoiceDefinition) { RuntimeChildChoiceDefinition choice = (RuntimeChildChoiceDefinition) nextChild; b.append(" - Expected one of: " + choice.getValidChildTypes()); } throw new DataFormatException(b.toString()); } throw new DataFormatException(nextChild + " has no child of type " + theType); }
private StringBuilder buildPath() { if (myResDef != null) { StringBuilder b = new StringBuilder(); b.append(myResDef.getName()); return b; } else if (myParent != null) { StringBuilder b = myParent.buildPath(); if (b != null && myDef != null) { b.append('.'); b.append(myDef.getElementName()); } return b; } else { return null; } }
private void addParent(CompositeChildElement theParent, StringBuilder theB) { if (theParent != null) { if (theParent.myResDef != null) { theB.append(theParent.myResDef.getName()); return; } if (theParent.myParent != null) { addParent(theParent.myParent, theB); } if (theParent.myDef != null) { if (theB.length() > 0) { theB.append('.'); } theB.append(theParent.myDef.getElementName()); } } }
thePathBuilder.append(myDef.getElementName()); String currentPath = thePathBuilder.toString(); boolean retVal = theElements.contains(currentPath);
b.append(nextValue.getClass().getSimpleName()); b.append("] which is not valid for field["); b.append(nextChild.getElementName()); b.append("] in "); b.append(childDef.getName());
for (BaseRuntimeChildDefinition next : myChildren) { if (next instanceof RuntimeChildChoiceDefinition) { String key = next.getElementName()+"[x]"; myNameToChild.put(key, next);
String newPath = thePath + "." + nextChildDef.getElementName();
if (theValues.isEmpty() && theMetaChildUncast.getElementName().equals("meta")) { BaseRuntimeElementDefinition<?> metaChild = theMetaChildUncast.getChildByName("meta"); if (IBaseMetaType.class.isAssignableFrom(metaChild.getImplementingClass())) {
String elementName = nextChild.getElementName(); if (nextChild.getValidChildNames().size() > 1) { elementName = nextChild.getValidChildNames().iterator().next();
if (nextChildElem.getDef().getElementName().equals("extension") || nextChildElem.getDef().getElementName().equals("modifierExtension") || nextChild instanceof RuntimeChildDeclaredExtensionDefinition) { if (!haveWrittenExtensions) {
private List<String> addNameToList(List<String> theCurrentList, BaseRuntimeChildDefinition theChildDefinition) { if (theChildDefinition == null) return null; if (theCurrentList == null || theCurrentList.isEmpty()) return new ArrayList<>(Arrays.asList(theChildDefinition.getElementName())); List<String> newList = new ArrayList<>(theCurrentList); newList.add(theChildDefinition.getElementName()); return newList; }
@Override public String toString() { return getClass().getSimpleName() + "[" + getElementName() + "]"; }
private static int findIndex(List<BaseRuntimeChildDefinition> theChildren, String theName, boolean theDefaultAtEnd) { int index = theDefaultAtEnd ? theChildren.size() : -1; for (ListIterator<BaseRuntimeChildDefinition> iter = theChildren.listIterator(); iter.hasNext(); ) { if (iter.next().getElementName().equals(theName)) { index = iter.previousIndex(); break; } } return index; }
private static void populateDetails(FhirContext theCtx, IBase theIssue, String theSeverity, String theDetails, String theLocation, String theCode) { BaseRuntimeElementCompositeDefinition<?> issueElement = (BaseRuntimeElementCompositeDefinition<?>) theCtx.getElementDefinition(theIssue.getClass()); BaseRuntimeChildDefinition detailsChild; detailsChild = issueElement.getChildByName("diagnostics"); BaseRuntimeChildDefinition codeChild = issueElement.getChildByName("code"); IPrimitiveType<?> codeElem = (IPrimitiveType<?>) codeChild.getChildByName("code").newInstance(codeChild.getInstanceConstructorArguments()); codeElem.setValueAsString(theCode); codeChild.getMutator().addValue(theIssue, codeElem); BaseRuntimeElementDefinition<?> stringDef = detailsChild.getChildByName(detailsChild.getElementName()); BaseRuntimeChildDefinition severityChild = issueElement.getChildByName("severity"); BaseRuntimeChildDefinition locationChild = issueElement.getChildByName("location"); IPrimitiveType<?> severityElem = (IPrimitiveType<?>) severityChild.getChildByName("severity").newInstance(severityChild.getInstanceConstructorArguments()); severityElem.setValueAsString(theSeverity); severityChild.getMutator().addValue(theIssue, severityElem); IPrimitiveType<?> string = (IPrimitiveType<?>) stringDef.newInstance(); string.setValueAsString(theDetails); detailsChild.getMutator().setValue(theIssue, string); if (isNotBlank(theLocation)) { IPrimitiveType<?> locationElem = (IPrimitiveType<?>) locationChild.getChildByName("location").newInstance(locationChild.getInstanceConstructorArguments()); locationElem.setValueAsString(theLocation); locationChild.getMutator().addValue(theIssue, locationElem); } }
if (nextChild.getElementName().equals("url") && theElement instanceof IBaseExtension) {
protected void throwExceptionForUnknownChildType(BaseRuntimeChildDefinition nextChild, Class<? extends IBase> theType) { if (nextChild instanceof BaseRuntimeDeclaredChildDefinition) { StringBuilder b = new StringBuilder(); b.append(nextChild.getElementName()); b.append(" has type "); b.append(theType.getName()); b.append(" but this is not a valid type for this element"); if (nextChild instanceof RuntimeChildChoiceDefinition) { RuntimeChildChoiceDefinition choice = (RuntimeChildChoiceDefinition) nextChild; b.append(" - Expected one of: " + choice.getValidChildTypes()); } throw new DataFormatException(b.toString()); } throw new DataFormatException(nextChild + " has no child of type " + theType); }