View Javadoc

1   // BSD License (http://www.galagosearch.org/license)
2   
3   package org.galagosearch.tupleflow.typebuilder;
4   
5   /***
6    *
7    * @author trevor
8    */
9   public class FieldSpecification {
10      public enum DataType {
11          BOOLEAN ("boolean", "boolean", "Boolean", false, false, false),
12          BYTE   ("byte", "byte", "Byte", true, false, false),
13          SHORT  ("short", "short", "Short", true, false, false),
14          INT    ("int", "int", "Integer", true, false, false),
15          LONG   ("long", "long", "Long", true, false, false),
16          FLOAT  ("float", "float", "Float", false, false, false),
17          DOUBLE ("double", "double", "Double", false, false, false),
18          STRING ("String", "String", "String", false, true, false),
19          BYTES  ("bytes", "byte", "byte[]", false, false, true);
20                  
21          DataType(String internalType, String baseType, String className,
22                   boolean isInteger, boolean isString, boolean isArray) {
23              this.internalType = internalType;
24              this.baseType = baseType;
25              this.className = className;
26              this.isInteger = isInteger;
27              this.isString = isString;
28              this.isArray = isArray;
29          }
30  
31          public String getType() {
32              if (!isArray)
33                  return baseType;
34              return baseType + "[]";
35          }
36          
37          public String getBaseType() {
38              return baseType;
39          }
40          
41          public String getInternalType() {
42              return internalType;
43          }
44  
45          public boolean isInteger() {
46              return isInteger;
47          }
48  
49          public boolean isString() {
50              return isString;
51          }
52          
53          public boolean isArray() {
54              return isArray;
55          }
56  
57          public String getClassName() {
58              return className;
59          }
60          
61          private String baseType;
62          private String internalType;
63          private String className;
64          private boolean isInteger;
65          private boolean isString;
66          private boolean isArray;
67      };
68      
69      public FieldSpecification(DataType type, String name) {
70          this.type = type;
71          this.name = name;
72      }
73      
74      public DataType getType() {
75          return type;
76      }
77      
78      public String getName() {
79          return name;
80      }
81      
82      protected DataType type;
83      protected String name;
84  }