1 16 package org.apache.cocoon.components.profiler; 17 18 import org.apache.cocoon.util.HashUtil; 19 20 import java.util.ArrayList ; 21 22 30 public class ProfilerData { 31 32 35 public static class Entry { 36 37 public String role; 38 public String source; 39 public long setup; 40 public long time; 41 public Object fragment; 42 43 protected Entry(String role, String source) { 44 this.role = role; 45 this.source = source; 46 } 47 } 48 49 private ArrayList entries = null; 51 52 private EnvironmentInfo environmentinfo; 54 55 private long totaltime = 0; 57 58 61 public ProfilerData() { 62 entries = new ArrayList (); 63 } 64 65 72 public void addComponent(Object component, String role, String source) { 73 entries.add(new Entry((role!=null) 74 ? role 75 : component.getClass().getName(), source)); 76 } 77 78 83 public int getCount() { 84 return entries.size(); 85 } 86 87 92 public void setEnvironmentInfo(EnvironmentInfo environmentinfo) { 93 this.environmentinfo = environmentinfo; 94 } 95 96 101 public EnvironmentInfo getEnvironmentInfo() { 102 return this.environmentinfo; 103 } 104 105 110 public void setTotalTime(long time) { 111 this.totaltime = time; 112 } 113 114 119 public long getTotalTime() { 120 return this.totaltime; 121 } 122 123 129 public void setSetupTime(int index, long time) { 130 ((Entry) entries.get(index)).setup = time; 131 } 132 133 139 public long getSetupTime(int index) { 140 return ((Entry) entries.get(index)).setup; 141 } 142 143 149 public void setProcessingTime(int index, long time) { 150 ((Entry) entries.get(index)).time = time; 151 } 152 153 159 public long getProcessingTime(int index) { 160 return ((Entry) entries.get(index)).time; 161 } 162 163 169 public void setSAXFragment(int index, Object fragment) { 170 ((Entry) entries.get(index)).fragment = fragment; 171 } 172 173 178 public Entry[] getEntries() { 179 return (Entry[]) entries.toArray(new Entry[entries.size()]); 180 } 181 182 188 public long getKey(String uri) { 189 StringBuffer key = new StringBuffer (uri); 190 191 for (int i = 0; i<entries.size(); i++) { 192 Entry entry = (Entry) entries.get(i); 193 194 key.append(':'); 195 key.append(entry.role); 196 key.append(':'); 197 key.append(entry.source); 198 } 199 return HashUtil.hash(key); 200 } 201 } 202 | Popular Tags |