biz.c24.io.api.data.fpml
Class FpMLValidator

java.lang.Object
  extended by biz.c24.io.api.data.fpml.FpMLValidator

public class FpMLValidator
extends Object

Utility validation class for generic FpML conditions and terms.
This class is used internally by the FpML java code validation rules.


Nested Class Summary
static class FpMLValidator.FpMLValidationException
          An FpML specific expection.
static class FpMLValidator.RegularPeriod
          A representation of a time period.
 
Constructor Summary
FpMLValidator()
           
 
Method Summary
static FpMLValidator.RegularPeriod calculateRegularPeriod(ComplexDataObject calculationPeriodDates)
          Term: regular period.
static boolean dividesRegularPeriod(ComplexDataObject calculationPeriodDates)
          Method used in rule ird-12.
static boolean isFrequencyEquivalent(String firstPeriod, int firstMultiplier, String secondPeriod, int secondMultiplier)
          Tests whether the second frequency is equivalent to the first, according to the following definitions:
Term: frequency equivalence
A frequency is specified as a tuple of period, which is an integer, and periodMultiplier, which is one of D, M, Y, W or T, standing for day, month, year, week and term.
static boolean isIntegerMultiple(String firstPeriod, int firstMultiplier, String secondPeriod, int secondMultiplier)
          Tests whether the second frequency is an integer multiple of the first, according to the following definitions:
Term: frequency equivalence
A frequency is specified as a tuple of period, which is an integer, and periodMultiplier, which is one of D, M, Y, W or T, standing for day, month, year, week and term.
static boolean isParametric(ComplexDataObject message)
          Tests for the following condition:
The ancestor element of type InterestRateStream contains no cashflows element, or cashflows/cashflowsMatchParameters contains true.
static boolean isPeriodMultiple(ISO8601Date firstDate, ISO8601Date secondDate, String period, int multiplier)
          Returns whether the second date can be reached from the fist via an integer multiple of the multiplier and period.
static boolean matchesUnadjustedCalcPeriodDates(ComplexDataObject interestRateStream, ISO8601Date testDate)
          Term: unadjusted calculation period dates.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FpMLValidator

public FpMLValidator()
Method Detail

isParametric

public static boolean isParametric(ComplexDataObject message)
Tests for the following condition:
The ancestor element of type InterestRateStream contains no cashflows element, or cashflows/cashflowsMatchParameters contains true.

Parameters:
message - The FpML message.
Returns:
Whether the message is parametric.

isFrequencyEquivalent

public static boolean isFrequencyEquivalent(String firstPeriod,
                                            int firstMultiplier,
                                            String secondPeriod,
                                            int secondMultiplier)
Tests whether the second frequency is equivalent to the first, according to the following definitions:
Term: frequency equivalence
A frequency is specified as a tuple of period, which is an integer, and periodMultiplier, which is one of D, M, Y, W or T, standing for day, month, year, week and term. Between any pair of frequencies, the following is the complete list of equivalences where the period multipliers differ:
If the period multipliers of a pair of frequencies are equivalent, then they are equal if and only if the period elements are equal. For the purpose of calculating multiples of periods, the following additional rule holds:

Parameters:
firstPeriod - The first period.
firstMultiplier - The first multiplier.
secondPeriod - The second period.
secondMultiplier - The second multiplier.
Returns:
The result.

isIntegerMultiple

public static boolean isIntegerMultiple(String firstPeriod,
                                        int firstMultiplier,
                                        String secondPeriod,
                                        int secondMultiplier)
Tests whether the second frequency is an integer multiple of the first, according to the following definitions:
Term: frequency equivalence
A frequency is specified as a tuple of period, which is an integer, and periodMultiplier, which is one of D, M, Y, W or T, standing for day, month, year, week and term. Between any pair of frequencies, the following is the complete list of equivalences where the period multipliers differ:
If the period multipliers of a pair of frequencies are equivalent, then they are equal if and only if the period elements are equal. For the purpose of calculating multiples of periods, the following additional rule holds:

Parameters:
firstPeriod - The first period.
firstMultiplier - The first multiplier.
secondPeriod - The second period.
secondMultiplier - The second multiplier.
Returns:
The result.

isPeriodMultiple

public static boolean isPeriodMultiple(ISO8601Date firstDate,
                                       ISO8601Date secondDate,
                                       String period,
                                       int multiplier)
Returns whether the second date can be reached from the fist via an integer multiple of the multiplier and period.

Parameters:
firstDate - The start date.
secondDate - The finish date.
period - The period, i.e. "D", "W", "M", "Y", "T".
multiplier - The period multiplier.
Returns:
Whether the period is an integer multiple.

calculateRegularPeriod

public static FpMLValidator.RegularPeriod calculateRegularPeriod(ComplexDataObject calculationPeriodDates)
                                                          throws FpMLValidator.FpMLValidationException
Term: regular period.
The regular period of a set of calculation period dates is the period between a start date and an end date. The start date is firstRegularPeriodStartDate, if present, or effectiveDate/unadjustedDate otherwise. The end date is lastRegularPeriodEndDate, if present, or terminationDate/unadjustedDate otherwise.

Parameters:
calculationPeriodDates - The source object.
Returns:
The period.
Throws:
FpMLValidator.FpMLValidationException - If the data is invalid.

matchesUnadjustedCalcPeriodDates

public static boolean matchesUnadjustedCalcPeriodDates(ComplexDataObject interestRateStream,
                                                       ISO8601Date testDate)
                                                throws FpMLValidator.FpMLValidationException
Term: unadjusted calculation period dates.
This applies in the context of an InterestRateStream. For the purpose of validation, the unadjusted calculation period dates are determined as follows:

Parameters:
interestRateStream - The test object.
testDate - The date to be tested.
Returns:
The result.
Throws:
FpMLValidator.FpMLValidationException - If the data is invalid.

dividesRegularPeriod

public static boolean dividesRegularPeriod(ComplexDataObject calculationPeriodDates)
                                    throws FpMLValidator.FpMLValidationException
Method used in rule ird-12.
The frequency specified in calculationPeriodFrequency must divide the regular period precisely. This means that by stepping through the period from the start date at the specified frequency, it must be possible to reach the end date.

Parameters:
calculationPeriodDates - The object to test.
Returns:
whether the calculationPeriodDates object meets the constraints of the rule.
Throws:
FpMLValidator.FpMLValidationException - If mandatory parts of the argument are missing.


C24 Technologies © 2002-2012: All Rights Reserved.