01: /*
02: * To change this template, choose Tools | Templates
03: * and open the template in the editor.
04: */
05: package org.netbeans.modules.masterindex.plugin;
06:
07: import java.util.HashMap;
08: import java.util.logging.Logger;
09:
10: /**
11: *
12: * @author Manish
13: */
14: public class DefaultSystemFields {
15:
16: // Enter System fields that need to be set as defaults (UPPERCASE)
17: // These fields must be present in the source system from where data is being pulled out.
18: private static final String[] defaults = { "GID", "SYSTEMCODE",
19: "LID", "UPDATEDATE", "USR", };
20:
21: //logger
22: private static Logger logger = Logger
23: .getLogger(DefaultSystemFields.class.getName());
24: HashMap fieldMap = new HashMap<String, Integer>();
25:
26: public DefaultSystemFields() {
27: logger.info("Default System Fields ..." + printfields());
28: createFieldMap();
29: }
30:
31: private String printfields() {
32: StringBuilder sb = new StringBuilder();
33: for (int i = 0; i < defaults.length; i++) {
34: sb.append("\n " + defaults[i]);
35: }
36: return sb.toString();
37: }
38:
39: // This is to speed up search of fields at runtime
40: private void createFieldMap() {
41: for (int i = 0; i < defaults.length; i++) {
42: fieldMap.put(defaults[i], new Integer(i));
43: }
44: }
45:
46: // If Attribute is found, index is returned for the attribute
47: public int isAttributeDefault(String attrib) {
48: Integer index = (Integer) fieldMap.get(attrib);
49: if (index != null) {
50: return index.intValue();
51: }
52: return -1;
53: }
54:
55: public static String[] getDefaultSystemFields() {
56: return defaults;
57: }
58: }
|