View Javadoc
1   package net.sf.sapjcosupport;
2   
3   import java.util.Collection;
4   import java.util.HashMap;
5   import java.util.Map;
6   
7   /**
8    * @author Niki Driessen
9    * @since Jan 23, 2006 - 11:49:14 AM
10   */
11  public class SapStructureMapping {
12      private String name;
13      private Map fields;
14      private String keyField, primaryKey;
15      private short type;
16      private boolean isExcluded; // excluded from output mapping
17      public static final short MAP = 0, LIST = 1, LIST_OF_MAPS = 2, NORMAL = 3, ENTITY = 4;
18  
19      private String entityClass;
20      private String collectionName;
21  
22      public SapStructureMapping(String name, short type) {
23          this.name = name;
24          this.fields = new HashMap();
25          this.type = type;
26      }
27  
28      public SapStructureMapping(String name) {
29          this(name, NORMAL);
30      }
31  
32      public String getName() {
33          return name;
34      }
35  
36      public short getType() {
37          return type;
38      }
39  
40      public void setType(short type) {
41          this.type = type;
42      }
43  
44      public String getEntityClass() {
45          return entityClass;
46      }
47  
48      public void setEntityClass(String entityClass) {
49          this.entityClass = entityClass;
50      }
51  
52      public String getCollectionName() {
53          return collectionName;
54      }
55  
56      public void setCollectionName(String collectionName) {
57          this.collectionName = collectionName;
58      }
59  
60      public Collection getFields() {
61          return fields.values();
62      }
63  
64      public Map getFieldsMap() {
65          return fields;
66      }
67  
68      public void addField(SapFieldMapping field) {
69          if (type == MAP || type == LIST_OF_MAPS) {
70              fields.put(field.getKey(), field);
71          } else {
72              fields.put(field.getPropertyName(), field);
73          }
74      }
75  
76      public String getKeyField() {
77          return keyField;
78      }
79  
80      public void setKeyField(String keyField) {
81          this.keyField = keyField;
82      }
83  
84      public String getPrimaryKey() {
85          return primaryKey;
86      }
87  
88      public void setPrimaryKey(String pk) {
89          primaryKey = pk;
90      }
91  
92      public boolean isMap() {
93          return type == MAP;
94      }
95  
96      public boolean isList() {
97          return type == LIST;
98      }
99  
100     public boolean isListOfMaps() {
101         return type == LIST_OF_MAPS;
102     }
103 
104     public boolean isEntity() {
105         return type == ENTITY;
106     }
107 
108     public boolean isExcluded() {
109         return isExcluded;
110     }
111 
112     public void setExcluded(boolean excluded) {
113         isExcluded = excluded;
114     }
115 }