1 16 package org.apache.log4j.lf5.viewer.categoryexplorer; 17 18 import java.util.LinkedList ; 19 import java.util.StringTokenizer ; 20 21 28 29 31 public class CategoryPath { 32 36 protected LinkedList _categoryElements = new LinkedList (); 40 41 45 49 public CategoryPath() { 50 super(); 51 } 52 53 56 public CategoryPath(String category) { 57 String processedCategory = category; 58 59 if (processedCategory == null) { 60 processedCategory = "Debug"; 61 } 62 63 processedCategory.replace('/', '.'); 64 processedCategory = processedCategory.replace('\\', '.'); 65 66 StringTokenizer st = new StringTokenizer (processedCategory, "."); 67 while (st.hasMoreTokens()) { 68 String element = st.nextToken(); 69 addCategoryElement(new CategoryElement(element)); 70 } 71 } 72 73 77 80 public int size() { 81 int count = _categoryElements.size(); 82 83 return (count); 84 } 85 86 public boolean isEmpty() { 87 boolean empty = false; 88 89 if (_categoryElements.size() == 0) { 90 empty = true; 91 } 92 93 return (empty); 94 } 95 96 97 100 public void removeAllCategoryElements() { 101 _categoryElements.clear(); 102 } 103 104 107 public void addCategoryElement(CategoryElement categoryElement) { 108 _categoryElements.addLast(categoryElement); 109 } 110 111 114 public CategoryElement categoryElementAt(int index) { 115 return ((CategoryElement) _categoryElements.get(index)); 116 } 117 118 119 public String toString() { 120 StringBuffer out = new StringBuffer (100); 121 122 out.append("\n"); 123 out.append("===========================\n"); 124 out.append("CategoryPath: \n"); 125 out.append("---------------------------\n"); 126 127 out.append("\nCategoryPath:\n\t"); 128 129 if (this.size() > 0) { 130 for (int i = 0; i < this.size(); i++) { 131 out.append(this.categoryElementAt(i).toString()); 132 out.append("\n\t"); 133 } 134 } else { 135 out.append("<<NONE>>"); 136 } 137 138 out.append("\n"); 139 out.append("===========================\n"); 140 141 return (out.toString()); 142 } 143 144 148 152 156 } 157 | Popular Tags |