| 1 package com.protomatter.syslog.xml; 2 3 52 53 import java.io.PrintWriter ; 54 import java.util.*; 55 import java.text.*; 56 import java.net.*; 57 import java.io.*; 58 import java.lang.reflect.*; 59 60 import org.jdom.*; 61 62 import com.protomatter.xml.*; 63 import com.protomatter.syslog.*; 64 65 68 public class SimpleSyslogTextFormatter_Helper 69 implements XMLConfigHelper 70 { 71 192 public void configure(Object o, Element e) 193 throws SyslogInitException 194 { 195 SimpleSyslogTextFormatter format = (SimpleSyslogTextFormatter)o; 196 197 String tmp = e.getChildTextTrim("showChannel", e.getNamespace()); 198 if (tmp != null) 199 format.setShowChannel("true".equalsIgnoreCase(tmp)); 200 201 tmp = e.getChildTextTrim("showCaller", e.getNamespace()); 202 if (tmp != null) 203 format.setShowCaller("true".equalsIgnoreCase(tmp)); 204 205 tmp = e.getChildTextTrim("showThreadName", e.getNamespace()); 206 if (tmp != null) 207 format.setShowThreadName("true".equalsIgnoreCase(tmp)); 208 209 tmp = e.getChildTextTrim("showHostName", e.getNamespace()); 210 if (tmp != null) 211 format.setShowHostName("true".equalsIgnoreCase(tmp)); 212 213 tmp = e.getChildTextTrim("dateFormat", e.getNamespace()); 214 if (tmp != null) 215 format.setDateFormat(tmp); 216 217 tmp = e.getChildTextTrim("dateFormatTimeZone", e.getNamespace()); 218 if (tmp != null) 219 format.setDateFormatTimezone(TimeZone.getTimeZone(tmp)); 220 221 tmp = e.getChildTextTrim("dateFormatCacheTime", e.getNamespace()); 222 if (tmp != null) 223 format.setDateFormatCacheTime(Integer.parseInt(tmp)); 224 225 tmp = e.getChildTextTrim("classWidth", e.getNamespace()); 226 if (tmp != null) 227 format.setClassWidth(Integer.parseInt(tmp)); 228 229 tmp = e.getChildTextTrim("channelWidth", e.getNamespace()); 230 if (tmp != null) 231 format.setChannelWidth(Integer.parseInt(tmp)); 232 233 tmp = e.getChildTextTrim("hostWidth", e.getNamespace()); 234 if (tmp != null) 235 format.setHostWidth(Integer.parseInt(tmp)); 236 237 tmp = e.getChildTextTrim("threadWidth", e.getNamespace()); 238 if (tmp != null) 239 format.setThreadWidth(Integer.parseInt(tmp)); 240 241 } 242 243 public Element getConfiguration(Object o, Element element) 244 { 245 SimpleSyslogTextFormatter format = (SimpleSyslogTextFormatter)o; 246 247 Element sc = new Element("showChannel"); 248 sc.setText(String.valueOf(format.getShowChannel())); 249 element.getChildren().add(sc); 250 251 Element st = new Element("showThreadName"); 252 st.setText(String.valueOf(format.getShowThreadName())); 253 element.getChildren().add(st); 254 255 Element sh = new Element("showHostName"); 256 sh.setText(String.valueOf(format.getShowHostName())); 257 element.getChildren().add(sh); 258 259 Element df = new Element("dateFormat"); 260 df.setText(String.valueOf(format.getDateFormat())); 261 element.getChildren().add(df); 262 263 Element dfc = new Element("dateFormatCacheTime"); 264 dfc.setText(String.valueOf(format.getDateFormatCacheTime())); 265 element.getChildren().add(dfc); 266 267 Element tz = new Element("dateFormatTimeZone"); 268 tz.setText(String.valueOf(format.getDateFormatTimezone().getID())); 269 element.getChildren().add(tz); 270 271 Element cw = new Element("classWidth"); 272 cw.setText(String.valueOf(format.getClassWidth())); 273 element.getChildren().add(cw); 274 275 Element chw = new Element("channelWidth"); 276 chw.setText(String.valueOf(format.getChannelWidth())); 277 element.getChildren().add(chw); 278 279 Element tw = new Element("threadWidth"); 280 tw.setText(String.valueOf(format.getThreadWidth())); 281 element.getChildren().add(tw); 282 283 Element hw = new Element("hostWidth"); 284 hw.setText(String.valueOf(format.getHostWidth())); 285 element.getChildren().add(hw); 286 287 return element; 288 } 289 } 290 | Popular Tags |