Class RecordedObject
- Direct Known Subclasses:
RecordedClass, RecordedClassLoader, RecordedEvent, RecordedFrame, RecordedMethod, RecordedStackTrace, RecordedThread, RecordedThreadGroup
This class provides methods to select and query nested objects by passing a
dot "."
delimited String
object (for instance,
"aaa.bbb"
). A method evaluates a nested object from left to right,
and if a part is null
, it throws NullPointerException
.
- Since:
- 9
-
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
getBoolean
(String name) Returns the value of a field of typeboolean
.final byte
Returns the value of a field of typebyte
.final char
Returns the value of a field of typechar
.final RecordedClass
Returns the value of a field of typeClass
.final double
Returns the value of a field of typedouble
or of another primitive type that is convertible to typedouble
by a widening conversion.final Duration
getDuration
(String name) Returns the value of a timespan field.Returns an immutable list of the fields for this object.final float
Returns the value of a field of typefloat
or of another primitive type convertible to typefloat
by a widening conversion.final Instant
getInstant
(String name) Returns the value of a timestamp field.final int
Returns the value of a field of typeint
or of another primitive type that is convertible to typeint
by a widening conversion.final long
Returns the value of a field of typelong
or of another primitive type that is convertible to typelong
by a widening conversion.final short
Returns the value of a field of typeshort
or of another primitive type convertible to typeshort
by a widening conversion.final String
Returns the value of a field of typeString
.final RecordedThread
Returns the value of a field of typeThread
.final <T> T
Returns the value of the field with the given name.boolean
Returnstrue
if a field with the given name exists,false
otherwise.final String
toString()
Returns a textual representation of this object.Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Modifier and TypeMethodDescriptionprotected Object
clone()
Creates and returns a copy of this object.boolean
Indicates whether some other object is "equal to" this one.protected void
finalize()
Deprecated, for removal: This API element is subject to removal in a future version.Finalization is deprecated and subject to removal in a future release.final Class
<?> getClass()
Returns the runtime class of thisObject
.int
hashCode()
Returns a hash code value for this object.final void
notify()
Wakes up a single thread that is waiting on this object's monitor.final void
Wakes up all threads that are waiting on this object's monitor.final void
wait()
Causes the current thread to wait until it is awakened, typically by being notified or interrupted.final void
wait
(long timeoutMillis) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.final void
wait
(long timeoutMillis, int nanos) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
-
Method Details
-
hasField
Returnstrue
if a field with the given name exists,false
otherwise.It's possible to index into a nested field by using
"."
(for instance"thread.group.parent.name
").- Parameters:
name
- name of the field to get, notnull
- Returns:
true
if the field exists,false
otherwise- See Also:
-
getValue
Returns the value of the field with the given name.The return type may be a primitive type or a subclass of
RecordedObject
.It's possible to index into a nested object by using
"."
(for instance"thread.group.parent.name
").A field might change or be removed in a future JDK release. A best practice for callers of this method is to validate the field before attempting access.
Example
if (event.hasField("intValue")) { int intValue = event.getValue("intValue"); System.out.println("Int value: " + intValue); } if (event.hasField("objectClass")) { RecordedClass clazz = event.getValue("objectClass"); System.out.println("Class name: " + clazz.getName()); } if (event.hasField("sampledThread")) { RecordedThread sampledThread = event.getValue("sampledThread"); System.out.println("Sampled thread: " + sampledThread.getJavaName()); }
- Type Parameters:
T
- the return type- Parameters:
name
- of the field to get, notnull
- Returns:
- the value, can be
null
- Throws:
IllegalArgumentException
- if no field calledname
exists- See Also:
-
getFields
Returns an immutable list of the fields for this object.- Returns:
- the fields, not
null
-
getBoolean
Returns the value of a field of typeboolean
.It's possible to index into a nested object using
"."
(for example,"aaa.bbb"
).A field might change or be removed in a future JDK release. A best practice for callers of this method is to validate the field before attempting access.
- Parameters:
name
- name of the field to get, notnull
- Returns:
- the value of the field,
true
orfalse
- Throws:
IllegalArgumentException
- if the field doesn't exist, or the field is not of typeboolean
- See Also:
-
getByte
Returns the value of a field of typebyte
.It's possible to index into a nested object using
"."
(for example,"foo.bar"
).A field might change or be removed in a future JDK release. A best practice for callers of this method is to validate the field before attempting access.
- Parameters:
name
- of the field to get, notnull
- Returns:
- the value of the field
- Throws:
IllegalArgumentException
- if the field doesn't exist, or the field is not of typebyte
- See Also:
-
getChar
Returns the value of a field of typechar
.It's possible to index into a nested object using
"."
(for example,"aaa.bbb"
).A field might change or be removed in a future JDK release. A best practice for callers of this method is to validate the field before attempting access.
- Parameters:
name
- of the field to get, notnull
- Returns:
- the value of the field as a
char
- Throws:
IllegalArgumentException
- if the field doesn't exist, or the field is not of typechar
- See Also:
-
getShort
Returns the value of a field of typeshort
or of another primitive type convertible to typeshort
by a widening conversion.This method can be used on the following types:
short
andbyte
.If the field has the
@Unsigned
annotation and is of a narrower type thanshort
, then the value is returned as an unsigned.It's possible to index into a nested object using
"."
(for example,"aaa.bbb"
).A field might change or be removed in a future JDK release. A best practice for callers of this method is to validate the field before attempting access.
- Parameters:
name
- of the field to get, notnull
- Returns:
- the value of the field converted to type
short
- Throws:
IllegalArgumentException
- if the field doesn't exist, or the field value can't be converted to the typeshort
by a widening conversion- See Also:
-
getInt
Returns the value of a field of typeint
or of another primitive type that is convertible to typeint
by a widening conversion.This method can be used on fields of the following types:
int
,short
,char
, andbyte
.If the field has the
@Unsigned
annotation and is of a narrower type thanint
, then the value will be returned as an unsigned.It's possible to index into a nested object using
"."
(for example,"aaa.bbb"
).A field might change or be removed in a future JDK release. A best practice for callers of this method is to validate the field before attempting access.
- Parameters:
name
- of the field to get, notnull
- Returns:
- the value of the field converted to type
int
- Throws:
IllegalArgumentException
- if the field doesn't exist, or the field value can't be converted to the typeint
by a widening conversion- See Also:
-
getFloat
Returns the value of a field of typefloat
or of another primitive type convertible to typefloat
by a widening conversion.This method can be used on fields of the following types:
float
,long
,int
,short
,char
, andbyte
.It's possible to index into a nested object using
"."
(for example,"aaa.bbb"
).A field might change or be removed in a future JDK release. A best practice for callers of this method is to validate the field before attempting access.
- Parameters:
name
- of the field to get, notnull
- Returns:
- the value of the field converted to type
float
- Throws:
IllegalArgumentException
- if the field doesn't exist, or the field value can't be converted to the typefloat
by a widening conversion- See Also:
-
getLong
Returns the value of a field of typelong
or of another primitive type that is convertible to typelong
by a widening conversion.This method can be used on fields of the following types:
long
,int
,short
,char
, andbyte
.If the field has the
@Unsigned
annotation and is of a narrower type thanlong
, then the value will be returned as an unsigned.It's possible to index into a nested object using
"."
(for example,"aaa.bbb"
).A field might change or be removed in a future JDK release. A best practice for callers of this method is to validate the field before attempting access.
- Parameters:
name
- of the field to get, notnull
- Returns:
- the value of the field converted to type
long
- Throws:
IllegalArgumentException
- if the field doesn't exist, or the field value can't be converted to the typelong
via a widening conversion- See Also:
-
getDouble
Returns the value of a field of typedouble
or of another primitive type that is convertible to typedouble
by a widening conversion.This method can be used on fields of the following types:
double
,float
,long
,int
,short
,char
, andbyte
.It's possible to index into a nested object using
"."
(for example,"aaa.bbb"
).A field might change or be removed in a future JDK release. A best practice for callers of this method is to validate the field before attempting access.
- Parameters:
name
- of the field to get, notnull
- Returns:
- the value of the field converted to type
double
- Throws:
IllegalArgumentException
- if the field doesn't exist, or the field value can't be converted to the typedouble
by a widening conversion- See Also:
-
getString
Returns the value of a field of typeString
.It's possible to index into a nested object using
"."
(for example,"foo.bar"
).A field might change or be removed in a future JDK release. A best practice for callers of this method is to validate the field before attempting access.
- Parameters:
name
- of the field to get, notnull
- Returns:
- the value of the field as a
String
, can benull
- Throws:
IllegalArgumentException
- if the field doesn't exist, or the field isn't of typeString
- See Also:
-
getDuration
Returns the value of a timespan field.This method can be used on fields annotated with
@Timespan
, and of the following types:long
,int
,short
,char
, andbyte
.If the committed event value was
Long.MAX_VALUE
, regardless of the unit set by@Timespan
, this method returnsChronoUnit.FOREVER
.It's possible to index into a nested object using
"."
(for example,"aaa.bbb"
).A field might change or be removed in a future JDK release. A best practice for callers of this method is to validate the field before attempting access.
- Parameters:
name
- of the field to get, notnull
- Returns:
- a time span represented as a
Duration
, notnull
- Throws:
IllegalArgumentException
- if the field doesn't exist, or the field value can't be converted to aDuration
object- See Also:
-
getInstant
Returns the value of a timestamp field.This method can be used on fields annotated with
@Timestamp
, and of the following types:long
,int
,short
,char
andbyte
.It's possible to index into a nested object using
"."
(for example,"aaa.bbb"
).A field might change or be removed in a future JDK release. A best practice for callers of this method is to validate the field before attempting access.
- Parameters:
name
- of the field to get, notnull
- Returns:
- a timstamp represented as an
Instant
, notnull
- Throws:
IllegalArgumentException
- if the field doesn't exist, or the field value can't be converted to anInstant
object- See Also:
-
getClass
Returns the value of a field of typeClass
.It's possible to index into a nested object using
"."
(for example,"aaa.bbb"
).A field might change or be removed in a future JDK release. A best practice for callers of this method is to validate the field before attempting access.
- Parameters:
name
- of the field to get, notnull
- Returns:
- the value of the field as a
RecordedClass
, can benull
- Throws:
IllegalArgumentException
- if the field doesn't exist, or the field isn't of typeClass
- See Also:
-
getThread
Returns the value of a field of typeThread
.It's possible to index into a nested object using
"."
(for example,"foo.bar"
).A field might change or be removed in a future JDK release. A best practice for callers of this method is to validate the field before attempting access.
- Parameters:
name
- of the field to get, notnull
- Returns:
- the value of the field as a
RecordedThread
object, can benull
- Throws:
IllegalArgumentException
- if the field doesn't exist, or the field isn't of typeThread
- See Also:
-
toString
-