com.jrockit.memleak.value
Class PrimitiveValue

java.lang.Object
  extended by com.jrockit.memleak.value.PrimitiveValue
All Implemented Interfaces:
IValue
Direct Known Subclasses:
PrimitiveFieldValue

public class PrimitiveValue
extends java.lang.Object
implements IValue

Represents a primitive value. Used for field values and array elements.


Field Summary
 
Fields inherited from interface com.jrockit.memleak.IValue
EMPTY_ARRAY
 
Constructor Summary
PrimitiveValue(java.lang.Object valueWrapper)
           
 
Method Summary
<T> T
get(java.lang.Class<T> type)
          Retrieve the actual primitive wrapper or object representation held by this instance if it can be assigned to a variable declared as being of class type, as per IValue.isAssignableTo(Class).
 java.lang.Object getPrimitiveValue()
          Returns the value of the primitive field.
 IObjectInfo getReference()
          Returns the reference for this field.
 boolean isAssignableTo(java.lang.Class<?> type)
          Check if the actual primitive wrapper or object representation held by this instance and returned by get() can be assigned to a variable declared as being of class type, with one additional requirement.
 boolean isPrimitive()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PrimitiveValue

public PrimitiveValue(java.lang.Object valueWrapper)
Parameters:
valueWrapper -
Method Detail

isPrimitive

public final boolean isPrimitive()
Specified by:
isPrimitive in interface IValue
Returns:
true if this field is a primitive type.

getPrimitiveValue

public java.lang.Object getPrimitiveValue()
Description copied from interface: IValue
Returns the value of the primitive field. The returned Object will be an instance of one of the primitive wrapper classes or null if IValue.isPrimitive() returns false.

Specified by:
getPrimitiveValue in interface IValue
Returns:
value of the primitive field

getReference

public final IObjectInfo getReference()
Description copied from interface: IValue
Returns the reference for this field. Will be null if IValue.isPrimitive() returns true.

Specified by:
getReference in interface IValue
Returns:
reference in the field

isAssignableTo

public boolean isAssignableTo(java.lang.Class<?> type)
Description copied from interface: IValue
Check if the actual primitive wrapper or object representation held by this instance and returned by get() can be assigned to a variable declared as being of class type, with one additional requirement. If type is a primitive wrapper class, Number.class, or Serializable.class, the value must also be non-null. This is to facilitate safe unboxing into primitives.

This method is mainly usable for filters to differentiate between different kinds of primitives, as well as between primitives, references or arrays.

The full list of supported type arguments, and the corresponding values from the actual heap they correspond to, is as follows:

The primitive wrapper classes (Boolean.class, Character.class, Byte.class, Short.class, Integer.class, Long.class, Float.class, Double.class) Matches their corresponding primitive
Number.class Matches byte, short, int, long, float, double
Serializable.class Matches all primitives
Object.class Matches all primitives and all references
IObjectInfo.class Matches all references (including null)
IArrayInfo.class Matches all references that are arrays or null

Specified by:
isAssignableTo in interface IValue
Parameters:
type - one of the classes above
Returns:
true iff the value can be assigned to type and, if type is a primitive wrapper class, be unboxed.

get

public <T> T get(java.lang.Class<T> type)
Description copied from interface: IValue
Retrieve the actual primitive wrapper or object representation held by this instance if it can be assigned to a variable declared as being of class type, as per IValue.isAssignableTo(Class). Otherwise, null is returned. Note that null may be returned even if IValue.isAssignableTo(Class) with the same type argument returns true, unless type is a primitive wrapper class, Number.class, or Serializable.class. This is to facilitate safe unboxing into primitives.

The full list of supported type arguments, and the corresponding values from the actual heap they correspond to, is as follows:

The primitive wrapper classes (Boolean.class, Character.class, Byte.class, Short.class, Integer.class, Long.class, Float.class, Double.class) Matches their corresponding primitive
Number.class Matches byte, short, int, long, float, double
Serializable.class Matches all primitives
Object.class Matches all primitives and all references
IObjectInfo.class Matches all references (including null)
IArrayInfo.class Matches all references that are arrays or null

Specified by:
get in interface IValue
Type Parameters:
T - implicit
Parameters:
type - one of the classes above, never null
Returns:
an instance of T (that is, a primitive wrapper or an IObjectInfo), or null

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 1999, 2011, Oracle and/or its affiliates. All rights reserved.