public class TrackedObject extends java.lang.Object implements java.lang.Comparable<TrackedObject>
Modifier and Type | Field and Description |
---|---|
protected static org.apache.log4j.Logger |
LOGGER
Used for logging.
|
Constructor and Description |
---|
TrackedObject(java.lang.Object object,
java.lang.String field,
TrackedObject parent,
ProfilingFilter filter)
Builds a tracked object around the given object
|
Modifier and Type | Method and Description |
---|---|
void |
addBytes(long bytes)
Adds more bytes to that used by this child, and updates the parents
|
void |
addChild(TrackedObject child)
Adds a child to this object
|
int |
compareTo(TrackedObject o) |
org.jdom.Element |
dumpToXML()
Outputs this object to XML.
|
java.util.Set<TrackedObject> |
getChildren()
Gets all the children of this object
|
java.lang.String |
getClassesPathToObject()
Returns a string representing the classes traversed to get to this object from the root object
|
ProfilingFilter |
getFilterUsed()
Returns the filter this object used, as a copy
|
protected ProfilingFilter |
getFilterUsedInternal()
Returns a reference to the filter used by this object
|
<T> T |
getObject()
Returns the object stored by this tracked object
|
long |
getObjectBytes()
Get the number of bytes used by just this object, excluding any children
|
java.lang.Class |
getObjectClass()
Returns the class of the object tracked by this object
|
java.lang.String |
getObjectName()
Gets the name of the field this object came from
|
TrackedObject |
getParent()
Returns this object's parent
|
TrackedObject |
getParent(java.lang.Class clazz)
Returns the parent with the given name (the nearest relative to this object with that name) or null
|
TrackedObject |
getParent(java.lang.String name)
Returns the parent with the given name (the nearest relative to this object with that name) or null
|
java.lang.String |
getPathToObject()
Returns a string representation of the path to get to this object from the object profiled
|
TrackedObject |
getThisOrParent(java.lang.Class clazz)
Returns the parent with the given name (the nearest relative to this object with that name) or null if not found
If the current object matches the class, the current object will be returned
|
TrackedObject |
getThisOrParent(java.lang.String name)
Returns the parent with the given name (the nearest relative to this object with that name) or null if not found.
|
long |
getTotalBytes()
Get the number of bytes used by this object and it's children
|
boolean |
hasParent()
Checks to see if this object has a parent
|
boolean |
hasParent(java.lang.Class clazz)
Checks to see if this object has a parent of the given class type
|
boolean |
hasParent(java.lang.String name)
Checks to see if this object has a parent with the given name
|
boolean |
isOrHasParent(java.lang.Class clazz)
Checks to see if this object has a parent of the given class type
|
boolean |
isOrHasParent(java.lang.String name)
Checks to see if this object has a parent with the given name
|
void |
setFilterUsed(ProfilingFilter filter)
Sets the filter used by this object
|
void |
setObjectBytes(long bytes)
Sets the number of bytes used by this object
|
java.lang.String |
toString() |
public TrackedObject(java.lang.Object object, java.lang.String field, TrackedObject parent, ProfilingFilter filter)
object
- The object being trackedfield
- The name of the field this object came fromparent
- The parent object, or null if this is the root profiled objectfilter
- The filter used by the object's parentpublic java.lang.String getObjectName()
public long getObjectBytes()
public long getTotalBytes()
public void setFilterUsed(ProfilingFilter filter)
filter
- The filter used by the object@NotNull public ProfilingFilter getFilterUsed()
protected ProfilingFilter getFilterUsedInternal()
public java.lang.Class getObjectClass()
public void setObjectBytes(long bytes)
bytes
- The number of bytes used by the objectpublic void addBytes(long bytes)
bytes
- The number of bytes to add to this object's usage footprint@Nullable public <T> T getObject() throws java.lang.ClassCastException
T
- The type of the object storedjava.lang.ClassCastException
- If the type of T doesn't match the type of the object actually storedpublic TrackedObject getParent()
public void addChild(TrackedObject child)
child
- The child to add@Nullable public java.util.Set<TrackedObject> getChildren()
public boolean hasParent()
public boolean hasParent(java.lang.String name)
name
- The name of the parent object, as the name of the field it came frompublic boolean hasParent(@NotNull java.lang.Class clazz)
clazz
- The class of the parentpublic TrackedObject getParent(java.lang.String name)
name
- The parent's namepublic TrackedObject getParent(@NotNull java.lang.Class clazz)
clazz
- The parent's classpublic boolean isOrHasParent(java.lang.String name)
name
- The name of the parent object, as the name of the field it came frompublic boolean isOrHasParent(@NotNull java.lang.Class clazz)
clazz
- The class of the parentpublic TrackedObject getThisOrParent(java.lang.String name)
name
- The parent's namepublic TrackedObject getThisOrParent(@NotNull java.lang.Class clazz)
clazz
- The parent's classpublic java.lang.String getPathToObject()
@NotNull public java.lang.String getClassesPathToObject()
public int compareTo(TrackedObject o)
compareTo
in interface java.lang.Comparable<TrackedObject>
@NotNull public java.lang.String toString()
toString
in class java.lang.Object
@NotNull public org.jdom.Element dumpToXML()