/** * RatesSetting de-serialization from input byte array * * @param ab Byte Array * @throws java.lang.Exception Thrown if RatesSetting cannot be properly de-serialized */ public RatesSetting(final byte[] ab) throws java.lang.Exception { if (null == ab || 0 == ab.length) throw new java.lang.Exception("RatesSetting de-serializer: Invalid input Byte array"); java.lang.String strRawString = new java.lang.String(ab); if (null == strRawString || strRawString.isEmpty()) throw new java.lang.Exception("RatesSetting de-serializer: Empty state"); java.lang.String strSerializedRatesSetting = strRawString.substring(0, strRawString.indexOf(getObjectTrailer())); if (null == strSerializedRatesSetting || strSerializedRatesSetting.isEmpty()) throw new java.lang.Exception("RatesSetting de-serializer: Cannot locate state"); java.lang.String[] astrField = org.drip.math.common.StringUtil.Split(strSerializedRatesSetting, getFieldDelimiter()); if (null == astrField || 5 > astrField.length) throw new java.lang.Exception("RatesSetting de-serializer: Invalid reqd field set"); // double dblVersion = new java.lang.Double (astrField[0]); if (null == astrField[1] || astrField[1].isEmpty() || org.drip.service.stream.Serializer.NULL_SER_STRING.equalsIgnoreCase(astrField[1])) throw new java.lang.Exception("RatesSetting de-serializer: Cannot locate Trade Currency"); _strTradeDiscountCurve = astrField[1]; if (null == astrField[2] || astrField[2].isEmpty() || org.drip.service.stream.Serializer.NULL_SER_STRING.equalsIgnoreCase(astrField[2])) throw new java.lang.Exception("RatesSetting de-serializer: Cannot locate Coupon Currency"); _strCouponDiscountCurve = astrField[2]; if (null == astrField[3] || astrField[3].isEmpty() || org.drip.service.stream.Serializer.NULL_SER_STRING.equalsIgnoreCase(astrField[3])) throw new java.lang.Exception("RatesSetting de-serializer: Cannot locate Principal Currency"); _strPrincipalDiscountCurve = astrField[3]; if (null == astrField[4] || astrField[4].isEmpty() || org.drip.service.stream.Serializer.NULL_SER_STRING.equalsIgnoreCase(astrField[4])) throw new java.lang.Exception( "RatesSetting de-serializer: Cannot locate Redemption Currency"); _strRedemptionDiscountCurve = astrField[4]; if (!validate()) throw new java.lang.Exception("RatesSetting de-serializer: Cannot validate!"); }
/** * TerminationSetting de-serialization from input byte array * * @param ab Byte Array * @throws java.lang.Exception Thrown if TerminationSetting cannot be properly de-serialized */ public TerminationSetting(final byte[] ab) throws java.lang.Exception { if (null == ab || 0 == ab.length) throw new java.lang.Exception("TerminationSetting de-serializer: Invalid input Byte array"); java.lang.String strRawString = new java.lang.String(ab); if (null == strRawString || strRawString.isEmpty()) throw new java.lang.Exception("TerminationSetting de-serializer: Empty state"); java.lang.String strSerializedTerminationSetting = strRawString.substring(0, strRawString.indexOf(getObjectTrailer())); if (null == strSerializedTerminationSetting || strSerializedTerminationSetting.isEmpty()) throw new java.lang.Exception("TerminationSetting de-serializer: Cannot locate state"); java.lang.String[] astrField = org.drip.quant.common.StringUtil.Split( strSerializedTerminationSetting, getFieldDelimiter()); if (null == astrField || 4 > astrField.length) throw new java.lang.Exception("TerminationSetting de-serializer: Invalid reqd field set"); // double dblVersion = new java.lang.Double (astrField[0]); if (null == astrField[1] || astrField[1].isEmpty() || org.drip.service.stream.Serializer.NULL_SER_STRING.equalsIgnoreCase(astrField[1])) throw new java.lang.Exception( "TerminationSetting de-serializer: Cannot locate perpetual flag"); _bIsPerpetual = new java.lang.Boolean(astrField[1]); if (null == astrField[2] || astrField[2].isEmpty() || org.drip.service.stream.Serializer.NULL_SER_STRING.equalsIgnoreCase(astrField[2])) throw new java.lang.Exception( "TerminationSetting de-serializer: Cannot locate defaulted flag"); _bIsDefaulted = new java.lang.Boolean(astrField[2]); if (null == astrField[3] || astrField[3].isEmpty() || org.drip.service.stream.Serializer.NULL_SER_STRING.equalsIgnoreCase(astrField[3])) throw new java.lang.Exception( "TerminationSetting de-serializer: Cannot locate exercised flag"); _bHasBeenExercised = new java.lang.Boolean(astrField[3]); if (!validate()) throw new java.lang.Exception("TerminationSetting de-serializer: Cannot validate!"); }
/** * De-serialize the FloatFloatComponent from the byte array * * @param ab Byte Array * @throws java.lang.Exception Thrown if the FloatFloatComponent cannot be de-serialized from the * byte array */ public FloatFloatComponent(final byte[] ab) throws java.lang.Exception { if (null == ab || 0 == ab.length) throw new java.lang.Exception("FloatFloatComponent de-serializer: Invalid input Byte array"); java.lang.String strRawString = new java.lang.String(ab); if (null == strRawString || strRawString.isEmpty()) throw new java.lang.Exception("FloatFloatComponent de-serializer: Empty state"); java.lang.String strSerializedFloatFloatComponent = strRawString.substring(0, strRawString.indexOf(getObjectTrailer())); if (null == strSerializedFloatFloatComponent || strSerializedFloatFloatComponent.isEmpty()) throw new java.lang.Exception("FloatFloatComponent de-serializer: Cannot locate state"); java.lang.String[] astrField = org.drip.quant.common.StringUtil.Split( strSerializedFloatFloatComponent, getFieldDelimiter()); if (null == astrField || 3 > astrField.length) throw new java.lang.Exception("FloatFloatComponent de-serializer: Invalid reqd field set"); // double dblVersion = new java.lang.Double (astrField[0]).doubleValue(); if (null == astrField[1] || astrField[1].isEmpty()) throw new java.lang.Exception( "FloatFloatComponent de-serializer: Cannot locate visible floating stream"); if (org.drip.service.stream.Serializer.NULL_SER_STRING.equalsIgnoreCase(astrField[1])) _floatReference = null; else _floatReference = new org.drip.product.rates.FloatingStream(astrField[1].getBytes()); if (null == astrField[2] || astrField[2].isEmpty()) throw new java.lang.Exception( "FloatFloatComponent de-serializer: Cannot locate work-out floating stream"); if (org.drip.service.stream.Serializer.NULL_SER_STRING.equalsIgnoreCase(astrField[2])) _floatDerived = null; else _floatDerived = new org.drip.product.rates.FloatingStream(astrField[2].getBytes()); }
/** * De-serialization of DateAdjustParams from byte stream * * @param ab Byte stream * @throws java.lang.Exception Thrown if cannot properly de-serialize DateAdjustParams */ public DateAdjustParams(final byte[] ab) throws java.lang.Exception { if (null == ab || 0 == ab.length) throw new java.lang.Exception("DateAdjustParams de-serialize: Invalid byte stream input"); java.lang.String strRawString = new java.lang.String(ab); if (null == strRawString || strRawString.isEmpty()) throw new java.lang.Exception("DateAdjustParams de-serializer: Empty state"); java.lang.String strDAP = strRawString.substring(0, strRawString.indexOf(getObjectTrailer())); if (null == strDAP || strDAP.isEmpty()) throw new java.lang.Exception("DateAdjustParams de-serializer: Cannot locate state"); java.lang.String[] astrField = org.drip.analytics.support.GenericUtil.Split(strDAP, getFieldDelimiter()); if (null == astrField || 3 > astrField.length) throw new java.lang.Exception("DateAdjustParams de-serialize: Invalid number of fields"); // double dblVersion = new java.lang.Double (astrField[0]); if (null == astrField[1] || astrField[1].isEmpty() || org.drip.service.stream.Serializer.NULL_SER_STRING.equals(astrField[1])) throw new java.lang.Exception("DateAdjustParams de-serializer: Cannot locate roll mode"); _iRollMode = new java.lang.Integer(astrField[1]).intValue(); if (null == astrField[2] || astrField[2].isEmpty() || org.drip.service.stream.Serializer.NULL_SER_STRING.equals(astrField[2])) throw new java.lang.Exception("DateAdjustParams de-serializer: Cannot locate calendar"); _strCalendar = astrField[2]; }
/** * FloatingStream de-serialization from input byte array * * @param ab Byte Array * @throws java.lang.Exception Thrown if FloatingStream cannot be properly de-serialized */ public FloatingStream(final byte[] ab) throws java.lang.Exception { if (null == ab || 0 == ab.length) throw new java.lang.Exception("FloatingStream de-serializer: Invalid input Byte array"); java.lang.String strRawString = new java.lang.String(ab); if (null == strRawString || strRawString.isEmpty()) throw new java.lang.Exception("FloatingStream de-serializer: Empty state"); java.lang.String strSerializedFloatingStream = strRawString.substring(0, strRawString.indexOf(getObjectTrailer())); if (null == strSerializedFloatingStream || strSerializedFloatingStream.isEmpty()) throw new java.lang.Exception("FloatingStream de-serializer: Cannot locate state"); java.lang.String[] astrField = org.drip.quant.common.StringUtil.Split(strSerializedFloatingStream, getFieldDelimiter()); if (null == astrField || 13 > astrField.length) throw new java.lang.Exception("FloatingStream de-serializer: Invalid reqd field set"); // double dblVersion = new java.lang.Double (astrField[0]); if (null == astrField[1] || astrField[1].isEmpty() || org.drip.service.stream.Serializer.NULL_SER_STRING.equalsIgnoreCase(astrField[1])) throw new java.lang.Exception("FloatingStream de-serializer: Cannot locate notional"); _dblNotional = new java.lang.Double(astrField[1]); if (null == astrField[2] || astrField[2].isEmpty() || org.drip.service.stream.Serializer.NULL_SER_STRING.equalsIgnoreCase(astrField[2])) throw new java.lang.Exception("FloatingStream de-serializer: Cannot locate coupon"); _dblSpread = new java.lang.Double(astrField[2]); if (null == astrField[3] || astrField[3].isEmpty()) throw new java.lang.Exception("FloatingStream de-serializer: Cannot locate IR curve name"); if (!org.drip.service.stream.Serializer.NULL_SER_STRING.equalsIgnoreCase(astrField[3])) _strIR = astrField[3]; else _strIR = ""; if (null == astrField[4] || astrField[4].isEmpty()) throw new java.lang.Exception("FloatingStream de-serializer: Cannot locate code"); if (!org.drip.service.stream.Serializer.NULL_SER_STRING.equalsIgnoreCase(astrField[4])) _strCode = astrField[4]; else _strCode = ""; if (null == astrField[5] || astrField[5].isEmpty() || org.drip.service.stream.Serializer.NULL_SER_STRING.equalsIgnoreCase(astrField[5])) throw new java.lang.Exception( "FloatingStream de-serializer: Cannot locate Apply Acc EOM Adj"); _bApplyAccEOMAdj = new java.lang.Boolean(astrField[5]); if (null == astrField[6] || astrField[6].isEmpty() || org.drip.service.stream.Serializer.NULL_SER_STRING.equalsIgnoreCase(astrField[6])) throw new java.lang.Exception( "FloatingStream de-serializer: Cannot locate Apply Cpn EOM Adj"); _bApplyCpnEOMAdj = new java.lang.Boolean(astrField[6]); if (null == astrField[7] || astrField[7].isEmpty() || org.drip.service.stream.Serializer.NULL_SER_STRING.equalsIgnoreCase(astrField[7])) throw new java.lang.Exception("FloatingStream de-serializer: Cannot locate maturity date"); _dblMaturity = new java.lang.Double(astrField[7]); if (null == astrField[8] || astrField[8].isEmpty() || org.drip.service.stream.Serializer.NULL_SER_STRING.equalsIgnoreCase(astrField[8])) throw new java.lang.Exception("FloatingStream de-serializer: Cannot locate effective date"); _dblEffective = new java.lang.Double(astrField[8]); if (null == astrField[9] || astrField[9].isEmpty()) throw new java.lang.Exception("FloatingStream de-serializer: Cannot locate rate index"); if (org.drip.service.stream.Serializer.NULL_SER_STRING.equalsIgnoreCase(astrField[9])) _fri = null; else _fri = new org.drip.product.params.FloatingRateIndex(astrField[9].getBytes()); if (null == astrField[10] || astrField[10].isEmpty()) throw new java.lang.Exception( "FloatingStream de-serializer: Cannot locate notional schedule"); if (org.drip.service.stream.Serializer.NULL_SER_STRING.equalsIgnoreCase(astrField[10])) _notlSchedule = null; else _notlSchedule = new org.drip.product.params.FactorSchedule(astrField[10].getBytes()); if (null == astrField[11] || astrField[11].isEmpty()) throw new java.lang.Exception( "FloatingStream de-serializer: Cannot locate cash settle params"); if (org.drip.service.stream.Serializer.NULL_SER_STRING.equalsIgnoreCase(astrField[11])) _settleParams = null; else _settleParams = new org.drip.param.valuation.CashSettleParams(astrField[11].getBytes()); if (null == astrField[12] || astrField[12].isEmpty()) throw new java.lang.Exception("FloatingStream de-serializer: Cannot locate the periods"); if (org.drip.service.stream.Serializer.NULL_SER_STRING.equalsIgnoreCase(astrField[12])) _lsCouponPeriod = null; else { java.lang.String[] astrRecord = org.drip.quant.common.StringUtil.Split(astrField[12], getCollectionRecordDelimiter()); if (null != astrRecord && 0 != astrRecord.length) { for (int i = 0; i < astrRecord.length; ++i) { if (null == astrRecord[i] || astrRecord[i].isEmpty() || org.drip.service.stream.Serializer.NULL_SER_STRING.equalsIgnoreCase(astrRecord[i])) continue; if (null == _lsCouponPeriod) _lsCouponPeriod = new java.util.ArrayList<org.drip.analytics.period.CashflowPeriod>(); _lsCouponPeriod.add( new org.drip.analytics.period.CashflowPeriod(astrRecord[i].getBytes())); } } } }
/** * Cash de-serialization from input byte array * * @param ab Byte Array * @throws java.lang.Exception Thrown if Cash cannot be properly de-serialized */ public CashComponent(final byte[] ab) throws java.lang.Exception { if (null == ab || 0 == ab.length) throw new java.lang.Exception("Cash de-serializer: Invalid input Byte array"); java.lang.String strRawString = new java.lang.String(ab); if (null == strRawString || strRawString.isEmpty()) throw new java.lang.Exception("Cash de-serializer: Empty state"); java.lang.String strSerializedCash = strRawString.substring(0, strRawString.indexOf(getObjectTrailer())); if (null == strSerializedCash || strSerializedCash.isEmpty()) throw new java.lang.Exception("Cash de-serializer: Cannot locate state"); java.lang.String[] astrField = org.drip.analytics.support.GenericUtil.Split(strSerializedCash, getFieldDelimiter()); if (null == astrField || 9 > astrField.length) throw new java.lang.Exception("Cash de-serializer: Invalid reqd field set"); // double dblVersion = new java.lang.Double (astrField[0]).doubleValue(); if (null == astrField[1] || astrField[1].isEmpty() || org.drip.service.stream.Serializer.NULL_SER_STRING.equalsIgnoreCase(astrField[1])) throw new java.lang.Exception("Cash de-serializer: Cannot locate notional"); _dblNotional = new java.lang.Double(astrField[1]); if (null == astrField[2] || astrField[2].isEmpty()) throw new java.lang.Exception("Cash de-serializer: Cannot locate IR curve name"); if (!org.drip.service.stream.Serializer.NULL_SER_STRING.equalsIgnoreCase(astrField[2])) _strIR = astrField[2]; else _strIR = ""; if (null == astrField[3] || astrField[3].isEmpty()) throw new java.lang.Exception("Cash de-serializer: Cannot locate cash code"); if (!org.drip.service.stream.Serializer.NULL_SER_STRING.equalsIgnoreCase(astrField[3])) _strCode = astrField[3]; else _strCode = ""; if (null == astrField[4] || astrField[4].isEmpty()) throw new java.lang.Exception("Cash de-serializer: Cannot locate day count convention"); if (!org.drip.service.stream.Serializer.NULL_SER_STRING.equalsIgnoreCase(astrField[4])) _strDC = astrField[4]; else _strDC = ""; if (null == astrField[5] || astrField[5].isEmpty()) throw new java.lang.Exception("Cash de-serializer: Cannot locate Calendar"); if (!org.drip.service.stream.Serializer.NULL_SER_STRING.equalsIgnoreCase(astrField[4])) _strCalendar = astrField[5]; else _strCalendar = ""; if (null == astrField[6] || astrField[6].isEmpty() || org.drip.service.stream.Serializer.NULL_SER_STRING.equalsIgnoreCase(astrField[6])) throw new java.lang.Exception("Cash de-serializer: Cannot locate maturity date"); _dblMaturity = new java.lang.Double(astrField[6]); if (null == astrField[7] || astrField[7].isEmpty() || org.drip.service.stream.Serializer.NULL_SER_STRING.equalsIgnoreCase(astrField[7])) throw new java.lang.Exception("Cash de-serializer: Cannot locate effective date"); _dblEffective = new java.lang.Double(astrField[7]); if (null == astrField[8] || astrField[8].isEmpty()) throw new java.lang.Exception("Cash de-serializer: Cannot locate notional schedule"); if (org.drip.service.stream.Serializer.NULL_SER_STRING.equalsIgnoreCase(astrField[8])) _notlSchedule = null; else _notlSchedule = new org.drip.product.params.FactorSchedule(astrField[8].getBytes()); if (null == astrField[9] || astrField[9].isEmpty()) throw new java.lang.Exception("Cash de-serializer: Cannot locate cash settle params"); if (org.drip.service.stream.Serializer.NULL_SER_STRING.equalsIgnoreCase(astrField[9])) _settleParams = null; else _settleParams = new org.drip.param.valuation.CashSettleParams(astrField[9].getBytes()); }
/** * EmbeddedOptionSchedule de-serialization from input byte array * * @param ab Byte Array * @throws java.lang.Exception Thrown if EmbeddedOptionSchedule cannot be properly de-serialized */ public EmbeddedOptionSchedule(final byte[] ab) throws java.lang.Exception { if (null == ab || 0 == ab.length) throw new java.lang.Exception( "EmbeddedOptionSchedule de-serializer: Invalid input Byte array"); java.lang.String strRawString = new java.lang.String(ab); if (null == strRawString || strRawString.isEmpty()) throw new java.lang.Exception("EmbeddedOptionSchedule de-serializer: Empty state"); java.lang.String strSerializedEmbeddedOptionSchedule = strRawString.substring(0, strRawString.indexOf(getObjectTrailer())); if (null == strSerializedEmbeddedOptionSchedule || strSerializedEmbeddedOptionSchedule.isEmpty()) throw new java.lang.Exception("EmbeddedOptionSchedule de-serializer: Cannot locate state"); java.lang.String[] astrField = org.drip.math.common.StringUtil.Split( strSerializedEmbeddedOptionSchedule, getFieldDelimiter()); if (null == astrField || 8 > astrField.length) throw new java.lang.Exception("EmbeddedOptionSchedule de-serializer: Invalid reqd field set"); // double dblVersion = new java.lang.Double (astrField[0]); if (null == astrField[1] || astrField[1].isEmpty() || org.drip.service.stream.Serializer.NULL_SER_STRING.equalsIgnoreCase(astrField[1])) throw new java.lang.Exception( "EmbeddedOptionSchedule de-serializer: Cannot locate notice period"); _iNoticePeriod = new java.lang.Integer(astrField[1]); if (null == astrField[2] || astrField[2].isEmpty() || org.drip.service.stream.Serializer.NULL_SER_STRING.equalsIgnoreCase(astrField[2])) throw new java.lang.Exception("EmbeddedOptionSchedule de-serializer: Cannot locate Put flag"); _bIsPut = new java.lang.Boolean(astrField[2]); if (null == astrField[3] || astrField[3].isEmpty() || org.drip.service.stream.Serializer.NULL_SER_STRING.equalsIgnoreCase(astrField[3])) throw new java.lang.Exception( "EmbeddedOptionSchedule de-serializer: Cannot locate fix-to-float-on-exercise flag"); _bFixToFloatOnExercise = new java.lang.Boolean(astrField[3]); if (null == astrField[4] || astrField[4].isEmpty() || org.drip.service.stream.Serializer.NULL_SER_STRING.equalsIgnoreCase(astrField[4])) throw new java.lang.Exception( "EmbeddedOptionSchedule de-serializer: Cannot locate fix-to-float-on-exercise flag"); _dblFixToFloatSpread = new java.lang.Double(astrField[4]); if (null == astrField[5] || astrField[5].isEmpty() || org.drip.service.stream.Serializer.NULL_SER_STRING.equalsIgnoreCase(astrField[5])) throw new java.lang.Exception( "EmbeddedOptionSchedule de-serializer: Cannot locate fix-to-float exercise date"); _dblFixToFloatExerciseDate = new java.lang.Double(astrField[5]).doubleValue(); if (null == astrField[6] || astrField[6].isEmpty()) throw new java.lang.Exception( "EmbeddedOptionSchedule de-serializer: Cannot locate float index"); if (org.drip.service.stream.Serializer.NULL_SER_STRING.equalsIgnoreCase(astrField[6])) _strFloatIndex = ""; else _strFloatIndex = astrField[6]; if (null == astrField[7] || astrField[7].isEmpty() || org.drip.service.stream.Serializer.NULL_SER_STRING.equalsIgnoreCase(astrField[7])) throw new java.lang.Exception("EmbeddedOptionSchedule de-serializer: Cannot decode state"); java.util.List<java.lang.Double> lsdblDate = new java.util.ArrayList<java.lang.Double>(); java.util.List<java.lang.Double> lsdblFactor = new java.util.ArrayList<java.lang.Double>(); if (!org.drip.math.common.StringUtil.KeyValueListFromStringArray( lsdblDate, lsdblFactor, astrField[7], getCollectionRecordDelimiter(), getCollectionKeyValueDelimiter())) throw new java.lang.Exception( "EmbeddedOptionSchedule de-serializer: Cannot decode hazard state"); if (0 == lsdblDate.size() || 0 == lsdblFactor.size() || lsdblDate.size() != lsdblFactor.size()) throw new java.lang.Exception( "EmbeddedOptionSchedule de-serializer: Cannot decode hazard state"); _adblDate = new double[lsdblDate.size()]; _adblFactor = new double[lsdblFactor.size()]; for (int i = 0; i < _adblFactor.length; ++i) { _adblDate[i] = lsdblDate.get(i); _adblFactor[i] = lsdblFactor.get(i); } }