Interface SpreadData
public interface SpreadData
This interface defines the access methods that a spread data holder should implement.
-
Method Summary
Modifier and TypeMethodDescriptionintAdds a new bucket into the spread data.voidClear all the cost/financial valuesgetBucketEndDate(int bucketIndex) Find the bucket end time of a specified bucket.intgetBucketIndex(Date date) Find the bucket index of the bucket that the specified date falls in.getBucketStart(Date date, SpreadBucketType bucketType) Trims the given date to the bucket start time.getBucketStartDate(int bucketIndex) Find the bucket start time of a specified bucket.Get the bucket type of this batch of spread data.String[]Get the cost fields in this spread data.doubleGet the spreaded value (either cumulative or period only) for this period.getNextBucketStart(Date date, SpreadBucketType bucketType) Gets the next bucket time by a given date.getPreviousBucketStart(Date date, SpreadBucketType bucketType) Gets the previous bucket time by a given date.Find the end time of this batch of spread data.Find the start time of this batch of spread data.String[]Get the unit fields in this spread data.booleanWhether this batch of spread data holds cumulative data or period data only.voidSet the spreaded value (period only) for this period.intsize()Get the number of buckets the spread data holds.
-
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
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
Find the bucket start time of a specified bucket.- Parameters:
bucketIndex- the bucket index of this batch of buckets- Returns:
- bucket start time
-
getBucketEndDate
Find the bucket end time of a specified bucket.- Parameters:
bucketIndex- the bucket index of this batch of buckets- Returns:
- bucket end time
-
getBucketIndex
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
Get the spreaded value (either cumulative or period only) for this period.- Parameters:
fieldName- the spread field namebucketIndex- 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
Set the spreaded value (period only) for this period.- Parameters:
fieldName- the spread field namebucketIndex- the bucket index of this batch of bucketsvalue- 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
Trims the given date to the bucket start time.- Parameters:
date- any given datebucketType- the spread bucket size- Returns:
- the bucket start time aligned with buckets
-
getPreviousBucketStart
Gets the previous bucket time by a given date.- Parameters:
date- any given datebucketType- the spread bucket size- Returns:
- the previous bucket start time aligned with buckets
-
getNextBucketStart
Gets the next bucket time by a given date.- Parameters:
date- any given datebucketType- the spread bucket size- Returns:
- the next bucket start time aligned with buckets
-