/** {@inheritDoc} */
  @Override
  public final Object read(final InputStream is) {
    final BAM result = new BAM();
    final EncogReadHelper in = new EncogReadHelper(is);
    EncogFileSection section;

    while ((section = in.readNextSection()) != null) {
      if (section.getSectionName().equals("BAM") && section.getSubSectionName().equals("PARAMS")) {
        final Map<String, String> params = section.parseParams();
        result.getProperties().putAll(params);
      }
      if (section.getSectionName().equals("BAM") && section.getSubSectionName().equals("NETWORK")) {
        final Map<String, String> params = section.parseParams();

        result.setF1Count(EncogFileSection.parseInt(params, PersistConst.PROPERTY_F1_COUNT));
        result.setF2Count(EncogFileSection.parseInt(params, PersistConst.PROPERTY_F2_COUNT));
        result.setWeightsF1toF2(
            EncogFileSection.parseMatrix(params, PersistConst.PROPERTY_WEIGHTS_F1_F2));
        result.setWeightsF2toF1(
            EncogFileSection.parseMatrix(params, PersistConst.PROPERTY_WEIGHTS_F2_F1));
      }
    }

    return result;
  }
  /** {@inheritDoc} */
  @Override
  public final Object read(final InputStream is) {
    Map<String, String> networkParams = null;
    final EncogReadHelper in = new EncogReadHelper(is);
    EncogFileSection section;
    int inputCount = 0;
    int instarCount = 0;
    int outputCount = 0;
    int winnerCount = 0;
    Matrix m1 = null;
    Matrix m2 = null;

    while ((section = in.readNextSection()) != null) {
      if (section.getSectionName().equals("CPN") && section.getSubSectionName().equals("PARAMS")) {
        networkParams = section.parseParams();
      }
      if (section.getSectionName().equals("CPN") && section.getSubSectionName().equals("NETWORK")) {
        final Map<String, String> params = section.parseParams();

        inputCount = EncogFileSection.parseInt(params, PersistConst.INPUT_COUNT);
        instarCount = EncogFileSection.parseInt(params, PersistConst.INSTAR);
        outputCount = EncogFileSection.parseInt(params, PersistConst.OUTPUT_COUNT);
        winnerCount = EncogFileSection.parseInt(params, PersistCPN.PROPERTY_winnerCount);
        m1 = EncogFileSection.parseMatrix(params, PersistCPN.PROPERTY_inputToInstar);
        m2 = EncogFileSection.parseMatrix(params, PersistCPN.PROPERTY_instarToInput);
      }
    }

    final CPN result = new CPN(inputCount, instarCount, outputCount, winnerCount);
    result.getProperties().putAll(networkParams);
    result.getWeightsInputToInstar().set(m1);
    result.getWeightsInstarToOutstar().set(m2);
    return result;
  }
  /** {@inheritDoc} */
  @Override
  public Object read(final InputStream is) {
    final ART1 result = new ART1();
    final EncogReadHelper in = new EncogReadHelper(is);
    EncogFileSection section;

    while ((section = in.readNextSection()) != null) {
      if (section.getSectionName().equals("ART1") && section.getSubSectionName().equals("PARAMS")) {
        final Map<String, String> params = section.parseParams();
        result.getProperties().putAll(params);
      }
      if (section.getSectionName().equals("ART1")
          && section.getSubSectionName().equals("NETWORK")) {
        final Map<String, String> params = section.parseParams();

        result.setA1(EncogFileSection.parseDouble(params, ART.PROPERTY_A1));
        result.setB1(EncogFileSection.parseDouble(params, ART.PROPERTY_B1));
        result.setC1(EncogFileSection.parseDouble(params, ART.PROPERTY_C1));
        result.setD1(EncogFileSection.parseDouble(params, ART.PROPERTY_D1));
        result.setF1Count(EncogFileSection.parseInt(params, PersistConst.PROPERTY_F1_COUNT));
        result.setF2Count(EncogFileSection.parseInt(params, PersistConst.PROPERTY_F2_COUNT));
        result.setNoWinner(EncogFileSection.parseInt(params, ART.PROPERTY_NO_WINNER));
        result.setL(EncogFileSection.parseDouble(params, ART.PROPERTY_L));
        result.setVigilance(EncogFileSection.parseDouble(params, ART.PROPERTY_VIGILANCE));
        result.setWeightsF1toF2(
            EncogFileSection.parseMatrix(params, PersistConst.PROPERTY_WEIGHTS_F1_F2));
        result.setWeightsF2toF1(
            EncogFileSection.parseMatrix(params, PersistConst.PROPERTY_WEIGHTS_F2_F1));
      }
    }

    return result;
  }
  /** {@inheritDoc} */
  @Override
  public final Object read(final InputStream is) {
    final SOM result = new SOM();
    final EncogReadHelper in = new EncogReadHelper(is);
    EncogFileSection section;

    while ((section = in.readNextSection()) != null) {
      if (section.getSectionName().equals("SOM") && section.getSubSectionName().equals("PARAMS")) {
        final Map<String, String> params = section.parseParams();
        result.getProperties().putAll(params);
      }
      if (section.getSectionName().equals("SOM") && section.getSubSectionName().equals("NETWORK")) {
        final Map<String, String> params = section.parseParams();
        result.setWeights(EncogFileSection.parseMatrix(params, PersistConst.WEIGHTS));
        result.setOutputNeuronCount(EncogFileSection.parseInt(params, PersistConst.OUTPUT_COUNT));
        result.setInputCount(EncogFileSection.parseInt(params, PersistConst.INPUT_COUNT));
      }
    }

    return result;
  }