Class SegmentsRepository
- java.lang.Object
-
- org.exbin.auxiliary.paged_data.delta.SegmentsRepository
-
@ParametersAreNonnullByDefault public class SegmentsRepository extends java.lang.Object
Repository of delta segments.
-
-
Constructor Summary
Constructors Constructor Description SegmentsRepository()
SegmentsRepository(org.exbin.auxiliary.paged_data.DataPageProvider dataPageProvider)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
closeFileSource(FileDataSource fileSource)
void
closeMemorySource(MemoryDataSource memorySource)
DataSegment
copySegment(DataSegment segment)
Creates copy of segment.DataSegment
copySegment(DataSegment segment, long offset, long length)
Creates copy of segment.DeltaDocument
createDocument()
Creates empty delta document.DeltaDocument
createDocument(FileDataSource fileSource)
Creates delta document for given file source.FileSegment
createFileSegment(FileDataSource fileSource, long startPosition, long length)
Creates new file segment on given file source.MemorySegment
createMemorySegment()
MemorySegment
createMemorySegment(MemoryDataSource memorySource, long startPosition, long length)
Creates new memory segment on given memory source.void
detachFileSource(FileDataSource fileSource)
Loads all segments from given source file to memory.void
detachMemoryArea(MemorySegment memorySegment, long segmentPosition, long length)
Detaches all other memory segments crossing given area of provided memory segment.void
detachSegment(MemorySegment memorySegment)
void
dropDocument(DeltaDocument document)
void
dropFileSegment(FileSegment fileSegment)
void
dropMemorySegment(MemorySegment memorySegment)
void
dropSegment(DataSegment segment)
void
insertMemoryData(MemorySegment memorySegment, long segmentPosition, byte[] insertedData)
void
insertMemoryData(MemorySegment memorySegment, long segmentPosition, byte[] insertedData, int insertedDataOffset, int insertedDataLength)
void
insertMemoryData(MemorySegment memorySegment, long segmentPosition, long length)
void
insertMemoryData(MemorySegment memorySegment, long segmentPosition, org.exbin.auxiliary.paged_data.BinaryData insertedData)
void
insertMemoryData(MemorySegment memorySegment, long segmentPosition, org.exbin.auxiliary.paged_data.BinaryData insertedData, long insertedDataOffset, long insertedDataLength)
void
insertUninitializedMemoryData(MemorySegment memorySegment, long segmentPosition, long length)
FileDataSource
openFileSource(java.io.File sourceFile)
FileDataSource
openFileSource(java.io.File sourceFile, FileDataSource.EditMode editMode)
MemoryDataSource
openMemorySource()
void
saveDocument(DeltaDocument savedDocument)
Saves document to it's source file and update all documents.void
setMemoryByte(MemorySegment memorySegment, long segmentPosition, byte value)
Sets byte to given segment.void
updateSegment(DataSegment segment, long position, long length)
void
updateSegmentLength(DataSegment segment, long length)
-
-
-
Method Detail
-
openFileSource
@Nonnull public FileDataSource openFileSource(java.io.File sourceFile) throws java.io.IOException
- Throws:
java.io.IOException
-
openFileSource
@Nonnull public FileDataSource openFileSource(java.io.File sourceFile, FileDataSource.EditMode editMode) throws java.io.IOException
- Throws:
java.io.IOException
-
closeFileSource
public void closeFileSource(FileDataSource fileSource)
-
openMemorySource
@Nonnull public MemoryDataSource openMemorySource()
-
closeMemorySource
public void closeMemorySource(MemoryDataSource memorySource)
-
createDocument
@Nonnull public DeltaDocument createDocument()
Creates empty delta document.- Returns:
- delta document
-
createDocument
@Nonnull public DeltaDocument createDocument(FileDataSource fileSource) throws java.io.IOException
Creates delta document for given file source.- Parameters:
fileSource
- file source- Returns:
- delta document
- Throws:
java.io.IOException
- if input/output error
-
saveDocument
public void saveDocument(DeltaDocument savedDocument) throws java.io.IOException
Saves document to it's source file and update all documents.- Parameters:
savedDocument
- document to save- Throws:
java.io.IOException
- if input/output error
-
createFileSegment
@Nonnull public FileSegment createFileSegment(FileDataSource fileSource, long startPosition, long length)
Creates new file segment on given file source.- Parameters:
fileSource
- file sourcestartPosition
- start positionlength
- length- Returns:
- file segment
-
dropFileSegment
public void dropFileSegment(FileSegment fileSegment)
-
createMemorySegment
@Nonnull public MemorySegment createMemorySegment()
-
createMemorySegment
@Nonnull public MemorySegment createMemorySegment(MemoryDataSource memorySource, long startPosition, long length)
Creates new memory segment on given memory source.- Parameters:
memorySource
- memory sourcestartPosition
- start positionlength
- length- Returns:
- memory segment
-
updateSegment
@Nonnull public void updateSegment(DataSegment segment, long position, long length)
-
updateSegmentLength
public void updateSegmentLength(DataSegment segment, long length)
-
dropMemorySegment
public void dropMemorySegment(MemorySegment memorySegment)
-
dropSegment
public void dropSegment(DataSegment segment)
-
dropDocument
public void dropDocument(DeltaDocument document)
-
setMemoryByte
public void setMemoryByte(MemorySegment memorySegment, long segmentPosition, byte value)
Sets byte to given segment. Handles shared memory between multiple segments.- Parameters:
memorySegment
- memory segmentsegmentPosition
- relative position to segment startvalue
- value to set
-
insertMemoryData
public void insertMemoryData(MemorySegment memorySegment, long segmentPosition, org.exbin.auxiliary.paged_data.BinaryData insertedData)
-
insertMemoryData
public void insertMemoryData(MemorySegment memorySegment, long segmentPosition, org.exbin.auxiliary.paged_data.BinaryData insertedData, long insertedDataOffset, long insertedDataLength)
-
insertMemoryData
public void insertMemoryData(MemorySegment memorySegment, long segmentPosition, byte[] insertedData)
-
insertMemoryData
public void insertMemoryData(MemorySegment memorySegment, long segmentPosition, byte[] insertedData, int insertedDataOffset, int insertedDataLength)
-
insertMemoryData
public void insertMemoryData(MemorySegment memorySegment, long segmentPosition, long length)
-
insertUninitializedMemoryData
public void insertUninitializedMemoryData(MemorySegment memorySegment, long segmentPosition, long length)
-
detachMemoryArea
public void detachMemoryArea(MemorySegment memorySegment, long segmentPosition, long length)
Detaches all other memory segments crossing given area of provided memory segment.- Parameters:
memorySegment
- provided memory segmentsegmentPosition
- positionlength
- length
-
detachSegment
public void detachSegment(MemorySegment memorySegment)
-
copySegment
@Nonnull public DataSegment copySegment(DataSegment segment)
Creates copy of segment.- Parameters:
segment
- original segment- Returns:
- copy of segment
-
copySegment
@Nonnull public DataSegment copySegment(DataSegment segment, long offset, long length)
Creates copy of segment.- Parameters:
segment
- original segmentoffset
- segment area offsetlength
- segment area length- Returns:
- copy of segment
-
detachFileSource
public void detachFileSource(FileDataSource fileSource)
Loads all segments from given source file to memory.- Parameters:
fileSource
- file source
-
-