Exemple #1
0
  @Override
  public boolean equals(Object obj) {

    if (obj == this) {
      return true;
    }

    Datum instance;
    if (obj instanceof Datum) {
      instance = (Datum) obj;
    } else {
      return false;
    }

    return myName.equals(instance.getName())
        && (myData == instance.getData())
        && (myComment.equals(instance.getComment()));
  }
  public DataSet performFunction(DataSet input) {

    List data = input.getDataSet();

    int numSaveFiles = 0;
    if (mySaveFiles != null) {
      numSaveFiles = mySaveFiles.length;
    }

    if ((numSaveFiles != 0) && (numSaveFiles != 1) && (numSaveFiles != data.size())) {
      throw new IllegalStateException(
          "ExportMultiplePlugin: performFunction: number of save files should be either 0, 1 or number of input data sets.");
    }

    if ((myFileTypes != null) && (myFileTypes.length != 0)) {
      if ((myFileTypes.length != 1) && (myFileTypes.length != data.size())) {
        throw new IllegalStateException(
            "ExportMultiplePlugin: performFunction: number of files types should be either 0, 1 or number of input data sets.");
      }
    }

    for (int i = 0, n = data.size(); i < n; i++) {

      Datum datum = (Datum) data.get(i);
      DataSet current = new DataSet(datum, input.getCreator());

      if (numSaveFiles == 0) {
        myExportPlugin.setSaveFile(datum.getName());
      } else if (numSaveFiles == 1) {
        String temp;
        if (data.size() == 1) {
          temp = mySaveFiles[0];
        } else {
          temp = mySaveFiles[0].replaceFirst("\\.", (i + 1) + ".");
          if (temp.length() == mySaveFiles[0].length()) {
            temp = mySaveFiles[0] + (i + 1);
          }
        }
        myExportPlugin.setSaveFile(temp);
      } else {
        myExportPlugin.setSaveFile(mySaveFiles[i]);
      }

      if ((myFileTypes == null) || (myFileTypes.length == 0)) {
        // do nothing
      } else if (myFileTypes.length == 1) {
        myExportPlugin.setAlignmentFileType(myFileTypes[0]);
      } else {
        myExportPlugin.setAlignmentFileType(myFileTypes[i]);
      }

      DataSet filename = myExportPlugin.performFunction(current);
      myLogger.info(
          "Datum: "
              + datum.getName()
              + " Written to: "
              + filename.getDataOfType(String.class).get(0).getData());
    }

    return null;
  }