View Javadoc
1   package ca.uhn.hl7v2.sourcegen;
2   
3   import java.util.ArrayList;
4   import java.util.List;
5   
6   import org.apache.commons.lang.StringUtils;
7   
8   public class DatatypeDef {
9   
10      private String type;
11      private final String name;
12      private final List<DatatypeComponentDef> mySubComponentDefs = new ArrayList<>();
13  
14      public DatatypeDef(String theType, String theDescription) {
15          super();
16          type = theType;
17          name = theDescription;
18          
19          if (StringUtils.isEmpty(theType)) {
20              throw new IllegalArgumentException("Missing datatype");
21          }
22          if (StringUtils.isEmpty(theDescription)) {
23              throw new IllegalArgumentException("Missing name in type:" + theType);
24          }
25      }
26  
27      public void addSubcomponentDef(DatatypeComponentDef theDef) {
28          mySubComponentDefs.add(theDef);
29      }
30      
31      public List<DatatypeComponentDef> getSubComponentDefs() {
32          return mySubComponentDefs;
33      }
34  
35      public String getType() {
36          return type;
37      }
38      
39   	public void setType(String theType) {
40   		this.type = theType;
41  	}
42  
43  
44      public String getName() {
45          return name;
46      }
47  
48  
49      public boolean isIsType() {
50          return getType().equals("IS");
51      }
52  
53      public boolean isIdType() {
54          return getType().equals("ID") || getType().equals("IS");
55      }
56  
57      public boolean isSpecialCasePrimitive() {
58          return type.equals("IS") || // Constant
59                 type.equals("ID") || // Constant
60                 type.equals("DT") || // Constant
61                 type.equals("DTM") || // Constant
62                 type.equals("TM");
63      }
64  
65      public boolean isTextPrimitive() {
66          return type.equals("ST") || // Constant
67                 type.equals("TX") || // Constant
68                 type.equals("FT");
69      }
70  
71  }