org.opensolaris.os.dtrace
Class ScalarRecord

java.lang.Object
  extended by org.opensolaris.os.dtrace.ScalarRecord
All Implemented Interfaces:
java.io.Serializable, Record, ValueRecord

public final class ScalarRecord
extends java.lang.Object
implements ValueRecord, java.io.Serializable

A traced D primitive generated by a DTrace action such as trace() or tracemem(), or else an element in a composite value generated by DTrace.

Immutable. Supports persistence using XMLEncoder.

See Also:
Serialized Form

Constructor Summary
ScalarRecord(java.lang.Object v, int nativeByteCount)
          Creates a scalar record with the given DTrace primitive and the number of bytes used to store the primitive in the native DTrace buffer.
 
Method Summary
 boolean equals(java.lang.Object o)
          Compares the specified object with this record for equality.
 int getNumberOfBytes()
          Gets the number of bytes used to store the primitive value of this record in the native DTrace buffer.
 java.lang.Object getValue()
          Gets the traced D primitive value of this record.
 int hashCode()
          Overridden to ensure that equal instances have equal hashcodes.
 java.lang.String toString()
          Gets the natural string representation of the traced D primitive.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ScalarRecord

public ScalarRecord(java.lang.Object v,
                    int nativeByteCount)
Creates a scalar record with the given DTrace primitive and the number of bytes used to store the primitive in the native DTrace buffer. Since traced 8- and 16-bit integers are promoted (as unsigned values) to 32-bit integers, it may be important for output formatting to know the number of bytes used to represent the primitive before promotion.

Parameters:
v - DTrace primitive data value
nativeByteCount - number of bytes used to store the given primitive in the native DTrace buffer
Throws:
java.lang.NullPointerException - if the given value is null
java.lang.IllegalArgumentException - if the given number of bytes is not consistent with the given primitive type or is not greater than zero
java.lang.ClassCastException - if the given value is not a DTrace primitive type listed as a possible return value of getValue()
Method Detail

getValue

public java.lang.Object getValue()
Gets the traced D primitive value of this record.

Specified by:
getValue in interface ValueRecord
Returns:
a non-null value whose type is one of the following:
  • Number
  • String
  • byte[]

getNumberOfBytes

public int getNumberOfBytes()
Gets the number of bytes used to store the primitive value of this record in the native DTrace buffer. Since traced 8- and 16-bit integers are promoted (as unsigned values) to 32-bit integers, it may be important for output formatting to know the number of bytes used to represent the primitive before promotion.

Returns:
the number of bytes used to store the primitive value of this record in the native DTrace buffer, guaranteed to be greater than zero and consisitent with the type of the primitive value

equals

public boolean equals(java.lang.Object o)
Compares the specified object with this record for equality. Defines equality as having the same value.

Overrides:
equals in class java.lang.Object
Returns:
true if and only if the specified object is also a ScalarRecord and the values returned by the getValue() methods of both instances are equal, false otherwise. Values are compared using Object.equals(), unless they are arrays of raw bytes, in which case they are compared using Arrays.equals(byte[] a, byte[] a2).

hashCode

public int hashCode()
Overridden to ensure that equal instances have equal hashcodes.

Overrides:
hashCode in class java.lang.Object
Returns:
Object.hashCode() of getValue(), or Arrays.hashCode(byte[] a) if the value is a raw byte array

toString

public java.lang.String toString()
Gets the natural string representation of the traced D primitive.

Overrides:
toString in class java.lang.Object
Returns:
the value of Object.toString() when called on getValue(); or if the value is an array of raw bytes, a table displaying 16 bytes per row in unsigned hex followed by the ASCII character representations of those bytes (each unprintable character is represented by a period (.))