Update of /cvsroot/javaprofiler/jpiimpl/net/sourceforge/javaprofiler/jpiimpl/realtime In directory usw-pr-cvs1:/tmp/cvs-serv24156 Modified Files: AllocThreadMethodR.java AllocThreadTraceR.java AllocTraceR.java AllocTypeMethodR.java AllocTypeR.java AllocTypeThreadMethodR.java AllocTypeThreadR.java AllocTypeThreadTraceR.java AllocTypeTraceR.java CPUThreadMethodR.java CPUThreadTraceR.java CPUTraceR.java ClassR.java DataR.java FrameR.java ImageR.java MethodR.java MonThreadMethodR.java MonThreadTraceR.java MonTraceR.java ThreadGroupR.java ThreadR.java Log Message: added siblings and getter methods with specific peer argument Index: AllocThreadMethodR.java =================================================================== RCS file: /cvsroot/javaprofiler/jpiimpl/net/sourceforge/javaprofiler/jpiimpl/realtime/AllocThreadMethodR.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** AllocThreadMethodR.java 15 May 2002 08:26:36 -0000 1.4 --- AllocThreadMethodR.java 28 May 2002 17:13:48 -0000 1.5 *************** *** 159,163 **** * </code> if this root is N / A. */ ! public Location getLocation() { needConstructed(); return location; --- 159,163 ---- * </code> if this root is N / A. */ ! public DataR getLocation() { needConstructed(); return location; *************** *** 285,288 **** --- 285,312 ---- Integer getId() { return objId; + } + + /** Returns CPUThreadMethodRef of the same Thread and the same Method. */ + public CPUThreadMethodRef getSiblingCPU() { + needConstructed(); + if (!image.getAlwaysRefresh()) + thread.refreshCPUThreadMethods(); + List o=thread.getCPUThreadMethods(); + return (CPUThreadMethodRef) image.filterByLocation(o, getLocation()); + } + + /** Returns MonThreadMethodRef of the same Thread and the same Method. */ + public MonThreadMethodRef getSiblingMon() { + needConstructed(); + if (!image.getAlwaysRefresh()) + thread.refreshMonThreadMethods(); + List o=thread.getMonThreadMethods(); + return (MonThreadMethodRef) image.filterByLocation(o, getLocation()); + } + + /** Returns specific element of AllocTypeThreadMethods list. */ + public AllocTypeThreadMethodRef getAllocTypeThreadMethod(TypeRef peer) { + List o=getAllocTypeThreadMethods(); + return (AllocTypeThreadMethodRef) image.filterByType(o,(DataR) peer); } Index: AllocThreadTraceR.java =================================================================== RCS file: /cvsroot/javaprofiler/jpiimpl/net/sourceforge/javaprofiler/jpiimpl/realtime/AllocThreadTraceR.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** AllocThreadTraceR.java 15 May 2002 08:26:36 -0000 1.3 --- AllocThreadTraceR.java 28 May 2002 17:13:49 -0000 1.4 *************** *** 151,155 **** * </code> if this root is N / A. */ ! public Location getLocation() { needConstructed(); return location; --- 151,155 ---- * </code> if this root is N / A. */ ! public DataR getLocation() { needConstructed(); return location; *************** *** 287,292 **** } public String toString() { return getThreadR() + "-" + getLocation(); } ! } \ No newline at end of file --- 287,318 ---- } + /** Returns CPUThreadTraceRef of the same Thread and the same Trace. */ + public CPUThreadTraceRef getSiblingCPU() { + needConstructed(); + if (!image.getAlwaysRefresh()) + thread.refreshCPUThreadTraces(); + List o=thread.getCPUThreadTraces(); + return (CPUThreadTraceRef) image.filterByLocationFrames(o, + location.getFrames()); + } + + /** Returns MonThreadTraceRef of the same Thread and the same Trace. */ + public MonThreadTraceRef getSiblingMon() { + needConstructed(); + if (!image.getAlwaysRefresh()) + thread.refreshMonThreadTraces(); + List o=thread.getMonThreadTraces(); + return (MonThreadTraceRef) image.filterByLocationFrames(o, + location.getFrames()); + } + + /** Returns specific element of AllocTypeThreadTraces list. */ + public AllocTypeThreadTraceRef getAllocTypeThreadTrace(TypeRef peer) { + List o=getAllocTypeThreadTraces(); + return (AllocTypeThreadTraceRef) image.filterByType(o,(DataR) peer); + } + public String toString() { return getThreadR() + "-" + getLocation(); } ! } Index: AllocTraceR.java =================================================================== RCS file: /cvsroot/javaprofiler/jpiimpl/net/sourceforge/javaprofiler/jpiimpl/realtime/AllocTraceR.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** AllocTraceR.java 15 May 2002 08:26:36 -0000 1.4 --- AllocTraceR.java 28 May 2002 17:13:49 -0000 1.5 *************** *** 43,47 **** * @author Lukas Petru */ ! public class AllocTraceR extends Location implements AllocTraceRef { /** Tells if any data was loaded from profiled VM about this Type. */ private boolean isReady; --- 43,47 ---- * @author Lukas Petru */ ! public class AllocTraceR extends DataR implements AllocTraceRef { /** Tells if any data was loaded from profiled VM about this Type. */ private boolean isReady; *************** *** 207,211 **** * </code> if this root is N / A. */ ! public Location getLocation() { return this; } --- 207,211 ---- * </code> if this root is N / A. */ ! public DataR getLocation() { return this; } *************** *** 281,284 **** --- 281,314 ---- Integer getId() { return objId; + } + + /** Returns CPUTraceRef of the same Trace. */ + public CPUTraceRef getSiblingCPU() { + needConstructed(); + if (!image.getAlwaysRefresh()) + image.refreshCPUTraces(); + List o=image.getCPUTraces(); + return (CPUTraceRef) image.filterByFrames(o, getFrames()); + } + + /** Returns MonTraceRef of the same Trace. */ + public MonTraceRef getSiblingMon() { + needConstructed(); + if (!image.getAlwaysRefresh()) + image.refreshMonTraces(); + List o=image.getMonTraces(); + return (MonTraceRef) image.filterByFrames(o, getFrames()); + } + + /** Returns specific element of AllocThreadTraces list. */ + public AllocThreadTraceRef getAllocThreadTrace(ThreadRef peer) { + List o=getAllocThreadTraces(); + return (AllocThreadTraceRef) image.filterByThread(o,(DataR) peer); + } + + /** Returns specific element of AllocTypeTraces list. */ + public AllocTypeTraceRef getAllocTypeTrace(TypeRef peer) { + List o=getAllocTypeTraces(); + return (AllocTypeTraceRef) image.filterByType(o,(DataR) peer); } Index: AllocTypeMethodR.java =================================================================== RCS file: /cvsroot/javaprofiler/jpiimpl/net/sourceforge/javaprofiler/jpiimpl/realtime/AllocTypeMethodR.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** AllocTypeMethodR.java 15 May 2002 08:26:36 -0000 1.4 --- AllocTypeMethodR.java 28 May 2002 17:13:49 -0000 1.5 *************** *** 133,137 **** * </code> if this root is N / A. */ ! public Location getLocation() { needConstructed(); return location; --- 133,137 ---- * </code> if this root is N / A. */ ! public DataR getLocation() { needConstructed(); return location; *************** *** 275,278 **** --- 275,284 ---- Integer getId() { return objId; + } + + /** Returns specific element of AllocTypeThreadMethods list. */ + public AllocTypeThreadMethodRef getAllocTypeThreadMethod(ThreadRef peer) { + List o=getAllocTypeThreadMethods(); + return (AllocTypeThreadMethodRef) image.filterByThread(o, (DataR)peer); } Index: AllocTypeR.java =================================================================== RCS file: /cvsroot/javaprofiler/jpiimpl/net/sourceforge/javaprofiler/jpiimpl/realtime/AllocTypeR.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** AllocTypeR.java 15 May 2002 08:26:36 -0000 1.2 --- AllocTypeR.java 28 May 2002 17:13:49 -0000 1.3 *************** *** 219,223 **** } ! public Location getLocation() { return null; } --- 219,223 ---- } ! public DataR getLocation() { return null; } *************** *** 354,357 **** --- 354,375 ---- Integer getId() { return objId; + } + + /** Returns specific element of AllocTypeTraces list. */ + public AllocTypeTraceRef getAllocTypeTrace(AllocTraceRef peer) { + List o=getAllocTypeTraces(); + return (AllocTypeTraceRef) image.filterByLocation(o, (DataR)peer); + } + + /** Returns specific element of AllocTypeMethods list. */ + public AllocTypeMethodRef getAllocTypeMethod(MethodRef peer) { + List o=getAllocTypeMethods(); + return (AllocTypeMethodRef) image.filterByLocation(o, (DataR)peer); + } + + /** Returns specific element of AllocTypeThreads list. */ + public AllocTypeThreadRef getAllocTypeThread(ThreadRef peer) { + List o=getAllocTypeThreads(); + return (AllocTypeThreadRef) image.filterByThread(o, (DataR)peer); } Index: AllocTypeThreadMethodR.java =================================================================== RCS file: /cvsroot/javaprofiler/jpiimpl/net/sourceforge/javaprofiler/jpiimpl/realtime/AllocTypeThreadMethodR.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** AllocTypeThreadMethodR.java 15 May 2002 08:26:36 -0000 1.4 --- AllocTypeThreadMethodR.java 28 May 2002 17:13:49 -0000 1.5 *************** *** 155,159 **** * </code> if this root is N / A. */ ! public Location getLocation() { needConstructed(); return location; --- 155,159 ---- * </code> if this root is N / A. */ ! public DataR getLocation() { needConstructed(); return location; Index: AllocTypeThreadR.java =================================================================== RCS file: /cvsroot/javaprofiler/jpiimpl/net/sourceforge/javaprofiler/jpiimpl/realtime/AllocTypeThreadR.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** AllocTypeThreadR.java 15 May 2002 08:26:36 -0000 1.5 --- AllocTypeThreadR.java 28 May 2002 17:13:49 -0000 1.6 *************** *** 134,138 **** * </code> if this root is N / A. */ ! public Location getLocation() { needConstructed(); return null; --- 134,138 ---- * </code> if this root is N / A. */ ! public DataR getLocation() { needConstructed(); return null; *************** *** 282,285 **** --- 282,299 ---- Integer getId() { return objId; + } + + /** Returns specific element of AllocTypeThreadMethods list. */ + public AllocTypeThreadMethodRef getAllocTypeThreadMethod(MethodRef peer) { + List o=getAllocTypeThreadMethods(); + return (AllocTypeThreadMethodRef) image.filterByLocation(o, (DataR) + peer); + } + + /** Returns specific element of AllocTypeThreadTraces list. */ + public AllocTypeThreadTraceRef getAllocTypeThreadTrace(AllocTraceRef peer) { + List o=getAllocTypeThreadTraces(); + return (AllocTypeThreadTraceRef) image.filterByLocation(o, (DataR) + peer); } Index: AllocTypeThreadTraceR.java =================================================================== RCS file: /cvsroot/javaprofiler/jpiimpl/net/sourceforge/javaprofiler/jpiimpl/realtime/AllocTypeThreadTraceR.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** AllocTypeThreadTraceR.java 15 May 2002 08:26:36 -0000 1.3 --- AllocTypeThreadTraceR.java 28 May 2002 17:13:49 -0000 1.4 *************** *** 143,147 **** * </code> if this root is N / A. */ ! public Location getLocation() { needConstructed(); return location; --- 143,147 ---- * </code> if this root is N / A. */ ! public DataR getLocation() { needConstructed(); return location; Index: AllocTypeTraceR.java =================================================================== RCS file: /cvsroot/javaprofiler/jpiimpl/net/sourceforge/javaprofiler/jpiimpl/realtime/AllocTypeTraceR.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** AllocTypeTraceR.java 15 May 2002 08:26:36 -0000 1.4 --- AllocTypeTraceR.java 28 May 2002 17:13:49 -0000 1.5 *************** *** 150,154 **** * </code> if this root is N / A. */ ! public Location getLocation() { needConstructed(); return location; --- 150,154 ---- * </code> if this root is N / A. */ ! public DataR getLocation() { needConstructed(); return location; *************** *** 284,287 **** --- 284,294 ---- Integer getId() { return objId; + } + + /** Returns specific element of AllocTypeThreadTraces list. */ + public AllocTypeThreadTraceRef getAllocTypeThreadTrace(ThreadRef peer) { + List o=getAllocTypeThreadTraces(); + return (AllocTypeThreadTraceRef) image.filterByThread(o, (DataR) + peer); } Index: CPUThreadMethodR.java =================================================================== RCS file: /cvsroot/javaprofiler/jpiimpl/net/sourceforge/javaprofiler/jpiimpl/realtime/CPUThreadMethodR.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** CPUThreadMethodR.java 15 May 2002 08:26:36 -0000 1.2 --- CPUThreadMethodR.java 28 May 2002 17:13:49 -0000 1.3 *************** *** 143,147 **** * </code> if this root is N / A. */ ! public Location getLocation() { needConstructed(); return location; --- 143,147 ---- * </code> if this root is N / A. */ ! public DataR getLocation() { needConstructed(); return location; *************** *** 254,257 **** --- 254,275 ---- Integer getId() { return objId; + } + + /** Returns AllocThreadMethodRef of the same Thread and the same Method. */ + public AllocThreadMethodRef getSiblingAlloc() { + needConstructed(); + if (!image.getAlwaysRefresh()) + thread.refreshAllocThreadMethods(); + List o=thread.getAllocThreadMethods(); + return (AllocThreadMethodRef) image.filterByLocation(o, getLocation()); + } + + /** Returns MonThreadMethodRef of the same Thread and the same Method. */ + public MonThreadMethodRef getSiblingMon() { + needConstructed(); + if (!image.getAlwaysRefresh()) + thread.refreshMonThreadMethods(); + List o=thread.getMonThreadMethods(); + return (MonThreadMethodRef) image.filterByLocation(o, getLocation()); } Index: CPUThreadTraceR.java =================================================================== RCS file: /cvsroot/javaprofiler/jpiimpl/net/sourceforge/javaprofiler/jpiimpl/realtime/CPUThreadTraceR.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** CPUThreadTraceR.java 15 May 2002 08:26:36 -0000 1.2 --- CPUThreadTraceR.java 28 May 2002 17:13:49 -0000 1.3 *************** *** 131,135 **** * </code> if this root is N / A. */ ! public Location getLocation() { needConstructed(); return location; --- 131,135 ---- * </code> if this root is N / A. */ ! public DataR getLocation() { needConstructed(); return location; *************** *** 251,254 **** --- 251,274 ---- Integer getId() { return objId; + } + + /** Returns AllocThreadTraceRef of the same Thread and the same Trace. */ + public AllocThreadTraceRef getSiblingAlloc() { + needConstructed(); + if (!image.getAlwaysRefresh()) + thread.refreshAllocThreadTraces(); + List o=thread.getAllocThreadTraces(); + return (AllocThreadTraceRef) image.filterByLocationFrames(o, + location.getFrames()); + } + + /** Returns MonThreadTraceRef of the same Thread and the same Trace. */ + public MonThreadTraceRef getSiblingMon() { + needConstructed(); + if (!image.getAlwaysRefresh()) + thread.refreshMonThreadTraces(); + List o=thread.getMonThreadTraces(); + return (MonThreadTraceRef) image.filterByLocationFrames(o, + location.getFrames()); } Index: CPUTraceR.java =================================================================== RCS file: /cvsroot/javaprofiler/jpiimpl/net/sourceforge/javaprofiler/jpiimpl/realtime/CPUTraceR.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** CPUTraceR.java 15 May 2002 08:26:36 -0000 1.3 --- CPUTraceR.java 28 May 2002 17:13:49 -0000 1.4 *************** *** 43,47 **** * @author Lukas Petru */ ! public class CPUTraceR extends Location implements CPUTraceRef { /** Tells if any data was loaded from profiled VM about this Type. */ private boolean isReady; --- 43,47 ---- * @author Lukas Petru */ ! public class CPUTraceR extends DataR implements CPUTraceRef { /** Tells if any data was loaded from profiled VM about this Type. */ private boolean isReady; *************** *** 170,174 **** * </code> if this root is N / A. */ ! public Location getLocation() { return this; } --- 170,174 ---- * </code> if this root is N / A. */ ! public DataR getLocation() { return this; } *************** *** 247,250 **** --- 247,274 ---- } + /** Returns AllocTraceRef of the same Trace. */ + public AllocTraceRef getSiblingAlloc() { + needConstructed(); + if (!image.getAlwaysRefresh()) + image.refreshAllocTraces(); + List o=image.getAllocTraces(); + return (AllocTraceRef) image.filterByFrames(o, getFrames()); + } + + /** Returns MonTraceRef of the same Trace. */ + public MonTraceRef getSiblingMon() { + needConstructed(); + if (!image.getAlwaysRefresh()) + image.refreshMonTraces(); + List o=image.getMonTraces(); + return (MonTraceRef) image.filterByFrames(o, getFrames()); + } + + /** Returns specific element of CPUThreadTraces list. */ + public CPUThreadTraceRef getCPUThreadTrace(ThreadRef peer) { + List o=getCPUThreadTraces(); + return (CPUThreadTraceRef) image.filterByThread(o,(DataR) peer); + } + public String toString() { return "trace of " + getMethod(); Index: ClassR.java =================================================================== RCS file: /cvsroot/javaprofiler/jpiimpl/net/sourceforge/javaprofiler/jpiimpl/realtime/ClassR.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** ClassR.java 15 May 2002 08:26:36 -0000 1.2 --- ClassR.java 28 May 2002 17:13:49 -0000 1.3 *************** *** 178,182 **** * </code> if this root is N / A. */ ! public Location getLocation() { return null; } --- 178,182 ---- * </code> if this root is N / A. */ ! public DataR getLocation() { return null; } Index: DataR.java =================================================================== RCS file: /cvsroot/javaprofiler/jpiimpl/net/sourceforge/javaprofiler/jpiimpl/realtime/DataR.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** DataR.java 15 May 2002 08:26:36 -0000 1.2 --- DataR.java 28 May 2002 17:13:49 -0000 1.3 *************** *** 68,71 **** * </code> if this root is N / A. */ ! public abstract Location getLocation(); } --- 68,71 ---- * </code> if this root is N / A. */ ! public abstract DataR getLocation(); } Index: FrameR.java =================================================================== RCS file: /cvsroot/javaprofiler/jpiimpl/net/sourceforge/javaprofiler/jpiimpl/realtime/FrameR.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** FrameR.java 15 May 2002 08:26:36 -0000 1.2 --- FrameR.java 28 May 2002 17:13:49 -0000 1.3 *************** *** 69,72 **** --- 69,82 ---- } + /** Defines that two frames are equal iff they have same lineno and point + * to the same method (tested via ==). + */ + public boolean equals(Object o) { + if (!(o instanceof FrameR)) + return false; + FrameR frame=(FrameR) o; + return lineno==frame.lineno && method==frame.method; + } + public String toString() { return getMethod() + ":" + getLineNo(); Index: ImageR.java =================================================================== RCS file: /cvsroot/javaprofiler/jpiimpl/net/sourceforge/javaprofiler/jpiimpl/realtime/ImageR.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** ImageR.java 15 May 2002 08:26:36 -0000 1.6 --- ImageR.java 28 May 2002 17:13:49 -0000 1.7 *************** *** 468,472 **** /** Refreshes <code>Type</code> list by loading new data from profiled JVM. */ ! public void refreshAllocTypes() { extractRoot(IProf.OBJECT_TYPES, typeFactory, types); } --- 468,472 ---- /** Refreshes <code>Type</code> list by loading new data from profiled JVM. */ ! public void refreshTypes() { extractRoot(IProf.OBJECT_TYPES, typeFactory, types); } *************** *** 475,479 **** public List getTypes() { if (isAlwaysRefresh) ! refreshAllocTypes(); return roTypes; } --- 475,479 ---- public List getTypes() { if (isAlwaysRefresh) ! refreshTypes(); return roTypes; } *************** *** 803,807 **** optionalArg, boolean clearFlag) throws COMMUN_Exception, BAD_OBJ_ID_Exception, BAD_COMMAND_Exception, UNKNOWN_Exception { ! if ( getAllFlags.add(new Long(direction << 32 + parent)) ) { return iprof.getAllThruIterator(parent, direction, sameOutputObject, includeInfo, optionalArg, clearFlag); --- 803,809 ---- optionalArg, boolean clearFlag) throws COMMUN_Exception, BAD_OBJ_ID_Exception, BAD_COMMAND_Exception, UNKNOWN_Exception { ! long dirLong=direction; ! Long key=new Long((dirLong << 32) + parent); ! if ( getAllFlags.add(key) ) { return iprof.getAllThruIterator(parent, direction, sameOutputObject, includeInfo, optionalArg, clearFlag); *************** *** 812,817 **** } public String toString() { return "realtime VirtualMachineImage"; } ! } \ No newline at end of file --- 814,919 ---- } + // --------------------------------------------------------- list filtering + + /** Processes the given list of <code>DataR</code> elements and selects one + * element from the list, which has the requested type. + * @return selected element or <code>null</code> if no element satisfies + * the criterion + */ + DataR filterByType (List inList, DataR keyType) { + Iterator it=inList.iterator(); + while (it.hasNext()) { + DataR el=(DataR) it.next(); + if (el.getTypeR()==keyType) + return el; + } + return null; + } + + /** Processes the given list of <code>DataR</code> elements and selects one + * element from the list, which has the requested thread. + * @return selected element or <code>null</code> if no element satisfies + * the criterion + */ + DataR filterByThread (List inList, DataR keyThread) { + Iterator it=inList.iterator(); + while (it.hasNext()) { + DataR el=(DataR) it.next(); + if (el.getThreadR()==keyThread) + return el; + } + return null; + } + + /** Processes the given list of <code>DataR</code> elements and selects one + * element from the list, which has the requested location. + * @return selected element or <code>null</code> if no element satisfies + * the criterion + */ + DataR filterByLocation (List inList, DataR keyLocation) { + Iterator it=inList.iterator(); + while (it.hasNext()) { + DataR el=(DataR) it.next(); + if (el.getLocation()==keyLocation) + return el; + } + return null; + } + + /** Processes the given list of <code>DataR</code> elements and selects one + * element from the list, which has the requested frames. + * @param inList This List must contain elements of type AllocTraceR, + * CPUTraceR or MonTraceR. + * @return selected element or <code>null</code> if no element satisfies + * the criterion + */ + DataR filterByFrames (List inList, List frames) { + Iterator it=inList.iterator(); + while (it.hasNext()) { + Object el=it.next(); + if (el instanceof AllocTraceR) { + if (((AllocTraceR)el).getFrames().equals(frames)) + return (DataR) el; + } else if (el instanceof CPUTraceR) { + if (((CPUTraceR)el).getFrames().equals(frames)) + return (DataR) el; + } else if (el instanceof MonTraceR) { + if (((MonTraceR)el).getFrames().equals(frames)) + return (DataR) el; + } + } + return null; + } + + /** Processes the given list of <code>DataR</code> elements and selects one + * element from the list, location of which has the requested frames. + * @param inList This List must contain elements which are instances + of some MultiRoot type, which have valid location. + * @return selected element or <code>null</code> if no element satisfies + * the criterion + */ + DataR filterByLocationFrames (List inList, List frames) { + System.out.println(frames); + Iterator it=inList.iterator(); + while (it.hasNext()) { + DataR data=(DataR) it.next(); + DataR location=data.getLocation(); + System.out.println(location); + if (location instanceof AllocTraceR) { + if (((AllocTraceR) location).getFrames().equals(frames)) + return data; + } else if (location instanceof CPUTraceR) { + if (((CPUTraceR) location).getFrames().equals(frames)) + return data; + } else if (location instanceof MonTraceR) { + if (((MonTraceR) location).getFrames().equals(frames)) + return data; + } + } + return null; + } + public String toString() { return "realtime VirtualMachineImage"; } ! } Index: MethodR.java =================================================================== RCS file: /cvsroot/javaprofiler/jpiimpl/net/sourceforge/javaprofiler/jpiimpl/realtime/MethodR.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** MethodR.java 15 May 2002 08:26:36 -0000 1.4 --- MethodR.java 28 May 2002 17:13:49 -0000 1.5 *************** *** 43,47 **** * @author Lukas Petru */ ! public class MethodR extends Location implements MethodRef { /** Tells if any data was loaded from profiled VM about this Type. */ private boolean isReady; --- 43,47 ---- * @author Lukas Petru */ ! public class MethodR extends DataR implements MethodRef { /** Tells if any data was loaded from profiled VM about this Type. */ private boolean isReady; *************** *** 302,306 **** * </code> if this root is N / A. */ ! public Location getLocation() { return this; } --- 302,306 ---- * </code> if this root is N / A. */ ! public DataR getLocation() { return this; } *************** *** 445,448 **** --- 445,472 ---- Integer getId() { return objId; + } + + /** Returns specific element of CPUThreadMethods list. */ + public CPUThreadMethodRef getCPUThreadMethod(ThreadRef peer) { + List o=getCPUThreadMethods(); + return (CPUThreadMethodRef) image.filterByThread(o,(DataR) peer); + } + + /** Returns specific element of AllocThreadMethods list. */ + public AllocThreadMethodRef getAllocThreadMethod(ThreadRef peer) { + List o=getAllocThreadMethods(); + return (AllocThreadMethodRef) image.filterByThread(o,(DataR) peer); + } + + /** Returns specific element of MonThreadMethods list. */ + public MonThreadMethodRef getMonThreadMethod(ThreadRef peer) { + List o=getMonThreadMethods(); + return (MonThreadMethodRef) image.filterByThread(o,(DataR) peer); + } + + /** Returns specific element of AllocTypeMethods list. */ + public AllocTypeMethodRef getAllocTypeMethod(TypeRef peer) { + List o=getAllocTypeMethods(); + return (AllocTypeMethodRef) image.filterByType(o,(DataR) peer); } Index: MonThreadMethodR.java =================================================================== RCS file: /cvsroot/javaprofiler/jpiimpl/net/sourceforge/javaprofiler/jpiimpl/realtime/MonThreadMethodR.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** MonThreadMethodR.java 15 May 2002 08:26:36 -0000 1.2 --- MonThreadMethodR.java 28 May 2002 17:13:49 -0000 1.3 *************** *** 143,147 **** * </code> if this root is N / A. */ ! public Location getLocation() { needConstructed(); return location; --- 143,147 ---- * </code> if this root is N / A. */ ! public DataR getLocation() { needConstructed(); return location; *************** *** 256,261 **** } public String toString() { return getThreadR() + "-" + getLocation(); } ! } \ No newline at end of file --- 256,279 ---- } + /** Returns CPUThreadMethodRef of the same Thread and the same Method. */ + public CPUThreadMethodRef getSiblingCPU() { + needConstructed(); + if (!image.getAlwaysRefresh()) + thread.refreshCPUThreadMethods(); + List o=thread.getCPUThreadMethods(); + return (CPUThreadMethodRef) image.filterByLocation(o, getLocation()); + } + + /** Returns AllocThreadMethodRef of the same Thread and the same Method. */ + public AllocThreadMethodRef getSiblingAlloc() { + needConstructed(); + if (!image.getAlwaysRefresh()) + thread.refreshAllocThreadMethods(); + List o=thread.getAllocThreadMethods(); + return (AllocThreadMethodRef) image.filterByLocation(o, getLocation()); + } + public String toString() { return getThreadR() + "-" + getLocation(); } ! } Index: MonThreadTraceR.java =================================================================== RCS file: /cvsroot/javaprofiler/jpiimpl/net/sourceforge/javaprofiler/jpiimpl/realtime/MonThreadTraceR.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** MonThreadTraceR.java 15 May 2002 08:26:36 -0000 1.2 --- MonThreadTraceR.java 28 May 2002 17:13:49 -0000 1.3 *************** *** 131,135 **** * </code> if this root is N / A. */ ! public Location getLocation() { needConstructed(); return location; --- 131,135 ---- * </code> if this root is N / A. */ ! public DataR getLocation() { needConstructed(); return location; *************** *** 253,258 **** } public String toString() { return getThreadR() + "-" + getLocation(); } ! } \ No newline at end of file --- 253,278 ---- } + /** Returns CPUThreadTraceRef of the same Thread and the same Trace. */ + public CPUThreadTraceRef getSiblingCPU() { + needConstructed(); + if (!image.getAlwaysRefresh()) + thread.refreshCPUThreadTraces(); + List o=thread.getCPUThreadTraces(); + return (CPUThreadTraceRef) image.filterByLocationFrames(o, + location.getFrames()); + } + + /** Returns AllocThreadTraceRef of the same Thread and the same Trace. */ + public AllocThreadTraceRef getSiblingAlloc() { + needConstructed(); + if (!image.getAlwaysRefresh()) + thread.refreshAllocThreadTraces(); + List o=thread.getAllocThreadTraces(); + return (AllocThreadTraceRef) image.filterByLocationFrames(o, + location.getFrames()); + } + public String toString() { return getThreadR() + "-" + getLocation(); } ! } Index: MonTraceR.java =================================================================== RCS file: /cvsroot/javaprofiler/jpiimpl/net/sourceforge/javaprofiler/jpiimpl/realtime/MonTraceR.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** MonTraceR.java 15 May 2002 08:26:36 -0000 1.3 --- MonTraceR.java 28 May 2002 17:13:49 -0000 1.4 *************** *** 43,47 **** * @author Lukas Petru */ ! public class MonTraceR extends Location implements MonTraceRef { /** Tells if any data was loaded from profiled VM about this Type. */ private boolean isReady; --- 43,47 ---- * @author Lukas Petru */ ! public class MonTraceR extends DataR implements MonTraceRef { /** Tells if any data was loaded from profiled VM about this Type. */ private boolean isReady; *************** *** 165,169 **** } ! public Location getLocation() { return this; } --- 165,169 ---- } ! public DataR getLocation() { return this; } *************** *** 235,238 **** --- 235,262 ---- } + /** Returns AllocTraceRef of the same Trace. */ + public AllocTraceRef getSiblingAlloc() { + needConstructed(); + if (!image.getAlwaysRefresh()) + image.refreshAllocTraces(); + List o=image.getAllocTraces(); + return (AllocTraceRef) image.filterByFrames(o, getFrames()); + } + + /** Returns CPUTraceRef of the same Trace. */ + public CPUTraceRef getSiblingCPU() { + needConstructed(); + if (!image.getAlwaysRefresh()) + image.refreshCPUTraces(); + List o=image.getCPUTraces(); + return (CPUTraceRef) image.filterByFrames(o, getFrames()); + } + + /** Returns specific element of MonThreadTraces list. */ + public MonThreadTraceRef getMonThreadTrace(ThreadRef peer) { + List o=getMonThreadTraces(); + return (MonThreadTraceRef) image.filterByThread(o,(DataR) peer); + } + public String toString() { return "trace of " + getMethod(); Index: ThreadGroupR.java =================================================================== RCS file: /cvsroot/javaprofiler/jpiimpl/net/sourceforge/javaprofiler/jpiimpl/realtime/ThreadGroupR.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** ThreadGroupR.java 15 May 2002 08:26:36 -0000 1.2 --- ThreadGroupR.java 28 May 2002 17:13:49 -0000 1.3 *************** *** 126,130 **** * </code> if this root is N / A. */ ! public Location getLocation() { return null; } --- 126,130 ---- * </code> if this root is N / A. */ ! public DataR getLocation() { return null; } Index: ThreadR.java =================================================================== RCS file: /cvsroot/javaprofiler/jpiimpl/net/sourceforge/javaprofiler/jpiimpl/realtime/ThreadR.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** ThreadR.java 15 May 2002 08:26:36 -0000 1.5 --- ThreadR.java 28 May 2002 17:13:49 -0000 1.6 *************** *** 323,327 **** * </code> if this root is N / A. */ ! public Location getLocation() { return null; } --- 323,327 ---- * </code> if this root is N / A. */ ! public DataR getLocation() { return null; } *************** *** 466,469 **** --- 466,511 ---- Integer getId() { return objId; + } + + /** Returns specific element of CPUThreadMethods list. */ + public CPUThreadMethodRef getCPUThreadMethod(MethodRef peer) { + List o=getCPUThreadMethods(); + return (CPUThreadMethodRef) image.filterByLocation(o, (DataR) peer); + } + + /** Returns specific element of CPUThreadTraces list. */ + public CPUThreadTraceRef getCPUThreadTrace(CPUTraceRef peer) { + List o=getCPUThreadTraces(); + return (CPUThreadTraceRef) image.filterByLocation(o, (DataR) peer); + } + + /** Returns specific element of AllocThreadMethods list. */ + public AllocThreadMethodRef getAllocThreadMethod(MethodRef peer) { + List o=getAllocThreadMethods(); + return (AllocThreadMethodRef) image.filterByLocation(o, (DataR) peer); + } + + /** Returns specific element of AllocThreadTraces list. */ + public AllocThreadTraceRef getAllocThreadTrace(AllocTraceRef peer) { + List o=getAllocThreadTraces(); + return (AllocThreadTraceRef) image.filterByLocation(o, (DataR) peer); + } + + /** Returns specific element of MonThreadMethods list. */ + public MonThreadMethodRef getMonThreadMethod(MethodRef peer) { + List o=getMonThreadMethods(); + return (MonThreadMethodRef) image.filterByLocation(o, (DataR) peer); + } + + /** Returns specific element of MonThreadTraces list. */ + public MonThreadTraceRef getMonThreadTrace(MonTraceRef peer) { + List o=getMonThreadTraces(); + return (MonThreadTraceRef) image.filterByLocation(o, (DataR) peer); + } + + /** Returns specific element of AllocTypeThreads list. */ + public AllocTypeThreadRef getAllocTypeThread(TypeRef peer) { + List o=getAllocTypeThreads(); + return (AllocTypeThreadRef) image.filterByType(o, (DataR) peer); } |