comparison artifacts/src/main/java/org/dive4elements/river/artifacts/states/StateFactory.java @ 8202:e4606eae8ea5

sed src/**/*.java 's/logger/log/g'
author Sascha L. Teichmann <teichmann@intevation.de>
date Fri, 05 Sep 2014 12:58:17 +0200
parents af13ceeba52a
children 0a5239a1e46e
comparison
equal deleted inserted replaced
8201:4b8c5a08de04 8202:e4606eae8ea5
24 /** 24 /**
25 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> 25 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
26 */ 26 */
27 public class StateFactory { 27 public class StateFactory {
28 28
29 /** The logger used in this class */ 29 /** The log used in this class */
30 private static Logger logger = Logger.getLogger(StateFactory.class); 30 private static Logger log = Logger.getLogger(StateFactory.class);
31 31
32 /** The XPath to the classname of the state */ 32 /** The XPath to the classname of the state */
33 public static final String XPATH_STATE = "@state"; 33 public static final String XPATH_STATE = "@state";
34 34
35 /** The XPath to the data items of the state relative to the state node. */ 35 /** The XPath to the data items of the state relative to the state node. */
58 stateConf, XPATH_STATE, XPathConstants.STRING); 58 stateConf, XPATH_STATE, XPathConstants.STRING);
59 59
60 State state = null; 60 State state = null;
61 61
62 try { 62 try {
63 logger.debug("Create a new State for class: " + clazz); 63 log.debug("Create a new State for class: " + clazz);
64 state = (State) Class.forName(clazz).newInstance(); 64 state = (State) Class.forName(clazz).newInstance();
65 state.setup(stateConf); 65 state.setup(stateConf);
66 66
67 initializeStateData(state, stateConf); 67 initializeStateData(state, stateConf);
68 } 68 }
69 catch (InstantiationException ie) { 69 catch (InstantiationException ie) {
70 logger.error(ie, ie); 70 log.error(ie, ie);
71 } 71 }
72 catch (IllegalAccessException iae) { 72 catch (IllegalAccessException iae) {
73 logger.error(iae, iae); 73 log.error(iae, iae);
74 } 74 }
75 catch (ClassNotFoundException cnfe) { 75 catch (ClassNotFoundException cnfe) {
76 logger.error(cnfe, cnfe); 76 log.error(cnfe, cnfe);
77 } 77 }
78 78
79 return state; 79 return state;
80 } 80 }
81 81
90 protected static void initializeStateData(State state, Node stateConf) { 90 protected static void initializeStateData(State state, Node stateConf) {
91 NodeList dataList = (NodeList) XMLUtils.xpath( 91 NodeList dataList = (NodeList) XMLUtils.xpath(
92 stateConf, XPATH_DATA, XPathConstants.NODESET); 92 stateConf, XPATH_DATA, XPathConstants.NODESET);
93 93
94 if (dataList == null || dataList.getLength() == 0) { 94 if (dataList == null || dataList.getLength() == 0) {
95 logger.debug("The state has no input data configured."); 95 log.debug("The state has no input data configured.");
96 96
97 return; 97 return;
98 } 98 }
99 99
100 int items = dataList.getLength(); 100 int items = dataList.getLength();
101 101
102 logger.debug("The state has " + items + " data items configured."); 102 log.debug("The state has " + items + " data items configured.");
103 103
104 for (int i = 0; i < items; i++) { 104 for (int i = 0; i < items; i++) {
105 Node data = dataList.item(i); 105 Node data = dataList.item(i);
106 106
107 String name = (String) XMLUtils.xpath( 107 String name = (String) XMLUtils.xpath(
110 data, XPATH_DATA_TYPE, XPathConstants.STRING); 110 data, XPATH_DATA_TYPE, XPathConstants.STRING);
111 String desc = (String) XMLUtils.xpath( 111 String desc = (String) XMLUtils.xpath(
112 data, XPATH_DATA_DESCRIPTION, XPathConstants.STRING); 112 data, XPATH_DATA_DESCRIPTION, XPathConstants.STRING);
113 113
114 if (name == null || name.length() == 0) { 114 if (name == null || name.length() == 0) {
115 logger.warn("No name for data item at pos " + i + " found."); 115 log.warn("No name for data item at pos " + i + " found.");
116 continue; 116 continue;
117 } 117 }
118 118
119 if (type == null || type.length() == 0) { 119 if (type == null || type.length() == 0) {
120 logger.warn("No type for data item at pos " + i + " found."); 120 log.warn("No type for data item at pos " + i + " found.");
121 logger.warn("Default type 'string' used."); 121 log.warn("Default type 'string' used.");
122 type = "string"; 122 type = "string";
123 } 123 }
124 124
125 logger.debug("add StateData '" + name + "' (type '" + type + "')"); 125 log.debug("add StateData '" + name + "' (type '" + type + "')");
126 state.addData(name, new DefaultStateData(name, desc, type)); 126 state.addData(name, new DefaultStateData(name, desc, type));
127 } 127 }
128 } 128 }
129 } 129 }
130 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 130 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org