Direct Known Subclasses:
Smf0Record, Smf10Record, Smf110Record, Smf11Record, Smf121Record, Smf14Record, Smf16Record, Smf17Record, Smf18Record, Smf19Record, Smf21Record, Smf23Record, Smf2GroupRecord, Smf2IntervalRecord, Smf2Record, Smf30Record, Smf3Record, Smf41Record, Smf42Record, Smf60Record, Smf61Record, Smf62Record, Smf64Record, Smf65Record, Smf66Record, Smf6Record, Smf70Record, Smf71Record, Smf72Record, Smf73Record, Smf74Record, Smf75Record, Smf76Record, Smf77Record, Smf78Record, Smf79Record, Smf7Record, Smf88Record, Smf89Record, Smf8Record, Smf90Record, Smf92Record, Smf98Record, SmfDb2Record

public class SmfRecord extends SmfData
SmfRecord is the base class for all SMF record types. It maps the fields from the standard SMF record header.

SmfRecord also provides static methods to access information e.g SMF record type from an array of bytes without creating a SmfRecord instance.

  • Constructor Summary

    Constructors
    Constructor
    Description
    SmfRecord(byte[] data)
    Constructs an SmfRecord using the specified byte array.
    SmfRecord(Data record)
     
    Constructs a new SmfRecord from an existing SMF record.
  • Method Summary

    Modifier and Type
    Method
    Description
    <T> T
    createSection(byte[] data, int offset, int length, com.blackhillsoftware.smf.internal.CreateSection<T> builder)
     
    boolean
    Return true if the SMF record has an extended header, as indicated by the SMFxFLG field in the SMF record header and SMFxRTY value equal to 126
    static boolean
    extendedHeader(byte[] data)
    Return true if the SMF record has an extended header, as indicated by the SMFxFLG field in the SMF record header and SMFxRTY value equal to 126
    static SmfRecord
    from(byte[] data)
    Constructs an SmfRecord using the specified byte array.
    com.blackhillsoftware.smf.internal.Triplet
    getTriplet(int offset)
     
    boolean
    Return true if the SMF record has subtypes, as indicated by the SMFxFLG field in the standard SMF record header.
    static boolean
    hasSubtypes(byte[] data)
    Return true if the SMF record has subtypes, as indicated by the SMFxFLG field in the standard SMF record header.
    int
    Return the length of the record.
    static int
    recordLength(byte[] data)
    Return the record length from the specified byte array.
    int
    Return the record type, as indicated by the SMFxRTY field in the standard SMF record header or the SMFHDR1_EXT_RTY field in the extended header
    static int
    recordType(byte[] data)
    Return the record type, as indicated by the SMFxRTY field in the standard SMF record header or the SMFHDR1_EXT_RTY field in the extended header
    boolean
    Perform a basic sanity check on the SMF record.
    Return the date the record was written, from the SMFxDTE field in the standard SMF record header.
    static LocalDate
    smfDate(byte[] data)
    Return the date the record was written, from the SMFxDTE field in the standard SMF record header.
    Return the date and time the record was written, from the SMFxDTE and SMFxTME fields in the standard SMF record header or the SMFHDR1_STCKE and SMFHDR1_TZO fields if the record has an extended header.
    smfDateTime(byte[] data)
    Return the date and time the record was written, from the SMFxDTE and SMFxTME fields in the standard SMF record header or the SMFHDR1_STCKE and SMFHDR1_TZO fields if the record has an extended header.
    int
    Return the Extended Header flag byte from the SMFHDR1_FLAG field.
    boolean
    Return true if IEFU86 bit in smfhdr1Flag() is set.
    int
    Return the Extended Header length from the SMFHDR1_LEN field.
    static int
    smfhdr1Len(byte[] data)
    Return the Extended Header length from the SMFHDR1_LEN field.
    SMFHDR1_STCKE value converted to ZonedDateTime (nanosecond precision, ZoneOffset.UTC).
    SMFHDR1_STCKE value.
    SMFHDR1_TZO as ZoneOffset.
    long
    SMFHDR1_TZO raw value.
    int
    Return the Extended Header length from the SMFHDR1_VERSION field.
    static int
    smfhdr1Version(byte[] data)
    Return the Extended Header version from the SMFHDR1_VERSION field.
    Return the time the record was written, from the SMFxTME field in the standard SMF record header.
    static LocalTime
    smfTime(byte[] data)
    Return the time the record was written, from the SMFxTME field in the standard SMF record header.
    Return the subsystem identification from the SMFxSSI field in the standard SMF record header.
    static String
    subSystem(byte[] data)
    Return the subsystem identification from the SMFxSSI field in the standard SMF record header.
    int
    Return the subtype from the SMFxSTY field in the standard SMF record header.
    static int
    subType(byte[] data)
    Return the subtype from the SMFxSTY field in the standard SMF record header.
    Return the system ID, as indicated by the SMFxSID field in the standard SMF record header.
    static String
    system(byte[] data)
    Return the system ID, as indicated by the SMFxSID field in the standard SMF record header.

    Methods inherited from class com.blackhillsoftware.smf.Data

    dump, dump, dump, dump, equals, getBytes, getBytes, hashCode, length, toString

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • SmfRecord

      public SmfRecord(byte[] data)
      Constructs an SmfRecord using the specified byte array.
      Parameters:
      data - a byte array containing the SMF record data. Ownership of the array passes to the SMF record object i.e. a new array should be used to create each SMF record, and no modifications should be made to the byte array after it is used to create the record.
    • SmfRecord

      public SmfRecord(SmfRecord record)
      Constructs a new SmfRecord from an existing SMF record. The 2 records share the same data byte array.
      Parameters:
      record - an existing SMF record
    • SmfRecord

      public SmfRecord(Data record)
  • Method Details

    • from

      public static SmfRecord from(byte[] data)
      Constructs an SmfRecord using the specified byte array.
      Parameters:
      data - a byte array containing the SMF record data. Ownership of the array passes to the SMF record object i.e. a new array should be used to create each SMF record, and no modifications should be made to the byte array after it is used to create the record.
    • recordLength

      public static int recordLength(byte[] data)
      Return the record length from the specified byte array.
      Parameters:
      data - a byte array
      Returns:
      int record length
    • recordLength

      public int recordLength()
      Return the length of the record.
      Returns:
      int record length
    • hasSubtypes

      public static boolean hasSubtypes(byte[] data)
      Return true if the SMF record has subtypes, as indicated by the SMFxFLG field in the standard SMF record header.
      Parameters:
      data - a byte array containing an SMF record
      Returns:
      boolean true if the record has subtypes
    • hasSubtypes

      public boolean hasSubtypes()
      Return true if the SMF record has subtypes, as indicated by the SMFxFLG field in the standard SMF record header.
      Returns:
      boolean true if the record has subtypes
    • extendedHeader

      public static boolean extendedHeader(byte[] data)
      Return true if the SMF record has an extended header, as indicated by the SMFxFLG field in the SMF record header and SMFxRTY value equal to 126
      Parameters:
      data - a byte array containing an SMF record
      Returns:
      boolean true if the record has an extended header
    • extendedHeader

      public boolean extendedHeader()
      Return true if the SMF record has an extended header, as indicated by the SMFxFLG field in the SMF record header and SMFxRTY value equal to 126
      Returns:
      boolean true if the record has an extended header
    • recordType

      public static int recordType(byte[] data)
      Return the record type, as indicated by the SMFxRTY field in the standard SMF record header or the SMFHDR1_EXT_RTY field in the extended header
      Parameters:
      data - a byte array containing an SMF record
      Returns:
      int SMFxRTY value
    • recordType

      public int recordType()
      Return the record type, as indicated by the SMFxRTY field in the standard SMF record header or the SMFHDR1_EXT_RTY field in the extended header
      Returns:
      int SMFxRTY value
    • system

      public static String system(byte[] data)
      Return the system ID, as indicated by the SMFxSID field in the standard SMF record header.
      Parameters:
      data - a byte array containing an SMF record
      Returns:
      String SMFxSID value
    • system

      public String system()
      Return the system ID, as indicated by the SMFxSID field in the standard SMF record header.
      Returns:
      String SMFxSID value
    • smfTime

      public static LocalTime smfTime(byte[] data)
      Return the time the record was written, from the SMFxTME field in the standard SMF record header.
      Parameters:
      data - a byte array containing an SMF record
      Returns:
      LocalTime SMFxTME converted to LocalTime
    • smfTime

      public LocalTime smfTime()
      Return the time the record was written, from the SMFxTME field in the standard SMF record header.
      Returns:
      LocalTime SMFxTME converted to LocalTime
    • smfDate

      public static LocalDate smfDate(byte[] data)
      Return the date the record was written, from the SMFxDTE field in the standard SMF record header.
      Parameters:
      data - a byte array containing an SMF record
      Returns:
      LocalDate SMFxDTE converted to LocalDate
    • smfDate

      public LocalDate smfDate()
      Return the date the record was written, from the SMFxDTE field in the standard SMF record header.
      Returns:
      LocalDate SMFxDTE converted to LocalDate
    • smfDateTime

      public static LocalDateTime smfDateTime(byte[] data)
      Return the date and time the record was written, from the SMFxDTE and SMFxTME fields in the standard SMF record header or the SMFHDR1_STCKE and SMFHDR1_TZO fields if the record has an extended header. If the extended header is present the value returned has a precision of 1 nanosecond. If there is no extended header the standard SMF header values have 1/100 of a second precision.
      Parameters:
      data - a byte array containing an SMF record
      Returns:
      LocalDateTime SMFxDTE and SMFxTME or SMFHDR1_STCKE and SMFHDR1_TZO converted to LocalDateTime
    • smfDateTime

      public LocalDateTime smfDateTime()
      Return the date and time the record was written, from the SMFxDTE and SMFxTME fields in the standard SMF record header or the SMFHDR1_STCKE and SMFHDR1_TZO fields if the record has an extended header. If the extended header is present the value returned has a precision of 1 nanosecond. If there is no extended header the standard SMF header values have 1/100 of a second precision.
      Returns:
      LocalDateTime SMFxDTE and SMFxTME or SMFHDR1_STCKE and SMFHDR1_TZO converted to LocalDateTime
    • subSystem

      public static String subSystem(byte[] data)
      Return the subsystem identification from the SMFxSSI field in the standard SMF record header.
      Parameters:
      data - a byte array containing an SMF record
      Returns:
      String SMFxSSI value, or null if the record does not have subtypes
    • subSystem

      public String subSystem()
      Return the subsystem identification from the SMFxSSI field in the standard SMF record header.
      Returns:
      String SMFxSSI value, or null if the record does not have subtypes
    • subType

      public static int subType(byte[] data)
      Return the subtype from the SMFxSTY field in the standard SMF record header.
      Parameters:
      data - a byte array containing an SMF record
      Returns:
      int SMFxSTY value
      Throws:
      NotAvailableException - if the record does not have subtypes
    • subType

      public int subType()
      Return the subtype from the SMFxSTY field in the standard SMF record header.
      Returns:
      int SMFxSTY value
      Throws:
      NotAvailableException - if the record does not have subtypes
    • smfhdr1Len

      public static int smfhdr1Len(byte[] data)
      Return the Extended Header length from the SMFHDR1_LEN field.
      Parameters:
      data - a byte array containing an SMF record
      Returns:
      int SMFHDR1_LEN value
      Throws:
      NotAvailableException - if the record does not have an extended header
    • smfhdr1Len

      public int smfhdr1Len()
      Return the Extended Header length from the SMFHDR1_LEN field.
      Returns:
      int SMFHDR1_LEN value
      Throws:
      NotAvailableException - if the record does not have an extended header
    • smfhdr1Version

      public static int smfhdr1Version(byte[] data)
      Return the Extended Header version from the SMFHDR1_VERSION field.
      Parameters:
      data - a byte array containing an SMF record
      Returns:
      int SMFHDR1_VERSION value
      Throws:
      NotAvailableException - if the record does not have an extended header
    • smfhdr1Version

      public int smfhdr1Version()
      Return the Extended Header length from the SMFHDR1_VERSION field.
      Returns:
      int SMFHDR1_VERSION value
      Throws:
      NotAvailableException - if the record does not have an extended header
    • smfhdr1Flag

      public int smfhdr1Flag()
      Return the Extended Header flag byte from the SMFHDR1_FLAG field.
      Returns:
      int SMFHDR1_FLAG value
      Throws:
      NotAvailableException - if the record does not have an extended header
    • smfhdr1Iefu86

      public boolean smfhdr1Iefu86()
      Return true if IEFU86 bit in smfhdr1Flag() is set.
      Returns:
      boolean IEFU86 bit is set in smfhdr1Flag()
      Throws:
      NotAvailableException - if the record does not have an extended header

      IEFU86 = 0x80

    • smfhdr1Stcke

      public ZonedDateTime smfhdr1Stcke()
      SMFHDR1_STCKE value converted to ZonedDateTime (nanosecond precision, ZoneOffset.UTC).

      Use smfhdr1StckeRawValue() for a BigInteger containing the complete STCKE value.

      Returns:
      DateTime SMFHDR1_STCKE converted to ZonedDateTime
      Throws:
      NotAvailableException - if the record does not have an extended header
      See Also:
    • smfhdr1StckeRawValue

      public BigInteger smfhdr1StckeRawValue()
      SMFHDR1_STCKE value.
      Returns:
      BigInteger SMFHDR1_STCKE value
      Throws:
      NotAvailableException - if the record does not have an extended header
    • smfhdr1Tzo

      public ZoneOffset smfhdr1Tzo()
      SMFHDR1_TZO as ZoneOffset.
      Returns:
      ZoneOffset SMFHDR1_TZO
      Throws:
      NotAvailableException - if the record does not have an extended header
    • smfhdr1TzoRawValue

      public long smfhdr1TzoRawValue()
      SMFHDR1_TZO raw value.
      Returns:
      long SMFHDR1_TZO value
      Throws:
      NotAvailableException - if the record does not have an extended header
    • sanityCheck

      public boolean sanityCheck()
      Perform a basic sanity check on the SMF record. Currently only checks that the header date and time are valid values. This will catch many errors, however it is possible that valid date and time values will appear in random data. There are many errors that could occur that will not be found by this check.
      Returns:
      boolean true if sanity check passes
    • createSection

      public <T> T createSection(byte[] data, int offset, int length, com.blackhillsoftware.smf.internal.CreateSection<T> builder)
      Overrides:
      createSection in class SmfData
    • getTriplet

      public com.blackhillsoftware.smf.internal.Triplet getTriplet(int offset)
      Overrides:
      getTriplet in class SmfData