Package adams.data.io.input
Class LineByLineTextReader
-
- All Implemented Interfaces:
Destroyable
,GlobalInfoSupporter
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,QuickInfoSupporter
,SizeOfHandler
,Serializable
public class LineByLineTextReader extends AbstractTextReaderWithEncoding<String>
Reads the text data, line by line. Allows the reading of very large files.
-logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel) The logging level for outputting errors and debugging output. default: WARNING
-encoding <adams.core.base.BaseCharset> (property: encoding) The type of encoding to use when reading the file, use empty string for default. default: Default
-max-lines <int> (property: maxLines) The maximum number of lines to read; using -1 will read all. default: -1 minimum: -1
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected int
m_LineCount
lines read so far.protected int
m_MaxLines
the maximum number of lines to read.protected Scanner
m_Scanner
the scanner in use.-
Fields inherited from class adams.data.io.input.AbstractTextReaderWithEncoding
m_Encoding
-
Fields inherited from class adams.data.io.input.AbstractTextReader
m_Stream
-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description LineByLineTextReader()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
defineOptions()
Adds options to the internal list of options.protected String
doNext()
Returns the next lot of data.Class
generates()
Returns the class of the data that it returns.int
getMaxLines()
Returns the maximum lines to read.String
getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.String
globalInfo()
Returns a string describing the object.void
initialize(InputStream stream)
Initializes the input stream to read the content from.String
maxLinesTipText()
Returns the tip text for this property.void
reset()
Resets the scheme.void
setMaxLines(int value)
Sets the maximum lines to read.-
Methods inherited from class adams.data.io.input.AbstractTextReaderWithEncoding
encodingTipText, getEncoding, setEncoding
-
Methods inherited from class adams.data.io.input.AbstractTextReader
hasNext, next
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, initialize, loggingLevelTipText, newOptionManager, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
-
-
-
Field Detail
-
m_MaxLines
protected int m_MaxLines
the maximum number of lines to read.
-
m_LineCount
protected int m_LineCount
lines read so far.
-
m_Scanner
protected transient Scanner m_Scanner
the scanner in use.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfo
in interfaceGlobalInfoSupporter
- Specified by:
globalInfo
in classAbstractOptionHandler
- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptions
in interfaceOptionHandler
- Overrides:
defineOptions
in classAbstractTextReaderWithEncoding<String>
-
reset
public void reset()
Resets the scheme.- Overrides:
reset
in classAbstractTextReader<String>
-
setMaxLines
public void setMaxLines(int value)
Sets the maximum lines to read.- Parameters:
value
- the maximum, < 1 denotes infinity
-
getMaxLines
public int getMaxLines()
Returns the maximum lines to read.- Returns:
- the maximum, < 1 denotes infinity
-
maxLinesTipText
public String maxLinesTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the gui
-
generates
public Class generates()
Returns the class of the data that it returns.- Specified by:
generates
in classAbstractTextReader<String>
- Returns:
- the generated data type
-
getQuickInfo
public String getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.- Specified by:
getQuickInfo
in interfaceQuickInfoSupporter
- Overrides:
getQuickInfo
in classAbstractTextReaderWithEncoding<String>
- Returns:
- null if no info available, otherwise short string
-
initialize
public void initialize(InputStream stream)
Initializes the input stream to read the content from.- Overrides:
initialize
in classAbstractTextReader<String>
- Parameters:
stream
- the input stream to use
-
doNext
protected String doNext()
Returns the next lot of data.- Specified by:
doNext
in classAbstractTextReader<String>
- Returns:
- the next amount of data, null if failed to read
-
-