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 PerChannelPolicy_Helper 66 extends SimpleLogPolicy_Helper 67 { 68 200 public void configure(Object o, Element e) 201 throws SyslogInitException 202 { 203 super.configure(o, e); 204 PerChannelPolicy policy = (PerChannelPolicy)o; 205 206 List myList = new ArrayList(); 207 208 Iterator params = e.getChildren("PolicyGroup", e.getNamespace()).iterator(); 209 while (params.hasNext()) 210 { 211 Element param = (Element)params.next(); 212 PerChannelPolicy.PolicyGroup g = new PerChannelPolicy.PolicyGroup(); 213 configureGroup(g, param); 214 myList.add(g); 215 } 216 217 policy.setGroupList(myList); 218 } 219 220 public void configureGroup(PerChannelPolicy.PolicyGroup g, Element e) 221 throws SyslogInitException 222 { 223 super.configure(g, e); 224 225 Iterator kids = e.getChildren("channelPattern", e.getNamespace()).iterator(); 226 while (kids.hasNext()) 227 { 228 Element param = (Element)kids.next(); 229 String value = param.getTextTrim(); 230 if (value != null) 231 g.addChannelPattern(value); 232 } 233 234 kids = e.getChildren("channelName", e.getNamespace()).iterator(); 235 while (kids.hasNext()) 236 { 237 Element param = (Element)kids.next(); 238 String value = param.getTextTrim(); 239 if (value != null) 240 g.addChannelName(value); 241 } 242 } 243 244 public Element getConfiguration(Object o, Element element) 245 { 246 element = super.getConfiguration(o, element); 247 248 PerChannelPolicy policy = (PerChannelPolicy)o; 249 250 Iterator i = policy.getPolicyGroups(); 251 while (i.hasNext()) 252 { 253 PerChannelPolicy.PolicyGroup g = (PerChannelPolicy.PolicyGroup)i.next(); 254 Element e = new Element("PolicyGroup"); 255 e = getConfigurationGroup(g, e); 256 element.getChildren().add(e); 257 } 258 return element; 259 } 260 261 public Element getConfigurationGroup(PerChannelPolicy.PolicyGroup g, Element element) 262 { 263 Element e = super.getConfiguration(g, element); 264 265 Iterator i = g.getPatternSet(); 267 while (i.hasNext()) 268 { 269 e.getChildren().add( 270 (new Element("channelPattern")).setText((String )i.next())); 271 } 272 273 i = g.getChannelSet(); 275 while (i.hasNext()) 276 { 277 e.getChildren().add( 278 (new Element("channelName")).setText((String )i.next())); 279 } 280 281 return e; 282 } 283 } 284 | Popular Tags |