001package org.hl7.fhir.r5.elementmodel;
002
003/*-
004 * #%L
005 * org.hl7.fhir.r5
006 * %%
007 * Copyright (C) 2014 - 2019 Health Level 7
008 * %%
009 * Licensed under the Apache License, Version 2.0 (the "License");
010 * you may not use this file except in compliance with the License.
011 * You may obtain a copy of the License at
012 * 
013 *      http://www.apache.org/licenses/LICENSE-2.0
014 * 
015 * Unless required by applicable law or agreed to in writing, software
016 * distributed under the License is distributed on an "AS IS" BASIS,
017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018 * See the License for the specific language governing permissions and
019 * limitations under the License.
020 * #L%
021 */
022
023import java.util.ArrayList;
024import java.util.Collections;
025import java.util.Comparator;
026import java.util.HashMap;
027import java.util.HashSet;
028import java.util.List;
029import java.util.Map;
030import java.util.Set;
031
032import org.apache.commons.lang3.Validate;
033import org.hl7.fhir.exceptions.FHIRException;
034import org.hl7.fhir.r5.conformance.ProfileUtilities;
035import org.hl7.fhir.r5.model.Base;
036import org.hl7.fhir.r5.model.ElementDefinition;
037import org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent;
038import org.hl7.fhir.r5.model.Enumerations.BindingStrength;
039import org.hl7.fhir.r5.model.ICoding;
040import org.hl7.fhir.r5.model.StringType;
041import org.hl7.fhir.r5.model.StructureDefinition;
042import org.hl7.fhir.r5.model.TypeConvertor;
043import org.hl7.fhir.r5.model.DataType;
044import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent;
045import org.hl7.fhir.r5.terminologies.ValueSetExpander.ValueSetExpansionOutcome;
046import org.hl7.fhir.utilities.ElementDecoration;
047import org.hl7.fhir.utilities.ElementDecoration.DecorationType;
048import org.hl7.fhir.utilities.Utilities;
049import org.hl7.fhir.utilities.xhtml.XhtmlNode;
050
051/**
052 * This class represents the underlying reference model of FHIR
053 * 
054 * A resource is nothing but a set of elements, where every element has a 
055 * name, maybe a stated type, maybe an id, and either a value or child elements 
056 * (one or the other, but not both or neither)
057 * 
058 * @author Grahame Grieve
059 *
060 */
061public class Element extends Base {
062
063
064  public enum SpecialElement {
065                CONTAINED, BUNDLE_ENTRY, BUNDLE_OUTCOME, PARAMETER;
066
067    public static SpecialElement fromProperty(Property property) {
068      if (property.getStructure().getIdElement().getIdPart().equals("Parameters"))
069        return PARAMETER;
070      if (property.getStructure().getIdElement().getIdPart().equals("Bundle") && property.getName().equals("resource"))
071        return BUNDLE_ENTRY;
072      if (property.getStructure().getIdElement().getIdPart().equals("Bundle") && property.getName().equals("outcome"))
073        return BUNDLE_OUTCOME;
074      if (property.getName().equals("contained")) 
075        return CONTAINED;
076      throw new Error("Unknown resource containing a native resource: "+property.getDefinition().getId());
077    }
078        }
079
080        private List<String> comments;// not relevant for production, but useful in documentation
081        private String name;
082        private String type;
083        private String value;
084        private int index = -1;
085        private List<Element> children;
086        private Property property;
087  private Property elementProperty; // this is used when special is set to true - it tracks the underlying element property which is used in a few places
088        private int line;
089        private int col;
090        private SpecialElement special;
091        private XhtmlNode xhtml; // if this is populated, then value will also hold the string representation
092        private String explicitType; // for xsi:type attribute
093
094        public Element(String name) {
095                super();
096                this.name = name;
097        }
098
099  public Element(Element other) {
100    super();
101    name = other.name;
102    type = other.type;
103    property = other.property;
104    elementProperty = other.elementProperty;
105    special = other.special;
106  }
107  
108  public Element(String name, Property property) {
109                super();
110                this.name = name;
111                this.property = property;
112        }
113
114        public Element(String name, Property property, String type, String value) {
115                super();
116                this.name = name;
117                this.property = property;
118                this.type = type;
119                this.value = value;
120        }
121
122        public void updateProperty(Property property, SpecialElement special, Property elementProperty) {
123                this.property = property;
124    this.elementProperty = elementProperty;
125                this.special = special;
126        }
127
128        public SpecialElement getSpecial() {
129                return special;
130        }
131
132        public String getName() {
133                return name;
134        }
135
136        public String getType() {
137                if (type == null)
138                        return property.getType(name);
139                else
140                  return type;
141        }
142
143        public String getValue() {
144                return value;
145        }
146
147        public boolean hasChildren() {
148                return !(children == null || children.isEmpty());
149        }
150
151        public List<Element> getChildren() {
152                if (children == null)
153                        children = new ArrayList<Element>();
154                return children;
155        }
156
157        public boolean hasComments() {
158                return !(comments == null || comments.isEmpty());
159        }
160
161        public List<String> getComments() {
162                if (comments == null)
163                        comments = new ArrayList<String>();
164                return comments;
165        }
166
167        public Property getProperty() {
168                return property;
169        }
170
171        public void setValue(String value) {
172                this.value = value;
173        }
174
175        public void setType(String type) {
176                this.type = type;
177
178        }
179
180        public boolean hasValue() {
181                return value != null;
182        }
183
184        public List<Element> getChildrenByName(String name) {
185                List<Element> res = new ArrayList<Element>();
186                if (hasChildren()) {
187                        for (Element child : children)
188                                if (name.equals(child.getName()))
189                                        res.add(child);
190                }
191                return res;
192        }
193
194        public void numberChildren() {
195                if (children == null)
196                        return;
197                
198                String last = "";
199                int index = 0;
200                for (Element child : children) {
201                        if (child.getProperty().isList()) {
202                          if (last.equals(child.getName())) {
203                                index++;
204                          } else {
205                                last = child.getName();
206                                index = 0;
207                          }
208                        child.index = index;
209                        } else {
210                                child.index = -1;
211                        }
212                        child.numberChildren();
213                }       
214        }
215
216        public int getIndex() {
217                return index;
218        }
219
220        public boolean hasIndex() {
221                return index > -1;
222        }
223
224        public void setIndex(int index) {
225                this.index = index;
226        }
227
228        public String getChildValue(String name) {
229                if (children == null)
230                        return null;
231                for (Element child : children) {
232                        if (name.equals(child.getName()))
233                                return child.getValue();
234                }
235        return null;
236        }
237
238  public void setChildValue(String name, String value) {
239    if (children == null)
240      children = new ArrayList<Element>();
241    for (Element child : children) {
242      if (name.equals(child.getName())) {
243        if (!child.isPrimitive())
244          throw new Error("Cannot set a value of a non-primitive type ("+name+" on "+this.getName()+")");
245        child.setValue(value);
246      }
247    }
248    try {
249      setProperty(name.hashCode(), name, new StringType(value));
250    } catch (FHIRException e) {
251      throw new Error(e);
252    }
253  }
254
255        public List<Element> getChildren(String name) {
256                List<Element> res = new ArrayList<Element>(); 
257                if (children != null)
258                for (Element child : children) {
259                        if (name.equals(child.getName()))
260                                res.add(child);
261                }
262                return res;
263        }
264
265  public boolean hasType() {
266    if (type == null)
267      return property.hasType(name);
268    else
269      return true;
270  }
271
272  @Override
273  public String fhirType() {
274    return getType();
275  }
276
277  @Override
278        public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
279        if (isPrimitive() && (hash == "value".hashCode()) && !Utilities.noString(value)) {
280//              String tn = getType();
281//              throw new Error(tn+" not done yet");
282          Base[] b = new Base[1];
283          b[0] = new StringType(value);
284          return b;
285        }
286                
287        List<Base> result = new ArrayList<Base>();
288        if (children != null) {
289        for (Element child : children) {
290                if (child.getName().equals(name))
291                        result.add(child);
292                if (child.getName().startsWith(name) && child.getProperty().isChoice() && child.getProperty().getName().equals(name+"[x]"))
293                        result.add(child);
294        }
295        }
296        if (result.isEmpty() && checkValid) {
297//              throw new FHIRException("not determined yet");
298        }
299        return result.toArray(new Base[result.size()]);
300        }
301
302        @Override
303        protected void listChildren(List<org.hl7.fhir.r5.model.Property> childProps) {
304          if (children != null) {
305            Map<String, org.hl7.fhir.r5.model.Property> map = new HashMap<String, org.hl7.fhir.r5.model.Property>();
306            for (Element c : children) {
307              org.hl7.fhir.r5.model.Property p = map.get(c.getName());
308              if (p == null) {
309              p = new org.hl7.fhir.r5.model.Property(c.getName(), c.fhirType(), c.getProperty().getDefinition().getDefinition(), c.getProperty().getDefinition().getMin(), maxToInt(c.getProperty().getDefinition().getMax()), c);
310          childProps.add(p);
311          map.put(c.getName(), p);
312              
313              } else
314                p.getValues().add(c);
315            }
316          }
317        }
318        
319  @Override
320  public Base setProperty(int hash, String name, Base value) throws FHIRException {
321    if ("xhtml".equals(getType()) && (hash == "value".hashCode())) {
322      this.xhtml = TypeConvertor.castToXhtml(value);
323      this.value =  TypeConvertor.castToXhtmlString(value);
324      return this;
325    }
326    if (isPrimitive() && (hash == "value".hashCode())) {
327      this.value = TypeConvertor.castToString(value).asStringValue();
328      return this;
329    }
330    
331    if (!value.isPrimitive() && !(value instanceof Element)) {
332      if (isDataType(value)) 
333        value = convertToElement(property.getChild(name), value);
334      else
335        throw new FHIRException("Cannot set property "+name+" on "+this.name+" - value is not a primitive type ("+value.fhirType()+") or an ElementModel type");
336    }
337    
338    if (children == null)
339      children = new ArrayList<Element>();
340    Element childForValue = null;
341    
342    // look through existing children
343    for (Element child : children) {
344      if (child.getName().equals(name)) {
345        if (!child.isList()) {
346          childForValue = child;
347          break;
348        } else {
349          Element ne = new Element(child);
350          children.add(ne);
351          numberChildren();
352          childForValue = ne;
353          break;
354        }
355      }
356    }
357
358    int i = 0;
359    if (childForValue == null)
360      for (Property p : property.getChildProperties(this.name, type)) {
361        int t = -1;
362        for (int c =0; c < children.size(); c++) {
363          Element e = children.get(c);
364          if (p.getName().equals(e.getName()))
365            t = c;
366        }
367        if (t > i)
368          i = t;
369        if (p.getName().equals(name) || p.getName().equals(name+"[x]")) {
370          Element ne = new Element(name, p);
371          children.add(i, ne);
372          childForValue = ne;
373          break;
374        }
375      }
376    
377    if (childForValue == null)
378      throw new Error("Cannot set property "+name+" on "+this.name);
379    else if (value.isPrimitive()) {
380      if (childForValue.property.getName().endsWith("[x]"))
381        childForValue.name = name+Utilities.capitalize(value.fhirType());
382      childForValue.setValue(value.primitiveValue());
383    } else {
384      Element ve = (Element) value;
385      childForValue.type = ve.getType();
386      if (childForValue.property.getName().endsWith("[x]"))
387        childForValue.name = name+Utilities.capitalize(childForValue.type);
388      else if (value.isResource()) {
389        if (childForValue.elementProperty == null)
390          childForValue.elementProperty = childForValue.property;
391        childForValue.property = ve.property;
392        childForValue.special = SpecialElement.BUNDLE_ENTRY;
393      }
394      if (ve.children != null) {
395        if (childForValue.children == null)
396          childForValue.children = new ArrayList<Element>();
397        else 
398          childForValue.children.clear();
399        childForValue.children.addAll(ve.children);
400      }
401    }
402    return childForValue;
403  }
404
405  private Base convertToElement(Property prop, Base v) throws FHIRException {
406    return new ObjectConverter(property.getContext()).convert(prop, (DataType) v);
407  }
408
409  private boolean isDataType(Base v) {
410    return v instanceof DataType &&  property.getContext().getTypeNames().contains(v.fhirType());
411  }
412
413  @Override
414  public Base makeProperty(int hash, String name) throws FHIRException {
415    if (isPrimitive() && (hash == "value".hashCode())) {
416      return new StringType(value);
417    }
418
419    if (children == null)
420      children = new ArrayList<Element>();
421    
422    // look through existing children
423    for (Element child : children) {
424      if (child.getName().equals(name)) {
425        if (!child.isList()) {
426          return child;
427        } else {
428          Element ne = new Element(child);
429          children.add(ne);
430          numberChildren();
431          return ne;
432        }
433      }
434    }
435
436    for (Property p : property.getChildProperties(this.name, type)) {
437      if (p.getName().equals(name)) {
438        Element ne = new Element(name, p);
439        children.add(ne);
440        return ne;
441      }
442    }
443      
444    throw new Error("Unrecognised name "+name+" on "+this.name); 
445  }
446  
447        private int maxToInt(String max) {
448    if (max.equals("*"))
449      return Integer.MAX_VALUE;
450    else
451      return Integer.parseInt(max);
452        }
453
454        @Override
455        public boolean isPrimitive() {
456                return type != null ? property.isPrimitive(type) : property.isPrimitive(property.getType(name));
457        }
458        
459  @Override
460  public boolean isBooleanPrimitive() {
461    return isPrimitive() && ("boolean".equals(type) || "boolean".equals(property.getType(name)));
462  }
463 
464  @Override
465  public boolean isResource() {
466    return property.isResource();
467  }
468  
469
470        @Override
471        public boolean hasPrimitiveValue() {
472                return property.isPrimitiveName(name) || property.IsLogicalAndHasPrimitiveValue(name);
473        }
474        
475
476        @Override
477        public String primitiveValue() {
478                if (isPrimitive())
479                  return value;
480                else {
481                        if (hasPrimitiveValue() && children != null) {
482                                for (Element c : children) {
483                                        if (c.getName().equals("value"))
484                                                return c.primitiveValue();
485                                }
486                        }
487                        return null;
488                }
489        }
490        
491        // for the validator
492  public int line() {
493    return line;
494  }
495
496  public int col() {
497    return col;
498  }
499
500        public Element markLocation(int line, int col) {
501                this.line = line;
502                this.col = col; 
503                return this;
504        }
505
506        public void clearDecorations() {
507          clearUserData("fhir.decorations");
508          for (Element e : children)
509            e.clearDecorations();         
510        }
511        
512        public void markValidation(StructureDefinition profile, ElementDefinition definition) {
513          @SuppressWarnings("unchecked")
514    List<ElementDecoration> decorations = (List<ElementDecoration>) getUserData("fhir.decorations");
515          if (decorations == null) {
516            decorations = new ArrayList<>();
517            setUserData("fhir.decorations", decorations);
518          }
519          decorations.add(new ElementDecoration(DecorationType.TYPE, profile.getUserString("path"), definition.getPath()));
520          if (definition.getId() != null && tail(definition.getId()).contains(":")) {
521            String[] details = tail(definition.getId()).split(":");
522            decorations.add(new ElementDecoration(DecorationType.SLICE, null, details[1]));
523          }
524        }
525        
526  private String tail(String id) {
527    return id.contains(".") ? id.substring(id.lastIndexOf(".")+1) : id;
528  }
529
530  public Element getNamedChild(String name) {
531          if (children == null)
532                return null;
533          Element result = null;
534          for (Element child : children) {
535                if (child.getName().equals(name)) {
536                        if (result == null)
537                                result = child;
538                        else 
539                                throw new Error("Attempt to read a single element when there is more than one present ("+name+")");
540                }
541          }
542          return result;
543        }
544
545  public void getNamedChildren(String name, List<Element> list) {
546        if (children != null)
547                for (Element child : children) 
548                        if (child.getName().equals(name))
549                                list.add(child);
550  }
551
552  public String getNamedChildValue(String name) {
553        Element child = getNamedChild(name);
554        return child == null ? null : child.value;
555  }
556
557  public void getNamedChildrenWithWildcard(String string, List<Element> values) {
558          Validate.isTrue(string.endsWith("[x]"));
559          
560          String start = string.substring(0, string.length() - 3);
561                if (children != null) {
562                        for (Element child : children) { 
563                                if (child.getName().startsWith(start)) {
564                                        values.add(child);
565                                }
566                        }
567                }
568  }
569
570  
571        public XhtmlNode getXhtml() {
572                return xhtml;
573        }
574
575        public Element setXhtml(XhtmlNode xhtml) {
576                this.xhtml = xhtml;
577                return this;
578        }
579
580        @Override
581        public boolean isEmpty() {
582        // GG: this used to also test !"".equals(value). 
583    // the condition where "" is empty and there are no children is an error, and so this really only manifested as an issue in corner cases technical testing of the validator / FHIRPath.
584          // it should not cause any problems in real life.
585                if (value != null) {   
586                        return false;
587                }
588                for (Element next : getChildren()) {
589                        if (!next.isEmpty()) {
590                                return false;
591                        }
592                }
593                return true;
594        }
595
596  public Property getElementProperty() {
597    return elementProperty;
598  }
599
600  public boolean hasElementProperty() {
601    return elementProperty != null;
602  }
603
604  public boolean hasChild(String name) {
605    return getNamedChild(name) != null;
606  }
607
608  public boolean hasChildren(String name) {
609    if (children != null)
610      for (Element child : children) 
611        if (child.getName().equals(name))
612          return true;
613    return false;
614  }
615
616  @Override
617  public String toString() {
618    return name+"="+fhirType() + "["+(children == null || hasValue() ? value : Integer.toString(children.size())+" children")+"]";
619  }
620
621  @Override
622  public String getIdBase() {
623    return getChildValue("id");
624  }
625
626  @Override
627  public void setIdBase(String value) {
628    setChildValue("id", value);
629  }
630
631
632  @Override
633  public boolean equalsDeep(Base other) {
634    if (!super.equalsDeep(other))
635      return false;
636    if (isPrimitive() && other.isPrimitive())
637      return primitiveValue().equals(other.primitiveValue());
638    if (isPrimitive() || other.isPrimitive())
639      return false;
640    Set<String> processed  = new HashSet<String>();
641    for (org.hl7.fhir.r5.model.Property p : children()) {
642      String name = p.getName();
643      processed.add(name);
644      org.hl7.fhir.r5.model.Property o = other.getChildByName(name);
645      if (!equalsDeep(p, o))
646        return false;
647    }
648    for (org.hl7.fhir.r5.model.Property p : children()) {
649      String name = p.getName();
650      if (!processed.contains(name)) {
651        org.hl7.fhir.r5.model.Property o = other.getChildByName(name);
652        if (!equalsDeep(p, o))
653          return false;
654      }
655    }
656    return true;
657  }
658
659  private boolean equalsDeep(org.hl7.fhir.r5.model.Property p, org.hl7.fhir.r5.model.Property o) {
660    if (o == null || p == null)
661      return false;
662    if (p.getValues().size() != o.getValues().size())
663      return false;
664    for (int i = 0; i < p.getValues().size(); i++)
665      if (!Base.compareDeep(p.getValues().get(i), o.getValues().get(i), true))
666        return false;
667    return true;
668  }
669
670  @Override
671  public boolean equalsShallow(Base other) {
672    if (!super.equalsShallow(other))
673      return false;
674    if (isPrimitive() && other.isPrimitive())
675      return primitiveValue().equals(other.primitiveValue());
676    if (isPrimitive() || other.isPrimitive())
677      return false;
678    return true; //?
679  }
680
681  public DataType asType() throws FHIRException {
682    return new ObjectConverter(property.getContext()).convertToType(this);
683  }
684
685  @Override
686  public boolean isMetadataBased() {
687    return true;
688  }
689
690  public boolean isList() {
691    if (elementProperty != null)
692      return elementProperty.isList();
693    else
694      return property.isList();
695  }
696  
697  @Override
698  public String[] getTypesForProperty(int hash, String name) throws FHIRException {
699    Property p = property.getChildSimpleName(this.name, name);
700    if (p != null) {
701      Set<String> types = new HashSet<String>();
702      for (TypeRefComponent tr : p.getDefinition().getType()) {
703        types.add(tr.getCode());
704      }
705      return types.toArray(new String[]{});
706    }
707    return super.getTypesForProperty(hash, name);
708
709  }
710
711  public void sort() {
712    if (children != null) {
713      List<Element> remove = new ArrayList<Element>();
714      for (Element child : children) {
715        child.sort();
716        if (child.isEmpty())
717          remove.add(child);
718      }
719      children.removeAll(remove);
720      Collections.sort(children, new ElementSortComparator(this, this.property));
721    }
722  }
723
724  public class ElementSortComparator implements Comparator<Element> {
725    private List<ElementDefinition> children;
726    public ElementSortComparator(Element e, Property property) {
727      String tn = e.getType();
728      StructureDefinition sd = property.getContext().fetchResource(StructureDefinition.class, ProfileUtilities.sdNs(tn, property.getContext().getOverrideVersionNs()));
729      if (sd != null && !sd.getAbstract())
730        children = sd.getSnapshot().getElement();
731      else
732        children = property.getStructure().getSnapshot().getElement();
733    }
734    
735    @Override
736    public int compare(Element e0, Element e1) {
737      int i0 = find(e0);
738      int i1 = find(e1);
739      return Integer.compare(i0, i1);
740    }
741    private int find(Element e0) {
742      int i =  e0.elementProperty != null ? children.indexOf(e0.elementProperty.getDefinition()) :  children.indexOf(e0.property.getDefinition());
743      return i; 
744    }
745
746  }
747
748  public class ICodingImpl implements ICoding {
749    private String system;
750    private String version;
751    private String code;
752    private String display;
753    private boolean doesSystem;
754    private boolean doesVersion;
755    private boolean doesCode;
756    private boolean doesDisplay;
757    public ICodingImpl(boolean doesCode, boolean doesSystem, boolean doesVersion, boolean doesDisplay) {
758      super();
759      this.doesCode = doesCode;
760      this.doesSystem = doesSystem;
761      this.doesVersion = doesVersion;
762      this.doesDisplay = doesDisplay;
763    }
764    public String getSystem() {
765      return system;
766    }
767    public String getVersion() {
768      return version;
769    }
770    public String getCode() {
771      return code;
772    }
773    public String getDisplay() {
774      return display;
775    }
776    public boolean hasSystem() {
777      return !Utilities.noString(system); 
778    }
779    public boolean hasVersion() {
780      return !Utilities.noString(version);
781    }
782    public boolean hasCode() {
783      return !Utilities.noString(code);
784    }
785    public boolean hasDisplay() {
786      return !Utilities.noString(display);
787    }
788    public boolean supportsSystem() {
789      return doesSystem;
790    }
791    public boolean supportsVersion() {
792      return doesVersion;
793    }
794    public boolean supportsCode() {
795      return doesCode;
796    }
797    public boolean supportsDisplay() {
798      return doesDisplay;
799    }    
800  }
801
802  public ICoding getAsICoding() throws FHIRException {
803    if ("code".equals(fhirType())) {
804      if (property.getDefinition().getBinding().getStrength() != BindingStrength.REQUIRED)
805        return null;
806      ICodingImpl c = new ICodingImpl(true, true, false, false);
807      c.code = primitiveValue();
808      ValueSetExpansionOutcome vse = property.getContext().expandVS(property.getDefinition().getBinding(), true, false);
809      if (vse.getValueset() == null)
810        return null;
811      for (ValueSetExpansionContainsComponent cc : vse.getValueset().getExpansion().getContains()) {
812        if (cc.getCode().equals(c.code)) {
813          c.system = cc.getSystem();
814          if (cc.hasVersion()) {
815            c.doesVersion = true;
816            c.version = cc.getVersion();
817          }
818          if (cc.hasDisplay()) {
819            c.doesDisplay = true;
820            c.display = cc.getDisplay();
821          }
822        }
823      }
824      if (c.system == null)
825        return null;
826      return c;   
827    } else if ("Coding".equals(fhirType())) {
828      ICodingImpl c = new ICodingImpl(true, true, true, true);
829      c.system = getNamedChildValue("system");
830      c.code = getNamedChildValue("code");
831      c.display = getNamedChildValue("display");
832      c.version = getNamedChildValue("version");
833      return c;
834    } else if ("Quantity".equals(fhirType())) {
835      ICodingImpl c = new ICodingImpl(true, true, false, false);
836      c.system = getNamedChildValue("system");
837      c.code = getNamedChildValue("code");
838      return c;
839    } else 
840      return null;
841  }
842
843  public String getExplicitType() {
844    return explicitType;
845  }
846
847  public void setExplicitType(String explicitType) {
848    this.explicitType = explicitType;
849  }
850
851  
852}