1 package com.protomatter.syslog.xml; 2 3 52 53 import java.io.*; 54 import java.net.*; 55 import java.util.*; 56 import com.protomatter.syslog.*; 57 import com.protomatter.xml.*; 58 import org.jdom.*; 59 import org.jdom.output.*; 60 import org.jdom.input.*; 61 62 65 public class PerClassPolicy_Helper 66 extends SimpleLogPolicy_Helper 67 { 68 201 public void configure(Object o, Element e) 202 throws SyslogInitException 203 { 204 super.configure(o, e); 205 PerClassPolicy policy = (PerClassPolicy)o; 206 207 List myList = new ArrayList(); 208 209 Iterator params = e.getChildren("PolicyGroup", e.getNamespace()).iterator(); 210 while (params.hasNext()) 211 { 212 Element param = (Element)params.next(); 213 PerClassPolicy.PolicyGroup g = new PerClassPolicy.PolicyGroup(); 214 configureGroup(g, param); 215 myList.add(g); 216 } 217 218 policy.setGroupList(myList); 219 } 220 221 public void configureGroup(PerClassPolicy.PolicyGroup g, Element e) 222 throws SyslogInitException 223 { 224 super.configure(g, e); 225 226 Iterator kids = e.getChildren("classPattern", e.getNamespace()).iterator(); 227 while (kids.hasNext()) 228 { 229 Element param = (Element)kids.next(); 230 String value = param.getTextTrim(); 231 if (value != null) 232 g.addClassPattern(value); 233 } 234 235 kids = e.getChildren("className", e.getNamespace()).iterator(); 236 while (kids.hasNext()) 237 { 238 Element param = (Element)kids.next(); 239 String value = param.getTextTrim(); 240 if (value != null) 241 g.addClass(value); 242 } 243 } 244 245 public Element getConfiguration(Object o, Element element) 246 { 247 element = super.getConfiguration(o, element); 248 249 PerClassPolicy policy = (PerClassPolicy)o; 250 251 Iterator i = policy.getPolicyGroups(); 252 while (i.hasNext()) 253 { 254 PerClassPolicy.PolicyGroup g = (PerClassPolicy.PolicyGroup)i.next(); 255 Element e = new Element("PolicyGroup"); 256 e = getConfigurationGroup(g, e); 257 element.getChildren().add(e); 258 } 259 return element; 260 } 261 262 public Element getConfigurationGroup(PerClassPolicy.PolicyGroup g, Element element) 263 { 264 Element e = super.getConfiguration(g, element); 265 266 Iterator i = g.getPatternSet(); 268 while (i.hasNext()) 269 { 270 e.getChildren().add( 271 (new Element("classPattern")).setText((String )i.next())); 272 } 273 274 i = g.getClassSet(); 276 while (i.hasNext()) 277 { 278 e.getChildren().add( 279 (new Element("className")).setText((String )i.next())); 280 } 281 282 return e; 283 } 284 } 285 | Popular Tags |