Package uk.ac.starlink.util
Class ProcessDataSource
java.lang.Object
uk.ac.starlink.util.DataSource
uk.ac.starlink.util.ProcessDataSource
DataSource that uses the standard output of a System process.
- Since:
- 24 Mar 2015
- Author:
- Mark Taylor
-
Field Summary
Fields inherited from class uk.ac.starlink.util.DataSource
DEFAULT_INTRO_LIMIT, MARK_WORKAROUND_PROPERTY
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ProcessBuilder
createCommandLineProcessBuilder
(String cmdLine) Utility method to create a process builder given a shell command line that generates output to standard output.protected InputStream
Provides a new InputStream for this data source.Methods inherited from class uk.ac.starlink.util.DataSource
close, forceCompression, getCompression, getHybridInputStream, getInputStream, getInputStream, getIntro, getIntroLimit, getLength, getMarkWorkaround, getName, getPosition, getRawLength, getSystemId, getURL, makeDataSource, makeDataSource, makeDataSource, setCompression, setIntroLimit, setMarkWorkaround, setName, setPosition, toString
-
Constructor Details
-
ProcessDataSource
Constructor.- Parameters:
pbuilder
- process builder
-
-
Method Details
-
getRawInputStream
Description copied from class:DataSource
Provides a new InputStream for this data source. This method should be implemented by subclasses to provide a new InputStream giving the raw content of the source each time it is called. The general contract of this method is that each time it is called it will return a stream with the same content.- Specified by:
getRawInputStream
in classDataSource
- Returns:
- an InputStream containing the data of this source
- Throws:
IOException
-
createCommandLineProcessBuilder
Utility method to create a process builder given a shell command line that generates output to standard output. The command line may contain shell syntax like | symbols.This method simply sets up a ProcessBuilder to execute a process with the argv { "sh", "-c", cmdLine }. I haven't tested this exhaustively, but I'd expect it to work on un*x-like systems. I've got no idea if there's any chance of getting something like this to work on MS Windows, or even if such a thing would be any use.
- Parameters:
cmdLine
- shell command that generates output to stdout- Returns:
- process builder to execute cmdLine
-