com.h3c.sdn.metric

## Class DataPoint

- java.lang.Object
- - com.h3c.sdn.metric.DataPoint

- Direct Known Subclasses:
    CounterDataPoint, GaugeDataPoint, HistogramDataPoint, MeterDataPoint, RatioGaugeDataPoint, RollingCounterDataPoint, TimerDataPoint

      public abstract class DataPoint
      extends Object

  Abstract base class for time stamped data points.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `protected static class` | `DataPoint.Indices` Indices used for storing `DataPoint` contents in a file.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static String` | `ENCODING_CHAR_SET` Character set used to encode `DataPoint` contents in a file.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DataPoint(InputStream is)` Constructs a `DataPoint` from the specified stream contents.
    `DataPoint(long lastUpdatedTimeStamp, long msSpanned)` Constructs a `DataPoint` using the specified values.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `equals(Object toCompare)`
    `int` | `getExpectedFieldCount()` Gets the expected CSV field count for the data type.
    `long` | `getLastUpdatedTimeStamp()` Gets the last updated time stamp.
    `long` | `getMsSpanned()` Gets the number of milliseconds spanned by the data point, presumably ending with the last update time stamp.
    `int` | `hashCode()`
    `protected String[]` | `prepareArrayFieldsForWriting(String[] fields)` Prepares the provided `String` array with values to be written for this `DataPoint`.
    `protected String[]` | `read(InputStream is)` Reads the `DataPoint` contents from the specified `InputStream`.
    `void` | `set(String[] fields)` Reads the `DataPoint` contents from the specified `String` array.
    `void` | `setLastUpdatedTimeStamp(long time)` Sets the last updated time stamp.
    `void` | `setMsSpanned(long ms)` Sets the number of milliseconds spanned by the data point, presumably ending with the last update time stamp.
    `String` | `toDebugString()` Gets a detailed representation of this object to facilitate debugging.
    `String` | `toString()`
    `void` | `write(OutputStream os)` Writes the `DataPoint` contents to the specified `OutputStream`.

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### ENCODING_CHAR_SET

          protected static final String ENCODING_CHAR_SET

      Character set used to encode `DataPoint` contents in a file.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### DataPoint

          public DataPoint(long lastUpdatedTimeStamp,
                   long msSpanned)

      Constructs a `DataPoint` using the specified values.
      Parameters:
        `lastUpdatedTimeStamp` - last updated time stamp
        `msSpanned` - milliseconds spanned

    - #### DataPoint

          public DataPoint(InputStream is)
                    throws DataFormatException,
                           IOException

      Constructs a `DataPoint` from the specified stream contents.
      Parameters:
        `is` - `InputStream` to read from
      Throws:
        `DataFormatException` - if the expected file content cannot be read
        `IOException` - if an error occurs while reading from the stream

  - ### Method Detail

    - #### equals

          public boolean equals(Object toCompare)

      Overrides:
        `equals` in class `Object`

    - #### getExpectedFieldCount

          public int getExpectedFieldCount()

      Gets the expected CSV field count for the data type.
      Returns:
        the expected field count

    - #### getLastUpdatedTimeStamp

          public long getLastUpdatedTimeStamp()

      Gets the last updated time stamp.
      Returns:
        last updated time stamp

    - #### getMsSpanned

          public long getMsSpanned()

      Gets the number of milliseconds spanned by the data point, presumably ending with the last update time stamp.
      Returns:
        milliseconds spanned

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### prepareArrayFieldsForWriting

          protected String[] prepareArrayFieldsForWriting(String[] fields)

      Prepares the provided `String` array with values to be written for this `DataPoint`.
      Parameters:
        `fields` - a `String` array that will be set with the field values, in order, to be written
      Returns:
        array set with fields values from this object, in order
      Throws:
        `IllegalArgumentException` - if the provided array is too small to hold the number of fields to be written

    - #### read

          protected String[] read(InputStream is)
                           throws DataFormatException,
                                  IOException

      Reads the `DataPoint` contents from the specified `InputStream`.
      Parameters:
        `is` - `InputStream` to read from
      Returns:
        array of parsed `String`s from stream
      Throws:
        `DataFormatException` - if the expected file content cannot be read
        `IOException` - if an error occurs while reading from the stream

    - #### set

          public void set(String[] fields)
                   throws DataFormatException

      Reads the `DataPoint` contents from the specified `String` array.
      Parameters:
        `fields` - `String` array to read from
      Throws:
        `DataFormatException` - if the expected file content cannot be read

    - #### setLastUpdatedTimeStamp

          public void setLastUpdatedTimeStamp(long time)

      Sets the last updated time stamp.
      Parameters:
        `time` - last updated time stamp

    - #### setMsSpanned

          public void setMsSpanned(long ms)

      Sets the number of milliseconds spanned by the data point, presumably ending with the last update time stamp.
      Parameters:
        `ms` - milliseconds spanned

    - #### toDebugString

          public String toDebugString()

      Gets a detailed representation of this object to facilitate debugging.
      Returns:
        debug representation of object

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### write

          public void write(OutputStream os)
                     throws IOException

      Writes the `DataPoint` contents to the specified `OutputStream`.
      Parameters:
        `os` - `OutputStream` to write to
      Throws:
        `IOException` - if a ZIP file or other I/O error occurs

Copyright © 2014. All Rights Reserved.