Package adams.data.io.input
Class ZippedSpectrumReader
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.data.io.input.AbstractDataContainerReader<Spectrum>
-
- adams.data.io.input.AbstractSpectrumReader
-
- adams.data.io.input.ZippedSpectrumReader
-
- All Implemented Interfaces:
adams.core.AdditionalInformationHandler,adams.core.CleanUpHandler,adams.core.Destroyable,adams.core.GlobalInfoSupporter,adams.core.io.FileFormatHandler,adams.core.logging.LoggingLevelHandler,adams.core.logging.LoggingSupporter,adams.core.option.OptionHandler,adams.core.ShallowCopySupporter<adams.data.io.input.DataContainerReader>,adams.core.SizeOfHandler,adams.core.Stoppable,adams.data.io.input.DataContainerReader<Spectrum>,Serializable,Comparable
public class ZippedSpectrumReader extends AbstractSpectrumReader
Reads spectra from the zip file using the specified base reader.
-logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel) The logging level for outputting errors and debugging output. default: WARNING
-input <adams.core.io.PlaceholderFile> (property: input) The file to read and turn into a container. default: ${CWD}-create-dummy-report <boolean> (property: createDummyReport) If true, then a dummy report is created if none present. default: false
-instrument <java.lang.String> (property: instrument) The name of the instrument that generated the spectra (if not already present in data). default: unknown
-format <java.lang.String> (property: format) The data format string. default: NIR
-keep-format <boolean> (property: keepFormat) If enabled the format obtained from the file is not replaced by the format defined here. default: false
-use-absolute-source <boolean> (property: useAbsoluteSource) If enabled the source report field stores the absolute file name rather than just the name. default: false
-reader <adams.data.io.input.AbstractSpectrumReader> (property: reader) The reader to use for reading the spectra from the zip file. default: adams.data.io.input.SimpleSpectrumReader
-reg-exp <adams.core.base.BaseRegExp> (property: regExp) The regular expression that the file names must match in order to be extracted. default: .* more: https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html
-invert <boolean> (property: invertMatching) If set to true, the matching sense of the regular expression is inverted. default: false
-buffer <int> (property: bufferSize) The size of the buffer in bytes for the data stream. default: 1024
- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected intm_BufferSizethe buffer size to use.protected booleanm_InvertMatchinginvert matching sense.protected AbstractSpectrumReaderm_Readerthe base reader to use.protected adams.core.base.BaseRegExpm_RegExpthe regular expression that the filenames must match to be extracted.-
Fields inherited from class adams.data.io.input.AbstractSpectrumReader
m_Format, m_Instrument, m_KeepFormat, m_Stopped, m_UseAbsoluteSource, OPTION_OUTPUTDIR
-
-
Constructor Summary
Constructors Constructor Description ZippedSpectrumReader()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StringbufferSizeTipText()Returns the tip text for this property.voiddefineOptions()Adds options to the internal list of options.intgetBufferSize()Returns the buffer size for the stream.StringgetFormatDescription()Returns a string describing the format (used in the file chooser).String[]getFormatExtensions()Returns the extension(s) of the format.booleangetInvertMatching()Returns whether to invert the matching sense of the regular expression.AbstractSpectrumReadergetReader()Returns the reader to use.adams.core.base.BaseRegExpgetRegExp()Returns the regular expression that the filenames must match.StringglobalInfo()Returns a string describing the object.protected voidinitialize()Initializes the reader.StringinvertMatchingTipText()Returns the tip text for this property.static voidmain(String[] args)Runs the reader from the command-line.protected voidreadData()Performs the actual reading.protected voidreadDataFromFile(org.apache.commons.compress.archivers.zip.ZipFile archive, org.apache.commons.compress.archivers.zip.ZipArchiveEntry entry, Set<String> ignored)Performs the actual reading using readers that do not support streaming.protected voidreadDataFromStream(org.apache.commons.compress.archivers.zip.ZipFile archive, org.apache.commons.compress.archivers.zip.ZipArchiveEntry entry, Set<String> ignored)Performs the actual reading using readers that do not support streaming.StringreaderTipText()Returns the tip text for this property.StringregExpTipText()Returns the tip text for this property.voidsetBufferSize(int value)Sets the buffer size for the stream.voidsetInvertMatching(boolean value)Sets whether to invert the matching sense of the regular expression.voidsetReader(AbstractSpectrumReader value)Sets the reader to use.voidsetRegExp(adams.core.base.BaseRegExp value)Sets the regular expression that the filenames must match.-
Methods inherited from class adams.data.io.input.AbstractSpectrumReader
checkData, createDummyReport, formatTipText, getDefaultFormat, getDefaultInstrument, getDefaultKeepFormat, getDefaultUseAbsoluteSource, getFormat, getInstrument, getKeepFormat, getReaders, getUseAbsoluteSource, instrumentTipText, keepFormatTipText, postProcessData, runReader, setFormat, setInstrument, setKeepFormat, setUseAbsoluteSource, stopExecution, useAbsoluteSourceTipText
-
Methods inherited from class adams.data.io.input.AbstractDataContainerReader
cleanUp, compareTo, createDummyReportTipText, destroy, doRead, equals, getAdditionalInformation, getCreateDummyReport, getDefaultFormatExtension, getInput, inputTipText, isInputFile, read, reset, setCreateDummyReport, setInput, shallowCopy, shallowCopy
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, finishInit, getDefaultLoggingLevel, getOptionManager, loggingLevelTipText, newOptionManager, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
-
-
-
Field Detail
-
m_Reader
protected AbstractSpectrumReader m_Reader
the base reader to use.
-
m_RegExp
protected adams.core.base.BaseRegExp m_RegExp
the regular expression that the filenames must match to be extracted.
-
m_InvertMatching
protected boolean m_InvertMatching
invert matching sense.
-
m_BufferSize
protected int m_BufferSize
the buffer size to use.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfoin interfaceadams.core.GlobalInfoSupporter- Specified by:
globalInfoin classadams.core.option.AbstractOptionHandler- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptionsin interfaceadams.core.option.OptionHandler- Overrides:
defineOptionsin classAbstractSpectrumReader
-
initialize
protected void initialize()
Initializes the reader.- Overrides:
initializein classadams.data.io.input.AbstractDataContainerReader<Spectrum>
-
setReader
public void setReader(AbstractSpectrumReader value)
Sets the reader to use.- Parameters:
value- the reader to use
-
getReader
public AbstractSpectrumReader getReader()
Returns the reader to use.- Returns:
- the reader to use
-
readerTipText
public String readerTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setRegExp
public void setRegExp(adams.core.base.BaseRegExp value)
Sets the regular expression that the filenames must match.- Parameters:
value- the regular expression
-
getRegExp
public adams.core.base.BaseRegExp getRegExp()
Returns the regular expression that the filenames must match.- Returns:
- the regular expression
-
regExpTipText
public String regExpTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setInvertMatching
public void setInvertMatching(boolean value)
Sets whether to invert the matching sense of the regular expression.- Parameters:
value- true if the matching sense is to be inverted
-
getInvertMatching
public boolean getInvertMatching()
Returns whether to invert the matching sense of the regular expression.- Returns:
- true if the matching sense is to be inverted
-
invertMatchingTipText
public String invertMatchingTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setBufferSize
public void setBufferSize(int value)
Sets the buffer size for the stream.- Parameters:
value- the size in bytes
-
getBufferSize
public int getBufferSize()
Returns the buffer size for the stream.- Returns:
- the size in bytes
-
bufferSizeTipText
public String bufferSizeTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getFormatDescription
public String getFormatDescription()
Returns a string describing the format (used in the file chooser).- Specified by:
getFormatDescriptionin interfaceadams.core.io.FileFormatHandler- Specified by:
getFormatDescriptionin classadams.data.io.input.AbstractDataContainerReader<Spectrum>- Returns:
- a description suitable for displaying in the file chooser
-
getFormatExtensions
public String[] getFormatExtensions()
Returns the extension(s) of the format.- Specified by:
getFormatExtensionsin interfaceadams.core.io.FileFormatHandler- Specified by:
getFormatExtensionsin classadams.data.io.input.AbstractDataContainerReader<Spectrum>- Returns:
- the extension (without the dot!)
-
readDataFromFile
protected void readDataFromFile(org.apache.commons.compress.archivers.zip.ZipFile archive, org.apache.commons.compress.archivers.zip.ZipArchiveEntry entry, Set<String> ignored)Performs the actual reading using readers that do not support streaming.- Parameters:
archive- the archive to read fromentry- the entry to readignored- the sample IDs to ignore
-
readDataFromStream
protected void readDataFromStream(org.apache.commons.compress.archivers.zip.ZipFile archive, org.apache.commons.compress.archivers.zip.ZipArchiveEntry entry, Set<String> ignored)Performs the actual reading using readers that do not support streaming.- Parameters:
archive- the archive to read fromentry- the entry to readignored- the sample IDs to ignore
-
readData
protected void readData()
Performs the actual reading.- Specified by:
readDatain classadams.data.io.input.AbstractDataContainerReader<Spectrum>
-
main
public static void main(String[] args)
Runs the reader from the command-line. If the optionAbstractSpectrumReader.OPTION_OUTPUTDIRis specified then the read spectra get output as .spec files in that directory.- Parameters:
args- the command-line options to use
-
-