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 String name;
12      private List<DatatypeComponentDef> mySubComponentDefs = new ArrayList<DatatypeComponentDef>();
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 String getName() {
40          return name;
41      }
42  
43  
44      public boolean isIsType() {
45          return getType().equals("IS");
46      }
47  
48      public boolean isIdType() {
49          return getType().equals("ID") || getType().equals("IS");
50      }
51  
52      public boolean isSpecialCasePrimitive() {
53          return type.equals("IS") || // Constant
54                 type.equals("ID") || // Constant
55                 type.equals("DT") || // Constant
56                 type.equals("DTM") || // Constant
57                 type.equals("TM");
58      }
59  
60      public boolean isTextPrimitive() {
61          return type.equals("ST") || // Constant
62                 type.equals("TX") || // Constant
63                 type.equals("FT");
64      }
65  
66  }