001package org.hl7.fhir.dstu3.utils;
002
003import java.util.HashMap;
004import java.util.List;
005import java.util.Map;
006
007import org.hl7.fhir.dstu3.model.Base;
008import org.hl7.fhir.dstu3.model.TypeDetails;
009import org.hl7.fhir.exceptions.FHIRException;
010
011public class FHIRPathUtilityClasses {
012
013
014  public static class ExecutionContext {
015    private Object appInfo;
016    private Base resource;
017    private Base context;
018    private Base thisItem;
019    private Map<String, Base> aliases;
020
021    public ExecutionContext(Object appInfo, Base resource, Base context, Map<String, Base> aliases, Base thisItem) {
022      this.appInfo = appInfo;
023      this.context = context;
024      this.resource = resource;
025      this.aliases = aliases;
026      this.thisItem = thisItem;
027    }
028    public Base getResource() {
029      return resource;
030    }
031    public Base getThisItem() {
032      return thisItem;
033    }
034    public void addAlias(String name, List<Base> focus) throws FHIRException {
035      if (aliases == null)
036        aliases = new HashMap<String, Base>();
037      else
038        aliases = new HashMap<String, Base>(aliases); // clone it, since it's going to change
039      if (focus.size() > 1)
040        throw new FHIRException("Attempt to alias a collection, not a singleton");
041      aliases.put(name, focus.size() == 0 ? null : focus.get(0));
042    }
043    public Base getAlias(String name) {
044      return aliases == null ? null : aliases.get(name);
045    }
046    public Object getAppInfo() {
047      return appInfo;
048    }
049    public Base getContext() {
050      return context;
051    }
052    public Map<String, Base> getAliases() {
053      return aliases;
054    }
055    
056  }
057
058  public static class ExecutionTypeContext {
059    private Object appInfo;
060    private String resource;
061    private String context;
062    private TypeDetails thisItem;
063
064
065    public ExecutionTypeContext(Object appInfo, String resource, String context, TypeDetails thisItem) {
066      super();
067      this.appInfo = appInfo;
068      this.resource = resource;
069      this.context = context;
070      this.thisItem = thisItem;
071
072    }
073    public String getResource() {
074      return resource;
075    }
076    public TypeDetails getThisItem() {
077      return thisItem;
078    }
079    public Object getAppInfo() {
080      return appInfo;
081    }
082    public String getContext() {
083      return context;
084    }
085    
086    
087  }
088
089  public static class FunctionDetails {
090    private String description;
091    private int minParameters;
092    private int maxParameters;
093    public FunctionDetails(String description, int minParameters, int maxParameters) {
094      super();
095      this.description = description;
096      this.minParameters = minParameters;
097      this.maxParameters = maxParameters;
098    }
099    public String getDescription() {
100      return description;
101    }
102    public int getMinParameters() {
103      return minParameters;
104    }
105    public int getMaxParameters() {
106      return maxParameters;
107    }
108
109  }
110}