Ejemplo n.º 1
0
 @Override
 public void report() throws IOException {
   Pair<FileType, Exporter> stateFormat = Exporters.getAcceptingFormat(this.statePattern);
   if (stateFormat == null) {
     this.logger.append(
         "Pattern %s does not specify export format: states saved in native GXL%n",
         this.statePattern);
   } else {
     this.logger.append("States saved as %s%n", stateFormat.one().getDescription());
   }
   for (GraphState state : getExploration().getResult()) {
     File savedFile = exportState(state, this.statePattern);
     this.logger.append("State saved: %s%n", savedFile);
   }
 }
Ejemplo n.º 2
0
 /**
  * Exports a given state using a filename derived from a state pattern.
  *
  * @param state the state to be exported
  * @param pattern the filename pattern
  * @throws IOException if anything went wrong during export
  */
 public static File exportState(GraphState state, String pattern) throws IOException {
   String stateFilename = pattern.replace(PLACEHOLDER, "" + state.getNumber());
   File stateFile = new File(stateFilename);
   Pair<FileType, Exporter> stateFormat = Exporters.getAcceptingFormat(stateFilename);
   if (stateFormat != null) {
     try {
       stateFormat.two().doExport(new Exportable(state.getGraph()), stateFile, stateFormat.one());
     } catch (PortException e1) {
       throw new IOException(e1);
     }
   } else {
     if (!FileType.hasAnyExtension(stateFile)) {
       stateFile = FileType.STATE.addExtension(stateFile);
     }
     Groove.saveGraph(GraphConverter.toAspect(state.getGraph()), stateFile);
   }
   return stateFile;
 }