View Javadoc
1 package net.sf.panoptes.model.component.log4j; 2 3 import java.util.ArrayList; 4 import java.util.Enumeration; 5 import java.util.Vector; 6 7 import net.sf.panoptes.model.component.Component; 8 import net.sf.panoptes.model.node.NodeDescriptor; 9 import net.sf.panoptes.model.node.INode; 10 11 import org.apache.log4j.Level; 12 import org.apache.log4j.spi.LoggingEvent; 13 14 /*** 15 * Wraps a logger location. 16 * 17 * @author Dag Liodden 18 * @version 0.1 19 */ 20 public class LoggerComponent extends Component implements Comparable { 21 22 private String className; 23 private String host; 24 private boolean isPackage; 25 private LoggerComponent parent; 26 private Vector children = new Vector(); 27 private Vector events = new Vector(); 28 29 /*** 30 * Constructor for LoggerComponent. 31 */ 32 public LoggerComponent(String host, String className, boolean isPackage, LoggerComponent parent) { 33 this.host = host; 34 this.className = className; 35 this.isPackage = isPackage; 36 this.parent = parent; 37 } 38 39 public String getClassName() { 40 return className; 41 } 42 43 public void addEvent(LoggingEvent event) { 44 events.insertElementAt(event, 0); 45 } 46 47 public void addChild(LoggerComponent child) { 48 children.add(child); 49 } 50 51 public LoggerComponent[] listChildren() { 52 return (LoggerComponent[]) children.toArray(new LoggerComponent[children.size()]); 53 } 54 55 public LoggingEvent[] listEvents() { 56 return (LoggingEvent[]) events.toArray(new LoggingEvent[events.size()]); 57 } 58 59 public LoggingEvent[] listEvents(Level level) { 60 ArrayList v = new ArrayList(); 61 for (Enumeration e = events.elements(); e.hasMoreElements();) { 62 LoggingEvent event = (LoggingEvent) e.nextElement(); 63 if (event.getLevel().isGreaterOrEqual(level)) { 64 v.add(event); 65 } 66 } 67 return (LoggingEvent[]) v.toArray(new LoggingEvent[v.size()]); 68 } 69 70 /*** 71 * @see com.glt.troodon.console.INode#getConfigDescriptor() 72 */ 73 public NodeDescriptor getConfigDescriptor() { 74 return new NodeDescriptor(host + ":" + className, "Logs for " + className); 75 } 76 77 /*** 78 * @see com.glt.troodon.console.INode#getIconName() 79 */ 80 public String getIconName() { 81 return isPackage ? INode.ICON_FOLDER : INode.ICON_LOG; 82 } 83 84 /*** 85 * @see java.lang.Comparable#compareTo(java.lang.Object) 86 */ 87 public int compareTo(Object o) { 88 if (o instanceof LoggerComponent) return ((LoggerComponent) o).getClassName().compareTo(className); 89 else throw new ClassCastException("Unable to compare"); 90 } 91 92 public boolean equals(Object o) { 93 if (o instanceof LoggerComponent) return ((LoggerComponent) o).getClassName().equals(className); 94 else return false; 95 } 96 97 }

This page was automatically generated by Maven