Package ca.uhn.fhir.context

Examples of ca.uhn.fhir.context.BaseRuntimeChildDefinition


      }
    }

    @Override
    public void enteringNewElement(String theNamespace, String theChildName) throws DataFormatException {
      BaseRuntimeChildDefinition child;
      try {
        child = myDefinition.getChildByNameOrThrowDataFormatException(theChildName);
      } catch (DataFormatException e) {
        if (false) {// TODO: make this configurable
          throw e;
        }
        ourLog.warn(e.getMessage());
        push(new SwallowChildrenWholeState(getPreResourceState()));
        return;
      }
      BaseRuntimeElementDefinition<?> target = child.getChildByName(theChildName);
      if (target == null) {
        throw new DataFormatException("Found unexpected element '" + theChildName + "' in parent element '" + myDefinition.getName() + "'. Valid names are: " + child.getValidChildNames());
      }

      switch (target.getChildType()) {
      case COMPOSITE_DATATYPE: {
        BaseRuntimeElementCompositeDefinition<?> compositeTarget = (BaseRuntimeElementCompositeDefinition<?>) target;
        ICompositeDatatype newChildInstance = (ICompositeDatatype) compositeTarget.newInstance(child.getInstanceConstructorArguments());
        child.getMutator().addValue(myInstance, newChildInstance);
        ElementCompositeState newState = new ElementCompositeState(getPreResourceState(), compositeTarget, newChildInstance);
        push(newState);
        return;
      }
      case PRIMITIVE_DATATYPE: {
        RuntimePrimitiveDatatypeDefinition primitiveTarget = (RuntimePrimitiveDatatypeDefinition) target;
        IPrimitiveDatatype<?> newChildInstance;
        newChildInstance = primitiveTarget.newInstance(child.getInstanceConstructorArguments());
        child.getMutator().addValue(myInstance, newChildInstance);
        PrimitiveState newState = new PrimitiveState(getPreResourceState(), newChildInstance);
        push(newState);
        return;
      }
      case RESOURCE_REF: {
        RuntimeResourceReferenceDefinition resourceRefTarget = (RuntimeResourceReferenceDefinition) target;
        ResourceReferenceDt newChildInstance = new ResourceReferenceDt();
        getPreResourceState().getResourceReferences().add(newChildInstance);
        child.getMutator().addValue(myInstance, newChildInstance);
        ResourceReferenceState newState = new ResourceReferenceState(getPreResourceState(), newChildInstance);
        push(newState);
        return;
      }
      case RESOURCE_BLOCK: {
        RuntimeResourceBlockDefinition blockTarget = (RuntimeResourceBlockDefinition) target;
        IResourceBlock newBlockInstance = blockTarget.newInstance();
        child.getMutator().addValue(myInstance, newBlockInstance);
        ElementCompositeState newState = new ElementCompositeState(getPreResourceState(), blockTarget, newBlockInstance);
        push(newState);
        return;
      }
      case PRIMITIVE_XHTML: {
        RuntimePrimitiveDatatypeNarrativeDefinition xhtmlTarget = (RuntimePrimitiveDatatypeNarrativeDefinition) target;
        XhtmlDt newDt = xhtmlTarget.newInstance();
        child.getMutator().addValue(myInstance, newDt);
        XhtmlState state = new XhtmlState(getPreResourceState(), newDt, true);
        push(state);
        return;
      }
      case CONTAINED_RESOURCES: {
        RuntimeElemContainedResources targetElem = (RuntimeElemContainedResources) target;
        List<? extends IElement> values = child.getAccessor().getValues(myInstance);
        ContainedDt newDt;
        if (values == null || values.isEmpty() || values.get(0) == null) {
          newDt = targetElem.newInstance();
          child.getMutator().addValue(myInstance, newDt);
        } else {
          newDt = (ContainedDt) values.get(0);
        }
        ContainedResourcesState state = new ContainedResourcesState(getPreResourceState());
        push(state);
View Full Code Here


    return getDefinition(currentDef, subList);

  }

  private BaseRuntimeChildDefinition getDefinition(BaseRuntimeElementCompositeDefinition<?> theCurrentDef, List<String> theSubList) {
    BaseRuntimeChildDefinition nextDef = theCurrentDef.getChildByNameOrThrowDataFormatException(theSubList.get(0));

    if (theSubList.size() == 1) {
      return nextDef;
    } else {
      BaseRuntimeElementCompositeDefinition<?> cmp = (BaseRuntimeElementCompositeDefinition<?>) nextDef.getChildByName(theSubList.get(0));
      return getDefinition(cmp, theSubList.subList(1, theSubList.size()));
    }
  }
View Full Code Here

  }

  private List<Object> getValues(BaseRuntimeElementCompositeDefinition<?> theCurrentDef, Object theCurrentObj, List<String> theSubList) {
    String name = theSubList.get(0);
    BaseRuntimeChildDefinition nextDef = theCurrentDef.getChildByNameOrThrowDataFormatException(name);
    List<? extends IElement> values = nextDef.getAccessor().getValues(theCurrentObj);
    List<Object> retVal = new ArrayList<Object>();

    if (theSubList.size() == 1) {
      retVal.addAll(values);
    } else {
View Full Code Here

      }
    }

    @Override
    public void enteringNewElement(String theNamespace, String theChildName) throws DataFormatException {
      BaseRuntimeChildDefinition child;
      try {
        child = myDefinition.getChildByNameOrThrowDataFormatException(theChildName);
      } catch (DataFormatException e) {
        if (false) {// TODO: make this configurable
          throw e;
        }
        ourLog.warn(e.getMessage());
        push(new SwallowChildrenWholeState(getPreResourceState()));
        return;
      }
      BaseRuntimeElementDefinition<?> target = child.getChildByName(theChildName);
      if (target == null) {
        throw new DataFormatException("Found unexpected element '" + theChildName + "' in parent element '" + myDefinition.getName() + "'. Valid names are: " + child.getValidChildNames());
      }

      switch (target.getChildType()) {
      case COMPOSITE_DATATYPE: {
        BaseRuntimeElementCompositeDefinition<?> compositeTarget = (BaseRuntimeElementCompositeDefinition<?>) target;
        ICompositeDatatype newChildInstance = (ICompositeDatatype) compositeTarget.newInstance(child.getInstanceConstructorArguments());
        child.getMutator().addValue(myInstance, newChildInstance);
        ElementCompositeState newState = new ElementCompositeState(getPreResourceState(), compositeTarget, newChildInstance);
        push(newState);
        return;
      }
      case PRIMITIVE_DATATYPE: {
        RuntimePrimitiveDatatypeDefinition primitiveTarget = (RuntimePrimitiveDatatypeDefinition) target;
        IPrimitiveDatatype<?> newChildInstance;
        newChildInstance = primitiveTarget.newInstance(child.getInstanceConstructorArguments());
        child.getMutator().addValue(myInstance, newChildInstance);
        PrimitiveState newState = new PrimitiveState(getPreResourceState(), newChildInstance);
        push(newState);
        return;
      }
      case RESOURCE_REF: {
        RuntimeResourceReferenceDefinition resourceRefTarget = (RuntimeResourceReferenceDefinition) target;
        ResourceReferenceDt newChildInstance = new ResourceReferenceDt();
        getPreResourceState().getResourceReferences().add(newChildInstance);
        child.getMutator().addValue(myInstance, newChildInstance);
        ResourceReferenceState newState = new ResourceReferenceState(getPreResourceState(), newChildInstance);
        push(newState);
        return;
      }
      case RESOURCE_BLOCK: {
        RuntimeResourceBlockDefinition blockTarget = (RuntimeResourceBlockDefinition) target;
        IResourceBlock newBlockInstance = blockTarget.newInstance();
        child.getMutator().addValue(myInstance, newBlockInstance);
        ElementCompositeState newState = new ElementCompositeState(getPreResourceState(), blockTarget, newBlockInstance);
        push(newState);
        return;
      }
      case PRIMITIVE_XHTML: {
        RuntimePrimitiveDatatypeNarrativeDefinition xhtmlTarget = (RuntimePrimitiveDatatypeNarrativeDefinition) target;
        XhtmlDt newDt = xhtmlTarget.newInstance();
        child.getMutator().addValue(myInstance, newDt);
        XhtmlState state = new XhtmlState(getPreResourceState(), newDt, true);
        push(state);
        return;
      }
      case CONTAINED_RESOURCES: {
        RuntimeElemContainedResources targetElem = (RuntimeElemContainedResources) target;
        List<? extends IElement> values = child.getAccessor().getValues(myInstance);
        ContainedDt newDt;
        if (values == null || values.isEmpty() || values.get(0) == null) {
          newDt = targetElem.newInstance();
          child.getMutator().addValue(myInstance, newDt);
        } else {
          newDt = (ContainedDt) values.get(0);
        }
        ContainedResourcesState state = new ContainedResourcesState(getPreResourceState());
        push(state);
View Full Code Here

    return getDefinition(currentDef, subList);

  }

  private BaseRuntimeChildDefinition getDefinition(BaseRuntimeElementCompositeDefinition<?> theCurrentDef, List<String> theSubList) {
    BaseRuntimeChildDefinition nextDef = theCurrentDef.getChildByNameOrThrowDataFormatException(theSubList.get(0));

    if (theSubList.size() == 1) {
      return nextDef;
    } else {
      BaseRuntimeElementCompositeDefinition<?> cmp = (BaseRuntimeElementCompositeDefinition<?>) nextDef.getChildByName(theSubList.get(0));
      return getDefinition(cmp, theSubList.subList(1, theSubList.size()));
    }
  }
View Full Code Here

  }

  private List<Object> getValues(BaseRuntimeElementCompositeDefinition<?> theCurrentDef, Object theCurrentObj, List<String> theSubList) {
    String name = theSubList.get(0);
    BaseRuntimeChildDefinition nextDef = theCurrentDef.getChildByNameOrThrowDataFormatException(name);
    List<? extends IElement> values = nextDef.getAccessor().getValues(theCurrentObj);
    List<Object> retVal = new ArrayList<Object>();

    if (theSubList.size() == 1) {
      retVal.addAll(values);
    } else {
View Full Code Here

        String elementName = nextChild.getElementName();
        if (nextChild.getValidChildNames().size() > 1) {
          elementName = nextChild.getValidChildNames().iterator().next();
        }
       
        BaseRuntimeChildDefinition sourceChildEquivalent = theSourceDef.getChildByNameOrThrowDataFormatException(elementName);
        if (sourceChildEquivalent == null) {
          continue;
        }

        List<? extends IElement> sourceValues = sourceChildEquivalent.getAccessor().getValues(theSource);
        for (IElement nextElement : sourceValues) {
          nextChild.getMutator().addValue(theTarget, nextElement);
        }
      }
     
View Full Code Here

      }
    }

    @Override
    public void enteringNewElement(String theNamespace, String theChildName) throws DataFormatException {
      BaseRuntimeChildDefinition child;
      try {
        child = myDefinition.getChildByNameOrThrowDataFormatException(theChildName);
      } catch (DataFormatException e) {
        if (false) {// TODO: make this configurable
          throw e;
        }
        ourLog.warn(e.getMessage());
        push(new SwallowChildrenWholeState(getPreResourceState()));
        return;
      }
      BaseRuntimeElementDefinition<?> target = child.getChildByName(theChildName);
      if (target == null) {
        throw new DataFormatException("Found unexpected element '" + theChildName + "' in parent element '" + myDefinition.getName() + "'. Valid names are: " + child.getValidChildNames());
      }

      switch (target.getChildType()) {
      case COMPOSITE_DATATYPE: {
        BaseRuntimeElementCompositeDefinition<?> compositeTarget = (BaseRuntimeElementCompositeDefinition<?>) target;
        ICompositeDatatype newChildInstance = (ICompositeDatatype) compositeTarget.newInstance(child.getInstanceConstructorArguments());
        child.getMutator().addValue(myInstance, newChildInstance);
        ElementCompositeState newState = new ElementCompositeState(getPreResourceState(), compositeTarget, newChildInstance);
        push(newState);
        return;
      }
      case PRIMITIVE_DATATYPE: {
        RuntimePrimitiveDatatypeDefinition primitiveTarget = (RuntimePrimitiveDatatypeDefinition) target;
        IPrimitiveDatatype<?> newChildInstance;
        newChildInstance = primitiveTarget.newInstance(child.getInstanceConstructorArguments());
        child.getMutator().addValue(myInstance, newChildInstance);
        PrimitiveState newState = new PrimitiveState(getPreResourceState(), newChildInstance);
        push(newState);
        return;
      }
      case RESOURCE_REF: {
        RuntimeResourceReferenceDefinition resourceRefTarget = (RuntimeResourceReferenceDefinition) target;
        ResourceReferenceDt newChildInstance = new ResourceReferenceDt();
        getPreResourceState().getResourceReferences().add(newChildInstance);
        child.getMutator().addValue(myInstance, newChildInstance);
        ResourceReferenceState newState = new ResourceReferenceState(getPreResourceState(), newChildInstance);
        push(newState);
        return;
      }
      case RESOURCE_BLOCK: {
        RuntimeResourceBlockDefinition blockTarget = (RuntimeResourceBlockDefinition) target;
        IResourceBlock newBlockInstance = blockTarget.newInstance();
        child.getMutator().addValue(myInstance, newBlockInstance);
        ElementCompositeState newState = new ElementCompositeState(getPreResourceState(), blockTarget, newBlockInstance);
        push(newState);
        return;
      }
      case PRIMITIVE_XHTML: {
        RuntimePrimitiveDatatypeNarrativeDefinition xhtmlTarget = (RuntimePrimitiveDatatypeNarrativeDefinition) target;
        XhtmlDt newDt = xhtmlTarget.newInstance();
        child.getMutator().addValue(myInstance, newDt);
        XhtmlState state = new XhtmlState(getPreResourceState(), newDt, true);
        push(state);
        return;
      }
      case CONTAINED_RESOURCES: {
        RuntimeElemContainedResources targetElem = (RuntimeElemContainedResources) target;
        List<? extends IElement> values = child.getAccessor().getValues(myInstance);
        ContainedDt newDt;
        if (values == null || values.isEmpty() || values.get(0) == null) {
          newDt = targetElem.newInstance();
          child.getMutator().addValue(myInstance, newDt);
        } else {
          newDt = (ContainedDt) values.get(0);
        }
        ContainedResourcesState state = new ContainedResourcesState(getPreResourceState());
        push(state);
View Full Code Here

    return getValues(currentDef, currentObj, parts.subList(1, parts.size() ));

  }

  private List<Object> getValues(BaseRuntimeElementCompositeDefinition<?> theCurrentDef, Object theCurrentObj, List<String> theSubList) {
    BaseRuntimeChildDefinition nextDef = theCurrentDef.getChildByNameOrThrowDataFormatException(theSubList.get(0));
    List<? extends IElement> values = nextDef.getAccessor().getValues(theCurrentObj);
    List<Object> retVal = new ArrayList<Object>();

    if (theSubList.size() == 1) {
      retVal.addAll(values);
    } else {
View Full Code Here

      }
    }

    @Override
    public void enteringNewElement(String theNamespace, String theChildName) throws DataFormatException {
      BaseRuntimeChildDefinition child;
      try {
        child = myDefinition.getChildByNameOrThrowDataFormatException(theChildName);
      } catch (DataFormatException e) {
        if (false) {// TODO: make this configurable
          throw e;
        }
        ourLog.warn(e.getMessage());
        push(new SwallowChildrenWholeState(getPreResourceState()));
        return;
      }
      BaseRuntimeElementDefinition<?> target = child.getChildByName(theChildName);
      if (target == null) {
        throw new DataFormatException("Found unexpected element '" + theChildName + "' in parent element '" + myDefinition.getName() + "'. Valid names are: " + child.getValidChildNames());
      }

      switch (target.getChildType()) {
      case COMPOSITE_DATATYPE: {
        BaseRuntimeElementCompositeDefinition<?> compositeTarget = (BaseRuntimeElementCompositeDefinition<?>) target;
        ICompositeDatatype newChildInstance = (ICompositeDatatype) compositeTarget.newInstance(child.getInstanceConstructorArguments());
        child.getMutator().addValue(myInstance, newChildInstance);
        ElementCompositeState newState = new ElementCompositeState(getPreResourceState(), compositeTarget, newChildInstance);
        push(newState);
        return;
      }
      case PRIMITIVE_DATATYPE: {
        RuntimePrimitiveDatatypeDefinition primitiveTarget = (RuntimePrimitiveDatatypeDefinition) target;
        IPrimitiveDatatype<?> newChildInstance;
        newChildInstance = primitiveTarget.newInstance(child.getInstanceConstructorArguments());
        child.getMutator().addValue(myInstance, newChildInstance);
        PrimitiveState newState = new PrimitiveState(getPreResourceState(), newChildInstance);
        push(newState);
        return;
      }
      case RESOURCE_REF: {
        RuntimeResourceReferenceDefinition resourceRefTarget = (RuntimeResourceReferenceDefinition) target;
        ResourceReferenceDt newChildInstance = new ResourceReferenceDt();
        getPreResourceState().getResourceReferences().add(newChildInstance);
        child.getMutator().addValue(myInstance, newChildInstance);
        ResourceReferenceState newState = new ResourceReferenceState(getPreResourceState(), newChildInstance);
        push(newState);
        return;
      }
      case RESOURCE_BLOCK: {
        RuntimeResourceBlockDefinition blockTarget = (RuntimeResourceBlockDefinition) target;
        IResourceBlock newBlockInstance = blockTarget.newInstance();
        child.getMutator().addValue(myInstance, newBlockInstance);
        ElementCompositeState newState = new ElementCompositeState(getPreResourceState(), blockTarget, newBlockInstance);
        push(newState);
        return;
      }
      case PRIMITIVE_XHTML: {
        RuntimePrimitiveDatatypeNarrativeDefinition xhtmlTarget = (RuntimePrimitiveDatatypeNarrativeDefinition) target;
        XhtmlDt newDt = xhtmlTarget.newInstance();
        child.getMutator().addValue(myInstance, newDt);
        XhtmlState state = new XhtmlState(getPreResourceState(), newDt, true);
        push(state);
        return;
      }
      case CONTAINED_RESOURCES: {
        RuntimeElemContainedResources targetElem = (RuntimeElemContainedResources) target;
        List<? extends IElement> values = child.getAccessor().getValues(myInstance);
        ContainedDt newDt;
        if (values == null || values.isEmpty() || values.get(0) == null) {
          newDt = targetElem.newInstance();
          child.getMutator().addValue(myInstance, newDt);
        } else {
          newDt = (ContainedDt) values.get(0);
        }
        ContainedResourcesState state = new ContainedResourcesState(getPreResourceState());
        push(state);
View Full Code Here

TOP

Related Classes of ca.uhn.fhir.context.BaseRuntimeChildDefinition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.