Class ChunkReader
- java.lang.Object
- 
- ghidra.framework.main.logviewer.model.ChunkReader
 
- 
 public class ChunkReader extends java.lang.ObjectThis class handles reading data from the input file, in the form ofChunkobjects. Each chunk is stored in theChunkModeland represents a single block of text that is displayed in theFVTable.
- 
- 
Constructor SummaryConstructors Constructor Description ChunkReader(java.io.File file, ChunkModel model)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description java.io.FilegetFile()Returns the file being read.longgetFileSize()Returns the number of bytes in the input file.longgetStartOfNextLine(long startByte)Returns the start of the next line after the given byte.java.util.List<byte[]>readBytes(long startByte, long endByte)Reads all bytes from the given byte to the end byte.java.util.List<java.lang.String>readLastChunk()Reads one chunk from the end of the file.java.util.List<java.lang.String>readNextChunk()Reads the next chunk in the file past the last one specified in theChunkModel.java.util.List<java.lang.String>readNextChunkFrom(long startByte)Reads a chunk of data from the given location in the file.java.util.List<java.lang.String>readPreviousChunk()Reads the chunk immediately before the first visible one.voidreload()
 
- 
- 
- 
Constructor Detail- 
ChunkReaderpublic ChunkReader(java.io.File file, ChunkModel model) throws java.io.IOException- Parameters:
- file-
- model-
- Throws:
- java.io.IOException
 
 
- 
 - 
Method Detail- 
getFileSizepublic long getFileSize() throws java.io.IOExceptionReturns the number of bytes in the input file.- Returns:
- number of bytes
- Throws:
- java.io.IOException
 
 - 
getFilepublic java.io.File getFile() Returns the file being read.- Returns:
 
 - 
reloadpublic void reload() throws java.io.IOException- Throws:
- java.io.IOException
 
 - 
readLastChunkpublic java.util.List<java.lang.String> readLastChunk() throws java.io.IOExceptionReads one chunk from the end of the file. This is useful when scrolling to the bottom of the viewport.- Returns:
- the last chunk, or an empty list
- Throws:
- java.io.IOException
 
 - 
readPreviousChunkpublic java.util.List<java.lang.String> readPreviousChunk() throws java.io.IOExceptionReads the chunk immediately before the first visible one.- Returns:
- the previous chunk, or an empty list
- Throws:
- java.io.IOException
 
 - 
readNextChunkFrompublic java.util.List<java.lang.String> readNextChunkFrom(long startByte) throws java.io.IOExceptionReads a chunk of data from the given location in the file. To ensure we're always reading full lines, take the given start position and move forward to the next full line before reading.- Parameters:
- startByte- the position to start reading from
- Returns:
- the lines of text read
- Throws:
- java.io.IOException
 
 - 
readBytespublic java.util.List<byte[]> readBytes(long startByte, long endByte) throws java.io.IOExceptionReads all bytes from the given byte to the end byte. If the amount of bytes to be read is greater than the size of an INT, we will have to read this in several chunks, hence the need to return a list of arrays, and not just a single byte array.- Parameters:
- startByte-
- endByte-
- Returns:
- a map of all the bytes read in (index 0 is first chunk, 1 is next, etc...).
- Throws:
- java.io.IOException
 
 - 
readNextChunkpublic java.util.List<java.lang.String> readNextChunk() throws java.io.FileNotFoundException, java.io.IOExceptionReads the next chunk in the file past the last one specified in theChunkModel.- Returns:
- the lines of text read
- Throws:
- java.io.FileNotFoundException
- java.io.IOException
 
 - 
getStartOfNextLinepublic long getStartOfNextLine(long startByte) throws java.io.IOExceptionReturns the start of the next line after the given byte. To do this, simply read backwards from the given point until a newline or carriage return is found.- Parameters:
- startByte-
- Returns:
- Throws:
- java.io.IOException
 
 
- 
 
-