From: Pavel V. <va...@us...> - 2002-05-06 17:33:04
|
Update of /cvsroot/javaprofiler/jpiimpl/net/sourceforge/javaprofiler/jpiimpl/data In directory usw-pr-cvs1:/tmp/cvs-serv27708 Added Files: AllocTypeThreadData.java AllocTypeThreadMethodData.java AllocTypeThreadTraceData.java AllStatIDObjectData.java FieldData.java FrameData.java TypeData.java Log Message: new api implemention --- NEW FILE: AllocTypeThreadData.java --- /* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License Version * 1.0 (the "License"). You may not use this file except in compliance with * the License. A copy of the License is available at http://www.sun.com/ * * The Original Code is the Java Profiler module. * The Initial Developers of the Original Code are Jan Stola, Pavel Vacha, * Michal Pise, Petr Luner, Lukas Petru and Marek Przeczek. * Portions created by Jan Stola are Copyright (C) 2000-2001. All Rights Reserved. * Portions created by Pavel Vacha are Copyright (C) 2000-2001. All Rights Reserved. * Portions created by Michal Pise are Copyright (C) 2000-2001. All Rights Reserved. * Portions created by Petr Luner are Copyright (C) 2000-2001. All Rights Reserved. * Portions created by Lukas Petru are Copyright (C) 2000-2001. All Rights Reserved. * Portions created by Marek Przeczek are Copyright (C) 2000-2001. All Rights Reserved. * * Contributors: Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. */ package net.sourceforge.javaprofiler.jpiimpl.data; import java.util.*; import net.sourceforge.javaprofiler.jpiimpl.commun.*; import net.sourceforge.javaprofiler.api.*; /** * Allocation data for one thread and class. * * @author Jan Stola, Pavel Vacha, Lukas Petru */ public class AllocTypeThreadData extends AllocStatIDObjectData implements AllocTypeThreadRef { /** Allocation data for this thread. */ private ThreadData thread; /** Allocation data for this type. */ private TypeData type; // lists for children private final List allocTypeThreadMethods=new ArrayList(0); private final List allocTypeThreadTraces=new ArrayList(0); // unmodifiable variants of lists for children private final List roAllocTypeThreadMethods=Collections.unmodifiableList( allocTypeThreadMethods); private final List roAllocTypeThreadTraces=Collections.unmodifiableList( allocTypeThreadTraces); /** * Creates new AllocTypeThreadData. * * @param ID unique ID of this object. * @param thread allocation data for this thread. * @param type allocation data for this class. */ AllocTypeThreadData(Integer ID, ThreadData thread, TypeData type) { super(ID); this.thread=thread; this.type=type; } /** * Creates new AllocTypeThreadData. * * @param sid data returned by communication layer * @param thread allocation data for this thread. * @param type allocation data for this type. */ AllocTypeThreadData(IProf.sID sid, ThreadData thread, TypeData type) { this( new Integer(sid.objId) , thread, type ); //if (sid.alloc!=null) //do not test this, its an error setStat(sid.alloc); } /** * Adds method where an instance of this class was allocated * (in given thread). * * @param method method where an instance of this class was allocated * (in given thread). */ void addMethod(AllocTypeThreadMethodData method) { allocTypeThreadMethods.add(method); //pending MAP } /** * Adds trace where an instance of this class was allocated * (in given thread). * * @param trace method where an instance of this class was allocated * (in given thread). */ void addTrace(AllocTypeThreadTraceData trace) { allocTypeThreadTraces.add(trace); //pending MAP } // ---------- return parents /** * Return allocation data for this class. * * @return allocation data for this class. */ public TypeRef getType() { return type; } /** * Returns allocation data for this thread. * * @return allocation data for this thread. */ public ThreadRef getThread() { return thread; } // ---------- return child Lists /** * Returns unmodifiable list of methods where an instance of this class was allocated * (and in this thread). * * @return unmodifiable list of {@link AllocTypeThreadMethodRef} objects. */ public List getAllocTypeThreadMethods() { return roAllocTypeThreadMethods; } /** * Returns statistic data for given method where an instances of this class were * allocated (and in this thread). * * @param peer method. * @return method where an instances of this class were * allocated (and in this thread) or <code>null</code> if such thread does * not exist. */ public AllocTypeThreadMethodRef getAllocTypeThreadMethod(MethodRef peer) { return null; //PENDING } /** * Returns unmodifiable list of traces where an instance of this class was allocated * (in given thread). * * @return unmodifiable list of {@link AllocTypeThreadTraceRef} objects. */ public List getAllocTypeThreadTraces() { return roAllocTypeThreadTraces; } /** * Returns statistic data for given trace where an instances of this class were * allocated (and in this thread). * * @param peer trace. * @return trace where an instances of this class were * allocated (and in this thread) or <code>null</code> if such thread does * not exist. */ public AllocTypeThreadTraceRef getAllocTypeThreadTrace(AllocTraceRef peer) { return null; //PENDING } public String toString() { return getType() + "-" + getThread(); } } /* * $Log: AllocTypeThreadData.java,v $ * Revision 1.1 2002/05/06 17:33:01 vachis * new api implemention * */ --- NEW FILE: AllocTypeThreadMethodData.java --- /* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License Version * 1.0 (the "License"). You may not use this file except in compliance with * the License. A copy of the License is available at http://www.sun.com/ * * The Original Code is the Java Profiler module. * The Initial Developers of the Original Code are Jan Stola, Pavel Vacha, * Michal Pise, Petr Luner, Lukas Petru and Marek Przeczek. * Portions created by Jan Stola are Copyright (C) 2000-2001. All Rights Reserved. * Portions created by Pavel Vacha are Copyright (C) 2000-2001. All Rights Reserved. * Portions created by Michal Pise are Copyright (C) 2000-2001. All Rights Reserved. * Portions created by Petr Luner are Copyright (C) 2000-2001. All Rights Reserved. * Portions created by Lukas Petru are Copyright (C) 2000-2001. All Rights Reserved. * Portions created by Marek Przeczek are Copyright (C) 2000-2001. All Rights Reserved. * * Contributors: Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. */ package net.sourceforge.javaprofiler.jpiimpl.data; import java.util.*; import net.sourceforge.javaprofiler.jpiimpl.commun.*; import net.sourceforge.javaprofiler.api.*; /** * Allocation data for one class, method and thread. * * @author Jan Stola, Pavel Vacha, Lukas Petru */ public class AllocTypeThreadMethodData extends AllocStatIDObjectData implements AllocTypeThreadMethodRef { /** Allocation data for this type and thread. */ private AllocTypeThreadData typeThread; /** Allocation data for this type and method. */ private AllocTypeMethodData typeMethod; /** Allocation data for this method and thread. */ private AllocThreadMethodData threadMethod; // lists for children private final List allocTypeThreadTraces=new ArrayList(0); // unmodifiable variants of lists for children private final List roAllocTypeThreadTraces=Collections.unmodifiableList( allocTypeThreadTraces); /** * Creates new AllocTypeThreadMethodData. * * @param ID unique ID of this object. * @param typeThread allocation data for this type and thread. * @param typeMethod allocation data for this type and method. * @param threadMethod allocation data for this thread and method. */ AllocTypeThreadMethodData(Integer ID, AllocTypeThreadData typeThread, AllocTypeMethodData typeMethod, AllocThreadMethodData threadMethod) { super(ID); this.typeThread=typeThread; this.typeMethod=typeMethod; this.threadMethod=threadMethod; } /** * Creates new AllocTypeThreadMethodData. * * @param sid data returned by communication layer * @param threadType allocation data for this type and thread. * @param typeMethod allocation data for this type and method. * @param threadMethod allocation data for this thread and method. */ AllocTypeThreadMethodData(IProf.sID sid, AllocTypeThreadData threadType, AllocTypeMethodData typeMethod, AllocThreadMethodData threadMethod) { this( new Integer(sid.objId), threadType, typeMethod, threadMethod ); //if (sid.alloc!=null) //do not test this, its an error setStat(sid.alloc); } /** * Adds trace of this method in this thread where instances of this * type (class or array of classes) were allocated. * * @param trace trace of this method in this thread where instances of this * type were allocated. */ void addTrace(AllocTypeThreadTraceData trace) { allocTypeThreadTraces.add(trace); //pending MAP } // ---------- return parents /** * Returns allocation data for this type and method. * * @return allocation data for this type and method. */ public AllocTypeMethodRef getAllocTypeMethod() { return typeMethod; } /** * Returns allocation data for this thread and method. * * @return allocation data for this thread and method. */ public AllocThreadMethodRef getAllocThreadMethod() { return threadMethod; } /** * Returns allocation data for this type and thread. * * @return allocation data for this type and thread. */ public AllocTypeThreadRef getAllocTypeThread() { return typeThread; } // ---------- return child Lists /** * Returns unmodifiable list of traces of this method in this thread where instances of this * type (class or array of classes) were allocated. * * @return unmodifiable list of {@link AllocTypeThreadTraceRef} objects. */ public List getAllocTypeThreadTraces() { return roAllocTypeThreadTraces; } /** * Returns statistic data for given trace. The trace of this method in this thread where * instances of this class were allocated. * * @param peer trace. * @return trace of this method in this thread where * instances of this class were allocated or <code>null</code> if such * trace does not exist. */ public AllocTypeThreadTraceRef getAllocTypeThreadTrace(AllocTraceRef peer) { return null; //PENDING } // ------------- roots /** * Returns allocation data for this thread (root object). * * @return allocation data for this thread (root object). */ public ThreadRef getThread() { return getAllocTypeThread().getThread(); } /** * Returns allocation data for this type (root object). * * @return allocation data for this type (root object). */ public TypeRef getType() { return getAllocTypeThread().getType(); } /** * Returns allocation data for this method (root object). * * @return allocation data for this method (root object). */ public MethodRef getMethod() { return getAllocTypeMethod().getMethod(); } public String toString() { return getType() + "-" + getThread() + "-" + getMethod(); } } /* * $Log: AllocTypeThreadMethodData.java,v $ * Revision 1.1 2002/05/06 17:33:01 vachis * new api implemention * */ --- NEW FILE: AllocTypeThreadTraceData.java --- /* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License Version * 1.0 (the "License"). You may not use this file except in compliance with * the License. A copy of the License is available at http://www.sun.com/ * * The Original Code is the Java Profiler module. * The Initial Developers of the Original Code are Jan Stola, Pavel Vacha, * Michal Pise, Petr Luner, Lukas Petru and Marek Przeczek. * Portions created by Jan Stola are Copyright (C) 2000-2001. All Rights Reserved. * Portions created by Pavel Vacha are Copyright (C) 2000-2001. All Rights Reserved. * Portions created by Michal Pise are Copyright (C) 2000-2001. All Rights Reserved. * Portions created by Petr Luner are Copyright (C) 2000-2001. All Rights Reserved. * Portions created by Lukas Petru are Copyright (C) 2000-2001. All Rights Reserved. * Portions created by Marek Przeczek are Copyright (C) 2000-2001. All Rights Reserved. * * Contributors: Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. */ package net.sourceforge.javaprofiler.jpiimpl.data; import net.sourceforge.javaprofiler.jpiimpl.commun.*; import net.sourceforge.javaprofiler.api.*; /** * Allocation data for one class, thread and trace. * * @author Jan Stola, Pavel Vacha, Lukas Petru */ public class AllocTypeThreadTraceData extends AllocStatIDObjectData implements AllocTypeThreadTraceRef { /** Allocation data for this type and trace. */ private AllocTypeTraceData typeTrace; /** Allocation data for this type, thread and method. */ private AllocTypeThreadMethodData threadTypeMethod; /** Allocation data for this thread and trace. */ private AllocThreadTraceData threadTrace; /** * Creates new AllocTypeThreadTraceData. * * @param ID unique ID of this object. * @param typeTrace allocation data for this type and trace. * @param threadTypeMethod allocation data for this type, thread and method. * @param threadTrace allocation data for this thread and trace. */ AllocTypeThreadTraceData(Integer ID, AllocTypeTraceData typeTrace, AllocTypeThreadMethodData threadTypeMethod, AllocThreadTraceData threadTrace) { super(ID); this.typeTrace=typeTrace; this.threadTypeMethod=threadTypeMethod; this.threadTrace=threadTrace; } /** * Creates new AllocTypeThreadTraceData. * * @param sid data returned by communication layer * @param typeTrace allocation data for this type and trace. * @param threadTypeMethod allocation data for this type, thread and method. * @param threadTrace allocation data for this thread and trace. */ AllocTypeThreadTraceData(IProf.sID sid, AllocTypeTraceData classTrace, AllocTypeThreadMethodData threadClassMethod, AllocThreadTraceData threadTrace) { this( new Integer(sid.objId), classTrace, threadClassMethod, threadTrace ); //if (sid.alloc!=null) //do not test this, its an error setStat(sid.alloc); } // ---------- return parents /** * Returns allocation data for this type, thread and method. * * @return allocation data for this type, thread and method. */ public AllocTypeThreadMethodRef getAllocTypeThreadMethod() { return threadTypeMethod; } /** * Returns allocation data for this type and trace. * * @return allocation data for this type and trace. */ public AllocTypeTraceRef getAllocTypeTrace() { return typeTrace; } /** * Returns allocation data for this thread and trace. * * @return allocation data for this thread and trace. */ public AllocThreadTraceRef getAllocThreadTrace() { return threadTrace; } /** * Returns allocation data for this type and thread. * * @return allocation data for this type and thread. */ public AllocTypeThreadRef getAllocTypeThread() { return threadTypeMethod.getAllocTypeThread(); } // ---------- return child Lists // ------------- roots /** * Returns allocation data for this thread (root object). * * @return allocation data for this thread (root object). */ public ThreadRef getThread() { return getAllocTypeThread().getThread(); } /** * Returns allocation data for this type (root object). * * @return allocation data for this type (root object). */ public TypeRef getType() { return getAllocTypeThread().getType(); } /** * Returns allocation data for this trace (root object). * * @return allocation data for this trace (root object). */ public AllocTraceRef getAllocTrace() { return getAllocTypeTrace().getAllocTrace(); } public String toString() { return getType() + "-" + getThread() + "-" + getAllocTrace(); } } /* * $Log: AllocTypeThreadTraceData.java,v $ * Revision 1.1 2002/05/06 17:33:01 vachis * new api implemention * */ --- NEW FILE: AllStatIDObjectData.java --- /* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License Version * 1.0 (the "License"). You may not use this file except in compliance with * the License. A copy of the License is available at http://www.sun.com/ * * The Original Code is the Java Profiler module. * The Initial Developers of the Original Code are Jan Stola, Pavel Vacha, * Michal Pise, Petr Luner, Lukas Petru and Marek Przeczek. * Portions created by Jan Stola are Copyright (C) 2000-2001. All Rights Reserved. * Portions created by Pavel Vacha are Copyright (C) 2000-2001. All Rights Reserved. * Portions created by Michal Pise are Copyright (C) 2000-2001. All Rights Reserved. * Portions created by Petr Luner are Copyright (C) 2000-2001. All Rights Reserved. * Portions created by Lukas Petru are Copyright (C) 2000-2001. All Rights Reserved. * Portions created by Marek Przeczek are Copyright (C) 2000-2001. All Rights Reserved. * * Contributors: Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. */ package net.sourceforge.javaprofiler.jpiimpl.data; import net.sourceforge.javaprofiler.jpiimpl.commun.IProf; import net.sourceforge.javaprofiler.api.*; /** * Class with statistic data for memory, CPU and monitors profiling. * * * @author Pavel Vacha */ public abstract class AllStatIDObjectData extends IDObjectData implements AllocStatData, AllocStat, CPUStatData, CPUStat, MonStatData, MonStat{ /** * Constructor to be used by subclasses. * * @param ID unique ID. */ protected AllStatIDObjectData(Integer ID) { super(ID); } /** Fills statistics on instances. * * @param stat Object with statistics on instances. */ public void setStat(IProf.sID sid) { if (sid.cpu != null) setStat(sid.cpu); if (sid.mon != null) setStat(sid.mon); if (sid.alloc!=null) { setStat(sid.alloc); } } //ALLOC ------------------------------------------------------------------ /** Number of live instances. */ private long numLiveInstances; /** Total number of created instances. */ private long numTotalInstances; /** Amount of space used by live instances. */ private long sizeLiveInstances; /** Total amount of space used by created instances. */ private long sizeTotalInstances; /** * Fills statistics on instances. * * @param stat Object with statistics on instances. */ public void setStat(IProf.sAllocStatData stat) { numLiveInstances=stat.allocNumInstancesLive; numTotalInstances=stat.allocNumInstancesTotal; sizeLiveInstances=stat.allocSizeInstancesLive; sizeTotalInstances=stat.allocSizeInstancesTotal; } /** * Returns number of live instances. * * @return number of live instances. */ public long getLiveInstancesCount() { return numLiveInstances; } /** * Returns total number of created instances. * * @return total number of created instances. */ public long getTotalInstancesCount() { return numTotalInstances; } /** * Returns amount of space used by live instances. * * @return amount of space used by live instances. */ public long getLiveInstancesSize() { return sizeLiveInstances; } /** * Returns total amount of space used by created instances. * * @return total amount of space used by created instances. */ public long getTotalInstancesSize() { return sizeTotalInstances; } /** * Adds given size (in bytes) to the statistics. * * @param size size of newly created instance. */ public void addToStat(int size) { numLiveInstances++; numTotalInstances++; sizeLiveInstances+=size; sizeTotalInstances+=size; } /** * Removes given size (in bytes) from the statistics; * * @param size of the garbage collected instance. */ public void subFromStat(int size) { numLiveInstances--; sizeLiveInstances-=size; } /** * Adds listener to changes in Alloc data * *@param listener to Alloc data changes */ public void addAllocStatListener( AllocStatListener listener) { } /** * Removes listener to changes in Alloc data * *@param listener to Alloc data changes */ public void removeAllocStatListener( AllocStatListener listener) { } //CPU ----------------------------------------------------------- //** Pure time spent in this method or trace. */ private long cpuPureTime; /** How many times was this method or trace called. */ private long cpuHits; /** * Adds given number of hits and time to the statistics. * * @param hits how many times was this method or trace called. * @param time pure time spent in this method or trace. */ public void addToCPUStat(long hits, long time) { this.cpuHits+=hits; this.cpuPureTime+=time; } /** * Returns how many times was this method or trace called. * * @return how many times was this method or trace called. */ public long getCPUHitsCount() { return cpuHits; } /** * Returns pure time spent in this method or trace. * * @return pure time spent in this method or trace. */ public long getCPUPureTime() { return cpuPureTime; } /** Fills statistics on instances. * * @param stat Object with statistics on instances. */ public void setStat(IProf.sCpuStatData stat) { cpuPureTime=stat.pureTime; cpuHits=stat.hits; } /** * Adds listener to changes in CPU data * *@param listener to CPU data changes */ public void addCPUStatListener( CPUStatListener listener) { } /** * Adds listener to changes in CPU data * *@param listener to CPU data changes */ public void removeCPUStatListener( CPUStatListener listener) { } //MON ----------------------------------------------------------------- /** Pure time spent by waiting for monitors. */ private long monPureTime; /** How many times waited this method */ private long monHits; /** * Adds given number of hits and time to the statistics. * * @param hits how many times waited this method * @param time pure time spent by waiting for monitors */ public void addToMonStat(long hits, long time) { this.monHits+=hits; this.monPureTime+=time; } /** * Returns how many times waited this method * * @return how many times waited this method */ public long getMonHitsCount() { return monHits; } /** * Returns pure time spent by waiting for monitors * * @return pure time spent by waiting for monitors */ public long getMonPureTime() { return monPureTime; } /** Fills statistics on instances. * * @param stat Object with statistics on instances. */ public void setStat(IProf.sMonStatData stat) { monPureTime=stat.time; monHits=stat.hits; } /** * Adds listener to changes in Monitor data * *@param listener to monitor data changes */ public void addMonStatListener( MonStatListener listener) { } /** * Adds listener to changes in Monitor data * *@param listener to monitor data changes */ public void removeMonStatListener( MonStatListener listener) { } } --- NEW FILE: FieldData.java --- /* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License Version * 1.0 (the "License"). You may not use this file except in compliance with * the License. A copy of the License is available at http://www.sun.com/ * * The Original Code is the Java Profiler module. * The Initial Developers of the Original Code are Jan Stola, Pavel Vacha, * Michal Pise, Petr Luner, Lukas Petru and Marek Przeczek. * Portions created by Jan Stola are Copyright (C) 2000-2001. All Rights Reserved. * Portions created by Pavel Vacha are Copyright (C) 2000-2001. All Rights Reserved. * Portions created by Michal Pise are Copyright (C) 2000-2001. All Rights Reserved. * Portions created by Petr Luner are Copyright (C) 2000-2001. All Rights Reserved. * Portions created by Lukas Petru are Copyright (C) 2000-2001. All Rights Reserved. * Portions created by Marek Przeczek are Copyright (C) 2000-2001. All Rights Reserved. * * Contributors: Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. */ package net.sourceforge.javaprofiler.jpiimpl.data; import net.sourceforge.javaprofiler.jpiimpl.commun.*; import net.sourceforge.javaprofiler.api.*; /** * Static or instance field of class. * * @author Jan Stola, Pavel Vacha, Lukas Petru */ public class FieldData extends IDObjectData implements FieldRef { /** Name of the field. */ private String name; /** Signature of the field. */ private String signature; private final ClassData fieldClass; private final boolean isStatic; /** * Creates new ClassFieldData * * @param ID unique ID of this object. * @param name name of the field. * @param signature signature of the field. */ FieldData(Integer ID, String name, String signature, ClassData parentClass, boolean aStatic) { super(ID); this.name=name; this.signature=signature; fieldClass=parentClass; isStatic=aStatic; } /** * Creates new ClassFieldData * * @param sid data returned by communication layer . */ FieldData(IProf.sID sid, ClassData parentClass, boolean aStatic) { this( new Integer(sid.objId), ((IProf.sClassFieldInfo) sid.info).fieldName, ((IProf.sClassFieldInfo) sid.info).fieldSignature, parentClass, aStatic); } // -------------- info getter methods /** * Returns name of the field. * * @return name of the field. */ public String getName() { return name; } /** * Returns signature of the field. * * @return signature of the field. */ public String getSignature() { return signature; } /** * Returns ClassRef which the field belongs to. * * @return parentClass of the field. */ public ClassRef getParentClass() { return fieldClass; } /** *Returns whether the field is static field. * *@return whether the field is static. */ public boolean isStatic() { return isStatic; } public String toString() { return getName(); } } /* * $Log: FieldData.java,v $ * Revision 1.1 2002/05/06 17:33:01 vachis * new api implemention * * Revision 1.4 2002/03/03 01:20:08 vachis * type of ID changed from int to Integer * * Revision 1.1.1.1 2001/07/11 22:27:58 stolis * no message * */ --- NEW FILE: FrameData.java --- /* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License Version * 1.0 (the "License"). You may not use this file except in compliance with * the License. A copy of the License is available at http://www.sun.com/ * * The Original Code is the Java Profiler module. * The Initial Developers of the Original Code are Jan Stola, Pavel Vacha, * Michal Pise, Petr Luner, Lukas Petru and Marek Przeczek. * Portions created by Jan Stola are Copyright (C) 2000-2001. All Rights Reserved. * Portions created by Pavel Vacha are Copyright (C) 2000-2001. All Rights Reserved. * Portions created by Michal Pise are Copyright (C) 2000-2001. All Rights Reserved. * Portions created by Petr Luner are Copyright (C) 2000-2001. All Rights Reserved. * Portions created by Lukas Petru are Copyright (C) 2000-2001. All Rights Reserved. * Portions created by Marek Przeczek are Copyright (C) 2000-2001. All Rights Reserved. * * Contributors: Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. */ package net.sourceforge.javaprofiler.jpiimpl.data; import java.io.Serializable; import net.sourceforge.javaprofiler.api.*; /** * Frame of some trace. * * @author Jan Stola, Pavel Vacha */ public class FrameData implements Serializable, FrameRef { /** Line number of this frame in the source file. */ private final int line; /** Method of this frame. */ private final MethodData method; private final FrameData caller; /** * Creates new FrameData. * * @param line line number of this frame in the source file. * @param method method of this frame. */ FrameData(int line, MethodData method, FrameData callerFrame) { this.line=line; this.method=method; caller=callerFrame; } // -------------- info getter methods /** * Returns line line number of this frame in the source file. * * @return line line number of this frame in the source file. */ public int getLineNo() { return line; } /** * Returns method of this frame. * * @return method of this frame. */ public MethodRef getMethod() { return method; } /** * Returns caller of this frame. * * @return caller of this frame. */ public FrameRef getCallerFrame() { return caller; } public String toString() { return getMethod() + ":" + getLineNo(); } } /* * $Log: FrameData.java,v $ * Revision 1.1 2002/05/06 17:33:01 vachis * new api implemention * * Revision 1.3 2002/04/20 10:25:55 stolis * Implements Serializable (is contained in Snapshot). * * Revision 1.1.1.1 2001/07/11 22:28:10 stolis * no message * */ --- NEW FILE: TypeData.java --- /* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License Version * 1.0 (the "License"). You may not use this file except in compliance with * the License. A copy of the License is available at http://www.sun.com/ * * The Original Code is the Java Profiler module. * The Initial Developers of the Original Code are Jan Stola, Pavel Vacha, * Michal Pise, Petr Luner, Lukas Petru and Marek Przeczek. * Portions created by Jan Stola are Copyright (C) 2000-2001. All Rights Reserved. * Portions created by Pavel Vacha are Copyright (C) 2000-2001. All Rights Reserved. * Portions created by Michal Pise are Copyright (C) 2000-2001. All Rights Reserved. * Portions created by Petr Luner are Copyright (C) 2000-2001. All Rights Reserved. * Portions created by Lukas Petru are Copyright (C) 2000-2001. All Rights Reserved. * Portions created by Marek Przeczek are Copyright (C) 2000-2001. All Rights Reserved. * * Contributors: Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. */ package net.sourceforge.javaprofiler.jpiimpl.data; import java.util.*; import net.sourceforge.javaprofiler.jpiimpl.commun.*; import net.sourceforge.javaprofiler.api.*; /** * Allocation data for one class. * * @author Jan Stola, Pavel Vacha, Lukas Petru */ public class TypeData extends AllocStatIDObjectData implements TypeRef { /** Class related to this type (class or array of classes), may be NULL for arrays of ints,bytes,etc. */ private ClassData componentClass; /** * Type of array (for example JVMPI_NORMAL_OBJECT, JVMPI_CLASS, * JVMPI_BOOLEAN etc.) */ private int arrayType; private String name; private boolean isArray; private boolean isPrimitiveArray; private final VirtualMachineImageRef vmImage; // lists for children private final List allocTypeMethods=new ArrayList(0); private final List allocTypeTraces=new ArrayList(0); private final List allocTypeThreads=new ArrayList(0); // unmodifiable variants of lists for children private final List roAllocTypeMethods=Collections.unmodifiableList( allocTypeMethods); private final List roAllocTypeTraces=Collections.unmodifiableList( allocTypeTraces); private final List roAllocTypeThreads=Collections.unmodifiableList( allocTypeThreads); /** * Creates new TypeData. * * @param ID unique ID of this object. * @param classData class related to this type (class or array of classes), may be NULL for arrays of ints,bytes,etc.. * @param typeID object ID of the AllocType object. * @param arrayType arrayType of this type. * @param virtualMachineImage VirtualMachineImage this method belongs to. The VirtualMachineImage could be live * (realtime implementation) or static (snaphshot). */ TypeData(Integer ID, ClassData componentClass, int arrayType, VirtualMachineImageRef vmImage) { super(ID); this.componentClass=componentClass; this.arrayType=arrayType; this.vmImage=vmImage; isArray = true; isPrimitiveArray = componentClass == null; switch ( arrayType ) { case IProf.JVMPI_NORMAL_OBJECT: name = componentClass.getName(); isArray = false; break; case IProf.JVMPI_CLASS: name = "[" + componentClass.getName(); break; case IProf.JVMPI_BOOLEAN: name = "[Z"; break; case IProf.JVMPI_BYTE: name = "[B"; break; case IProf.JVMPI_CHAR: name = "[C"; break; case IProf.JVMPI_SHORT: name = "[S"; break; case IProf.JVMPI_INT: name = "[I"; break; case IProf.JVMPI_LONG: name = "[J"; break; case IProf.JVMPI_FLOAT: name = "[F"; break; case IProf.JVMPI_DOUBLE: name = "[D"; break; default: name = ""; } } /** * Creates new TypeData. * @param sid data returned by communication layer * @param componentClass class related to this type (class or array of classes), may be NULL for arrays of ints,bytes,etc.. * @param virtualMachineImage VirtualMachineImage this method belongs to. The VirtualMachineImage could be live * (realtime implementation) or static (snaphshot). */ TypeData(IProf.sID sid, ClassData componentClass, VirtualMachineImageRef vmImage) { this( new Integer(sid.objId), componentClass, ((IProf.sObjectInfo) sid.info).isArray, vmImage ); //if (sid.alloc != null) //do not test this, its an error setStat(sid.alloc); } /** * Adds method where instance of this type (class or array of classes) was allocated. * * @param method method where instance of this class were allocated. */ void addMethod(AllocTypeMethodData method) { allocTypeMethods.add(method); //pending MAP } /** * Adds thread where instances of this type (class or array of classes) were allocated. * * @param thread where instances of this type (class or array of classes) were allocated. */ void addThread(AllocTypeThreadData thread) { allocTypeThreads.add(thread); //pending MAP } /** * Adds trace where instance of this type (class or array of classes) was allocated. * * @param trace method where instance of this class were allocated. */ void addTrace(AllocTypeTraceData trace) { allocTypeTraces.add(trace); //pending MAP } // -------------- info getter methods /** Returns name of a type. */ public String getName() { return name; } /** Returns component class of this type. */ public ClassRef getComponentClass() { return componentClass; } /** Returns true, if this type is an array. */ public boolean isArray() { return isArray; } /** Returns true, if this type is an array of primitive component type. */ public boolean isArrayOfPrimitives() { return isPrimitiveArray; } /** * Returns VirtualMachineImage this method belongs to. The VirtualMachineImage could be live * (realtime implementation) or static (snaphshot). * * @return VirtualMachineImage this method belongs to. */ public VirtualMachineImageRef getVirtualMachineImage() { return vmImage; } // -------------- children lists getter methods /** * Return unmodifiable list of trace in which instances of this type (class or array of classes) were allocated. * * @return lunmodifiable ist between {@link AllocTypeTraceRef} objects. */ public List getAllocTypeTraces() { return roAllocTypeTraces; } /** * Returns statistic data for given trace where instance of this type (class or array of classes) was allocated. * * @param peer trace. * @return trace where instance of this type (class or array of classes) was allocated * or <code>null</code> if such method does not exist. */ public AllocTypeTraceRef getAllocTypeTrace(AllocTraceRef peer) { return null; //PENDING; } /** * Returns unmodifiable list of methods where instance of this type (class or array of classes) were allocated. * * @return unmodifiable list between {@link AllocTypeMethodRef} objects. */ public List getAllocTypeMethods() { return roAllocTypeMethods; } /** * Returns statistic data for given method where instance of this type (class or array of classes) was allocated. * * @param peer method. * @return method where instance of this type (class or array of classes) was allocated * or <code>null</code> if such method does not exist. */ public AllocTypeMethodRef getAllocTypeMethod(MethodRef peer) { return null; //PENDING; } /** * Return unmodifiable list of threads in which instances of this type (class or array of classes) were allocated. * * @return unmodifiable list between {@link AllocTypeThreadRef} objects. */ public List getAllocTypeThreads() { return roAllocTypeThreads; } /** * Returns statistic data for given thread where instances of this type (class or array of classes) * were allocated. * * @param peer thread. * @return thread where instances of this type (class or array of classes) * were allocated or <code>null</code> if such thread does not exist. */ public AllocTypeThreadRef getAllocTypeThread(ThreadRef peer) { return null; //PENDING; } public String toString () { return getName(); } } /* * $Log: TypeData.java,v $ * Revision 1.1 2002/05/06 17:33:01 vachis * new api implemention * */ |