Class LinkedDataReader
java.lang.Object
cool.scx.io.data_reader.LinkedDataReader
- All Implemented Interfaces:
DataReader
- Direct Known Subclasses:
PowerfulLinkedDataReader
LinkedDataReader
- Version:
- 0.0.1
- Author:
- scx567888
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidappendData(DataNode data) booleanvoidlongindexOf(byte[] pattern, long maxLength) 查找 指定字节数组 第一次出现的 index (指针不会移动)longindexOf(byte b, long maxLength) 查找 指定字节 第一次出现的 index (指针不会移动)longindexOf(DataIndexer indexer, long max) bytepeek()向 dataConsumer 写入指定长度字节 (指针不会移动) 当没有更多的数据时会抛出异常byte[]peek(int maxLength) 读取指定长度字节 (指针不会移动) 当没有更多的数据时会抛出异常voidpeek(DataConsumer dataConsumer, long maxLength) 向 outputStream 写入指定长度字节 (指针不会移动) 当没有更多的数据时会抛出异常booleanpullData()byteread()读取单个字节 (指针会移动) 当没有更多的数据时会抛出异常byte[]read(int maxLength) 读取字节 (指针会移动) 当没有更多的数据时会抛出异常voidread(DataConsumer dataConsumer, long maxLength) 向 dataConsumer 写入指定长度字节 (指针会移动) 当没有更多的数据时会抛出异常voidskip(long length) 向后移动指定字节voidwalk(DataConsumer consumer, long maxLength, boolean movePointer)
-
Field Details
-
dataSupplier
-
head
-
tail
-
-
Constructor Details
-
LinkedDataReader
-
LinkedDataReader
public LinkedDataReader()
-
-
Method Details
-
appendData
-
pullData
public boolean pullData() -
ensureAvailable
public boolean ensureAvailable() -
ensureAvailableOrThrow
- Throws:
NoMoreDataException
-
walk
-
indexOf
- Throws:
NoMatchFoundException
-
read
Description copied from interface:DataReader读取单个字节 (指针会移动) 当没有更多的数据时会抛出异常- Specified by:
readin interfaceDataReader- Returns:
- byte
- Throws:
NoMoreDataException- 没有更多数据时抛出
-
read
Description copied from interface:DataReader读取字节 (指针会移动) 当没有更多的数据时会抛出异常- Specified by:
readin interfaceDataReader- Parameters:
maxLength- 最大长度- Returns:
- bytes
- Throws:
NoMoreDataException- 没有更多数据时抛出
-
read
Description copied from interface:DataReader向 dataConsumer 写入指定长度字节 (指针会移动) 当没有更多的数据时会抛出异常- Specified by:
readin interfaceDataReader- Parameters:
maxLength- 最大长度- Throws:
NoMoreDataException- 没有更多数据时抛出
-
peek
Description copied from interface:DataReader向 dataConsumer 写入指定长度字节 (指针不会移动) 当没有更多的数据时会抛出异常- Specified by:
peekin interfaceDataReader- Returns:
- byte
- Throws:
NoMoreDataException- 没有更多数据时抛出
-
peek
Description copied from interface:DataReader读取指定长度字节 (指针不会移动) 当没有更多的数据时会抛出异常- Specified by:
peekin interfaceDataReader- Parameters:
maxLength- 最大长度- Returns:
- byte
- Throws:
NoMoreDataException- 没有更多数据时抛出
-
peek
Description copied from interface:DataReader向 outputStream 写入指定长度字节 (指针不会移动) 当没有更多的数据时会抛出异常- Specified by:
peekin interfaceDataReader- Parameters:
maxLength- 最大长度- Throws:
NoMoreDataException- 没有更多数据时抛出
-
indexOf
Description copied from interface:DataReader查找 指定字节 第一次出现的 index (指针不会移动)- Specified by:
indexOfin interfaceDataReader- Parameters:
b- 指定字节maxLength- 最大长度- Returns:
- index 或者 -1 (未找到)
- Throws:
NoMatchFoundException- 没有匹配时抛出NoMoreDataException
-
indexOf
public long indexOf(byte[] pattern, long maxLength) throws NoMatchFoundException, NoMoreDataException Description copied from interface:DataReader查找 指定字节数组 第一次出现的 index (指针不会移动)- Specified by:
indexOfin interfaceDataReader- Parameters:
pattern- 指定字节数组maxLength- 最大长度- Returns:
- index 或者 -1 (未找到)
- Throws:
NoMatchFoundException- 没有匹配时抛出NoMoreDataException
-
skip
Description copied from interface:DataReader向后移动指定字节- Specified by:
skipin interfaceDataReader- Parameters:
length- 移动长度- Throws:
NoMoreDataException
-