/**
   * 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());
  }
  /**
   * Return the stringified set of parameters in a java call that can be statically used to
   * re-construct the index.
   *
   * @return Set of Stringified parameters as a java call.
   */
  public java.lang.String setConstructionString() {
    java.lang.StringBuffer sb = new java.lang.StringBuffer();

    java.lang.String strCDXCode =
        _strIndexClass
            + "."
            + _strIndexGroupName
            + "."
            + _iIndexLifeSpan
            + "Y."
            + _iIndexSeries
            + "."
            + _iIndexVersion;

    sb.append(
        "\t\tUpdateCDXRefDataMap ("
            + org.drip.quant.common.StringUtil.MakeStringArg(strCDXCode)
            + ",\n\t\t\torg.drip.product.creator.CDXRefDataBuilder.CreateCDXRefDataBuilder (");

    sb.append(org.drip.quant.common.StringUtil.MakeStringArg(_strCurveID) + ", ");

    sb.append(org.drip.quant.common.StringUtil.MakeStringArg(_strSPN) + ",\n\t\t\t\t");

    sb.append(org.drip.quant.common.StringUtil.MakeStringArg(_strIndexLabel) + ", ");

    sb.append(org.drip.quant.common.StringUtil.MakeStringArg(_strIndexName) + ",\n\t\t\t\t\t");

    sb.append(org.drip.quant.common.StringUtil.MakeStringArg(_strCurveName) + ", ");

    sb.append(_dtIssue.getJulian() + ", ");

    sb.append(_dtMaturity.getJulian() + ", ");

    sb.append(_dblCoupon + ", ");

    sb.append(org.drip.quant.common.StringUtil.MakeStringArg(_strCurrency) + ",\n\t\t\t\t\t\t");

    sb.append(org.drip.quant.common.StringUtil.MakeStringArg(_strDayCount) + ", ");

    sb.append(_bFullFirstStub + ", ");

    sb.append(_dblRecovery + ", ");

    sb.append(_iFrequency + ", ");

    sb.append(org.drip.quant.common.StringUtil.MakeStringArg(_strRedID) + ", ");

    sb.append(org.drip.quant.common.StringUtil.MakeStringArg(_strIndexClass) + ", ");

    sb.append(_iIndexSeries + ", ");

    sb.append(org.drip.quant.common.StringUtil.MakeStringArg(_strIndexGroupName) + ", ");

    sb.append(org.drip.quant.common.StringUtil.MakeStringArg(_strIndexShortName) + ", ");

    sb.append(org.drip.quant.common.StringUtil.MakeStringArg(_strIndexShortGroupName) + ", ");

    sb.append(_iIndexVersion + ", ");

    sb.append(_iIndexLifeSpan + ",\n\t\t\t\t\t\t\t");

    sb.append(org.drip.quant.common.StringUtil.MakeStringArg(_strCurvyCurveID) + ", ");

    sb.append(_dblIndexFactor + ", ");

    sb.append(_iOriginalComponentCount + ", ");

    sb.append(_iDefaultedComponentCount + ", ");

    sb.append(org.drip.quant.common.StringUtil.MakeStringArg(_strLocation) + ", ");

    sb.append(_bPayAccrued + ", ");

    sb.append(_bKnockOutOnDefault + ", ");

    sb.append(_bQuoteAsCDS + ", ");

    sb.append(org.drip.quant.common.StringUtil.MakeStringArg(_strBBGTicker) + ", ");

    sb.append(org.drip.quant.common.StringUtil.MakeStringArg(_strShortName) + "));\n\n");

    return sb.toString();
  }
  /**
   * 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()));
        }
      }
    }
  }