1 package com.protomatter.syslog.xml; 2 3 52 53 import java.io.*; 54 import java.net.*; 55 import java.util.*; 56 import java.text.*; 57 58 import com.protomatter.xml.*; 59 import com.protomatter.syslog.*; 60 import org.jdom.*; 61 62 65 public class FileLog_Helper 66 extends BasicLogger_Helper 67 { 68 129 public void configure(Object o, Element e) 130 throws SyslogInitException 131 { 132 super.configure(o, e); 133 134 FileLog log = (FileLog)o; 135 136 String tmp = e.getChildTextTrim("fileName", e.getNamespace()); 137 if (tmp != null) 138 { 139 log.setFile(new File(tmp)); 140 } 141 else 142 { 143 throw new IllegalArgumentException ( 144 MessageFormat.format(Syslog.getResourceString(MessageConstants.XML_MUST_SPECIFY_PARAM_MESSAGE), 145 new Object [] { "fileName" } )); 146 } 147 148 tmp = e.getChildTextTrim("append", e.getNamespace()); 149 if (tmp != null) 150 log.setAppend("true".equalsIgnoreCase(tmp.trim())); 151 152 tmp = e.getChildTextTrim("autoFlush", e.getNamespace()); 153 if (tmp != null) 154 log.setAutoFlush("true".equalsIgnoreCase(tmp.trim())); 155 } 156 157 public Element getConfiguration(Object o, Element element) 158 { 159 Element e = super.getConfiguration(o, element); 160 161 FileLog log = (FileLog)o; 162 163 Element file = new Element("fileName"); 164 file.setText(log.getFile().getPath()); 165 e.getChildren().add(file); 166 167 Element append = new Element("append"); 168 append.setText(String.valueOf(log.getAppend())); 169 e.getChildren().add(append); 170 171 Element af = new Element("autoFlush"); 172 af.setText(String.valueOf(log.getAutoFlush())); 173 e.getChildren().add(af); 174 175 return e; 176 } 177 } 178 | Popular Tags |