Interface SpreadData


public interface SpreadData
This interface defines the access methods that a spread data holder should implement.
  • Method Details

    • getUnitFields

      String[] getUnitFields()
      Get the unit fields in this spread data.
      Returns:
      array of unit field names
    • getCostFields

      String[] getCostFields()
      Get the cost fields in this spread data.
      Returns:
      array of cost field names
    • clearFinancialValues

      void clearFinancialValues()
      Clear all the cost/financial values
    • getSpreadStart

      Date getSpreadStart()
      Find the start time of this batch of spread data.
      Returns:
      start time of this spread
    • getSpreadEnd

      Date getSpreadEnd()
      Find the end time of this batch of spread data.
      Returns:
      end time of this spread
    • getBucketType

      SpreadBucketType getBucketType()
      Get the bucket type of this batch of spread data.
      Returns:
      bucket type
    • size

      int size()
      Get the number of buckets the spread data holds.
      Returns:
      the number of buckets
    • addBucket

      int addBucket(Date bucketStartDate)
      Adds a new bucket into the spread data.
      Parameters:
      bucketStartDate - the bucket start date. If it is not a bucket start, a bucket that contains this date will be added.
      Returns:
      the bucket index
    • getBucketStartDate

      Date getBucketStartDate(int bucketIndex)
      Find the bucket start time of a specified bucket.
      Parameters:
      bucketIndex - the bucket index of this batch of buckets
      Returns:
      bucket start time
    • getBucketEndDate

      Date getBucketEndDate(int bucketIndex)
      Find the bucket end time of a specified bucket.
      Parameters:
      bucketIndex - the bucket index of this batch of buckets
      Returns:
      bucket end time
    • getBucketIndex

      int getBucketIndex(Date date)
      Find the bucket index of the bucket that the specified date falls in.
      Parameters:
      date - the date that shall fall in a bucket start and end time
      Returns:
      the bucket index of this batch of buckets
    • getDouble

      double getDouble(String fieldName, int bucketIndex) throws SpreadFieldNotFoundException
      Get the spreaded value (either cumulative or period only) for this period.
      Parameters:
      fieldName - the spread field name
      bucketIndex - the bucket index of this batch of buckets
      Returns:
      the cumulative or period only spreaded value
      Throws:
      SpreadFieldNotFoundException - if the spread field is not valid
    • setDouble

      void setDouble(String fieldName, int bucketIndex, double value) throws SpreadFieldNotFoundException
      Set the spreaded value (period only) for this period.
      Parameters:
      fieldName - the spread field name
      bucketIndex - the bucket index of this batch of buckets
      value - the period only spreaded value
      Throws:
      SpreadFieldNotFoundException - if the spread field is not valid
    • isCumulativeData

      boolean isCumulativeData()
      Whether this batch of spread data holds cumulative data or period data only.
      Returns:
      true if cumulative data, false period data only
    • getBucketStart

      Date getBucketStart(Date date, SpreadBucketType bucketType)
      Trims the given date to the bucket start time.
      Parameters:
      date - any given date
      bucketType - the spread bucket size
      Returns:
      the bucket start time aligned with buckets
    • getPreviousBucketStart

      Date getPreviousBucketStart(Date date, SpreadBucketType bucketType)
      Gets the previous bucket time by a given date.
      Parameters:
      date - any given date
      bucketType - the spread bucket size
      Returns:
      the previous bucket start time aligned with buckets
    • getNextBucketStart

      Date getNextBucketStart(Date date, SpreadBucketType bucketType)
      Gets the next bucket time by a given date.
      Parameters:
      date - any given date
      bucketType - the spread bucket size
      Returns:
      the next bucket start time aligned with buckets