Examples of StreamFactory


Examples of de.lmu.ifi.dbs.elki.result.textwriter.StreamFactory

  @Override
  public void processNewResult(HierarchicalResult baseresult, Result result) {
    TextWriter writer = new TextWriter();

    StreamFactory output;
    try {
      if(out == null) {
        output = new SingleStreamOutput(gzip);
      }
      else if(out.exists()) {
        if(out.isDirectory()) {
          if(warnoverwrite && out.listFiles().length > 0) {
            logger.warning("Output directory specified is not empty. Files will be overwritten and old files may be left over.");
          }
          output = new MultipleFilesOutput(out, gzip);
        }
        else {
          if(warnoverwrite) {
            logger.warning("Output file exists and will be overwritten!");
          }
          output = new SingleStreamOutput(out, gzip);
        }
      }
      else {
        // If it doesn't exist yet, make a MultipleFilesOutput.
        output = new MultipleFilesOutput(out, gzip);
      }
    }
    catch(IOException e) {
      throw new IllegalStateException("Error opening output.", e);
    }
    try {
      Database db = ResultUtil.findDatabase(baseresult);
      writer.output(db, result, output);
    }
    catch(IOException e) {
      throw new IllegalStateException("Input/Output error while writing result.", e);
    }
    catch(UnableToComplyException e) {
      throw new IllegalStateException("Unable to comply while writing result.", e);
    }
    output.closeAllStreams();
  }
View Full Code Here

Examples of de.lmu.ifi.dbs.elki.result.textwriter.StreamFactory

  @Override
  public void processNewResult(HierarchicalResult baseresult, Result result) {
    TextWriter writer = new TextWriter();

    StreamFactory output;
    try {
      if(out == null) {
        output = new SingleStreamOutput(gzip);
      }
      else if(out.exists()) {
        if(out.isDirectory()) {
          if(warnoverwrite && out.listFiles().length > 0) {
            logger.warning("Output directory specified is not empty. Files will be overwritten and old files may be left over.");
          }
          output = new MultipleFilesOutput(out, gzip);
        }
        else {
          if(warnoverwrite) {
            logger.warning("Output file exists and will be overwritten!");
          }
          output = new SingleStreamOutput(out, gzip);
        }
      }
      else {
        // If it doesn't exist yet, make a MultipleFilesOutput.
        output = new MultipleFilesOutput(out, gzip);
      }
    }
    catch(IOException e) {
      throw new IllegalStateException("Error opening output.", e);
    }
    try {
      Database db = ResultUtil.findDatabase(baseresult);
      writer.output(db, result, output);
    }
    catch(IOException e) {
      throw new IllegalStateException("Input/Output error while writing result.", e);
    }
    catch(UnableToComplyException e) {
      throw new IllegalStateException("Unable to comply while writing result.", e);
    }
    output.closeAllStreams();
  }
View Full Code Here

