Ejemplo n.º 1
0
  /**
   * @param type
   * @param fileName
   * @return
   * @throws BirtException
   */
  private DataEngineContext newContext(int type, String fileName) throws BirtException {

    switch (type) {
      case DataEngineContext.MODE_GENERATION:
        {
          try {
            archiveWriter = new FileArchiveWriter(fileName);
            archiveWriter.initialize();
          } catch (IOException e) {
            throw new IllegalArgumentException(e.getMessage());
          }
          return DataEngineContext.newInstance(
              DataEngineContext.MODE_GENERATION, null, null, archiveWriter);
        }
      case DataEngineContext.MODE_PRESENTATION:
        {
          try {
            archiveReader = new FileArchiveReader(fileName);
            archiveReader.open();
          } catch (IOException e) {
            throw new IllegalArgumentException(e.getMessage());
          }
          return DataEngineContext.newInstance(
              DataEngineContext.MODE_PRESENTATION, null, archiveReader, null);
        }
      default:
        throw new IllegalArgumentException("" + type);
    }
  }
Ejemplo n.º 2
0
 /** @throws DataException */
 private void closeArchiveWriter() throws DataException {
   if (archiveWriter != null)
     try {
       archiveWriter.finish();
     } catch (IOException e) {
       throw new DataException("error", e);
     }
 }