org.opensolaris.os.dtrace
Class PrintfRecord

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

public final class PrintfRecord
extends java.lang.Object
implements Record, java.io.Serializable

A formatted string generated by the DTrace printf() action.

Immutable. Supports persistence using XMLEncoder.

See Also:
Serialized Form

Constructor Summary
PrintfRecord(java.util.List<ValueRecord> v, java.lang.String s)
          Creates a record with the unformatted elements passed to the DTrace printf() action and the resulting formatted output.
 
Method Summary
 java.lang.String getFormattedString()
          Gets the formatted string output of the DTrace printf() action.
 ValueRecord getRecord(int i)
          Gets the unformatted element passed to the DTrace printf() action at the given offset in the printf() argument list after the format string, starting at offset zero for the first unformatted element.
 int getRecordCount()
          Gets the number of DTrace printf() unformatted elements (arguments following the format string).
 java.util.List<ValueRecord> getRecords()
          Gets the unfomatted elements passed to the DTrace printf() action after the format string.
 java.lang.String toString()
          Gets the formatted string output of the DTrace printf() action.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PrintfRecord

public PrintfRecord(java.util.List<ValueRecord> v,
                    java.lang.String s)
Creates a record with the unformatted elements passed to the DTrace printf() action and the resulting formatted output. Supports XML persistence.

Parameters:
v - variable number of unformatted elements passed to the DTrace printf() action
s - formatted printf() output
Throws:
java.lang.NullPointerException - if the given list or any of its elements is null, or if the given formatted string is null
Method Detail

getFormattedString

public java.lang.String getFormattedString()
Gets the formatted string output of the DTrace printf() action.

Returns:
non-null formatted string output of the DTrace printf() action

getRecords

public java.util.List<ValueRecord> getRecords()
Gets the unfomatted elements passed to the DTrace printf() action after the format string.

Returns:
non-null, unmodifiable list of unformatted elements passed to the DTrace printf() action that generated this record, in the order they appear in the argument list after the format string

getRecordCount

public int getRecordCount()
Gets the number of DTrace printf() unformatted elements (arguments following the format string). For example, the following action

    printf("%s %d\n", "cat", 9);
 
generates a PrintfRecord with a record count of two.

Returns:
the number of unformatted elements passed to the DTrace printf() action that generated this record.

getRecord

public ValueRecord getRecord(int i)
Gets the unformatted element passed to the DTrace printf() action at the given offset in the printf() argument list after the format string, starting at offset zero for the first unformatted element.

Returns:
non-null record representing the unformatted printf() element at the given index (using the same order that they appear in the printf() argument list)
Throws:
java.lang.ArrayIndexOutOfBoundsException - if the given index is out of range (index < 0 || index >= getRecordCount())

toString

public java.lang.String toString()
Gets the formatted string output of the DTrace printf() action.

Overrides:
toString in class java.lang.Object