Examples of org.apache.wsif.compiler.util.StreamFactory

            }
        }

        int classCount = classFileList.size();
        String[] fileNames = new String[classCount];
        StreamFactory streamFactory = new StreamFactory();

        for (int classIndex = 0; classIndex < classCount; classIndex++) {
            ClassFile classFile =
                (ClassFile) classFileList.elementAt(classIndex);
            String javaPathName =
                Conventions.getJavaPathName(
                    getWorkingDirectory(),
                    classFile.packageName);
            String javaFileName = classFile.className + ".java";
            OutputStream os =
                streamFactory.getOutputStream(
                    javaPathName,
                    javaFileName,
                    overwrite);
            Writer classWriter = new OutputStreamWriter(os);
View Full Code Here

Examples of org.beanio.StreamFactory

    private BeanWriter beanWriter;

    @Override
    public void open(final Serializable checkpoint) throws Exception {
        mappingFileKey = new StreamFactoryKey(jobContext, streamMapping);
        final StreamFactory streamFactory = getStreamFactory(streamFactoryLookup, mappingFileKey, mappingProperties);
        final OutputStream outputStream = getOutputStream(CsvProperties.OVERWRITE);
        final Writer outputWriter = charset == null ? new OutputStreamWriter(outputStream) :
                new OutputStreamWriter(outputStream, charset);
        beanWriter = streamFactory.createWriter(streamName, new BufferedWriter(outputWriter));
    }
View Full Code Here

Examples of org.beanio.StreamFactory

        if (startRowNumber < this.start || startRowNumber > this.end || startRowNumber < 0) {
            throw SupportMessages.MESSAGES.invalidStartPosition(startRowNumber, this.start, this.end);
        }

        mappingFileKey = new StreamFactoryKey(jobContext, streamMapping);
        final StreamFactory streamFactory = getStreamFactory(streamFactoryLookup, mappingFileKey, mappingProperties);
        final InputStream inputStream = getInputStream(resource, false);
        final Reader inputReader = charset == null ? new InputStreamReader(inputStream) :
                new InputStreamReader(inputStream, charset);
        beanReader = streamFactory.createReader(streamName, new BufferedReader(inputReader), LocaleUtil.parseLocale(locale));

        if (errorHandler != null) {
            beanReader.setErrorHandler((BeanReaderErrorHandler) errorHandler.newInstance());
        }
        if (startRowNumber > 1) {
View Full Code Here

Examples of org.beanio.StreamFactory

                                          final Map mappingProperties) throws Exception {
        if (streamFactoryLookup != null) {
            return InitialContext.doLookup(streamFactoryLookup);
        }
        synchronized (beanIOMappings) {
            StreamFactory streamFactory = beanIOMappings.get(key);
            if (streamFactory != null) {
                return streamFactory;
            }
            final InputStream mappingInputStream = getInputStream(key.mappingFile, false);
            if (mappingInputStream == null) {
                throw SupportMessages.MESSAGES.invalidReaderWriterProperty(null, null, "streamMapping");
            }
            streamFactory = StreamFactory.newInstance();

            try {
                if (mappingProperties == null) {
                    streamFactory.load(mappingInputStream);
                } else {
                    final Properties p = new Properties();
                    p.putAll(mappingProperties);
                    streamFactory.load(mappingInputStream, p);
                }
            } finally {
                try {
                    mappingInputStream.close();
                } catch (final IOException ioe) {
View Full Code Here

Examples of org.beanio.StreamFactory

        if (startRowNumber < this.start || startRowNumber > this.end || startRowNumber < 0) {
            throw SupportMessages.MESSAGES.invalidStartPosition(startRowNumber, this.start, this.end);
        }

        mappingFileKey = new StreamFactoryKey(jobContext, streamMapping);
        final StreamFactory streamFactory = getStreamFactory(streamFactoryLookup, mappingFileKey, mappingProperties);
        final InputStream inputStream = getInputStream(resource, false);
        final Reader inputReader = charset == null ? new InputStreamReader(inputStream) :
                new InputStreamReader(inputStream, charset);
        beanReader = streamFactory.createReader(streamName, new BufferedReader(inputReader), LocaleUtil.parseLocale(locale));

        if (errorHandler != null) {
            beanReader.setErrorHandler((BeanReaderErrorHandler) errorHandler.newInstance());
        }
        if (startRowNumber > 1) {
View Full Code Here

Examples of org.beanio.StreamFactory

    private BeanWriter beanWriter;

    @Override
    public void open(final Serializable checkpoint) throws Exception {
        mappingFileKey = new StreamFactoryKey(jobContext, streamMapping);
        final StreamFactory streamFactory = getStreamFactory(streamFactoryLookup, mappingFileKey, mappingProperties);
        final OutputStream outputStream = getOutputStream(CsvProperties.OVERWRITE);
        final Writer outputWriter = charset == null ? new OutputStreamWriter(outputStream) :
                new OutputStreamWriter(outputStream, charset);
        beanWriter = streamFactory.createWriter(streamName, new BufferedWriter(outputWriter));
    }
View Full Code Here

Examples of org.beanio.StreamFactory

        if (startRowNumber < this.start || startRowNumber > this.end || startRowNumber < 0) {
            throw SupportMessages.MESSAGES.invalidStartPosition(startRowNumber, this.start, this.end);
        }

        mappingFileKey = new StreamFactoryKey(jobContext, streamMapping);
        final StreamFactory streamFactory = getStreamFactory(streamFactoryLookup, mappingFileKey, mappingProperties);
        final InputStream inputStream = getInputStream(resource, false);
        final Reader inputReader = charset == null ? new InputStreamReader(inputStream) :
                new InputStreamReader(inputStream, charset);
        beanReader = streamFactory.createReader(streamName, new BufferedReader(inputReader), LocaleUtil.parseLocale(locale));

        if (errorHandler != null) {
            beanReader.setErrorHandler((BeanReaderErrorHandler) errorHandler.newInstance());
        }
        if (startRowNumber > 1) {
View Full Code Here

Examples of org.beanio.StreamFactory

                                          final Map mappingProperties) throws Exception {
        if (streamFactoryLookup != null) {
            return InitialContext.doLookup(streamFactoryLookup);
        }
        synchronized (beanIOMappings) {
            StreamFactory streamFactory = beanIOMappings.get(key);
            if (streamFactory != null) {
                return streamFactory;
            }
            final InputStream mappingInputStream = getInputStream(key.mappingFile, false);
            if (mappingInputStream == null) {
                throw SupportMessages.MESSAGES.invalidReaderWriterProperty(null, null, "streamMapping");
            }
            streamFactory = StreamFactory.newInstance();

            try {
                if (mappingProperties == null) {
                    streamFactory.load(mappingInputStream);
                } else {
                    final Properties p = new Properties();
                    p.putAll(mappingProperties);
                    streamFactory.load(mappingInputStream, p);
                }
            } finally {
                try {
                    mappingInputStream.close();
                } catch (final IOException ioe) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.