Class ByteWindow
- java.lang.Object
-
- org.eclipse.jgit.internal.storage.file.ByteWindow
-
- Direct Known Subclasses:
ByteArrayWindow
,ByteBufferWindow
abstract class ByteWindow extends java.lang.Object
A window of data currently stored within a cache.All bytes in the window can be assumed to be "immediately available", that is they are very likely already in memory, unless the operating system's memory is very low and has paged part of this process out to disk. Therefore copying bytes from a window is very inexpensive.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ByteWindow(PackFile p, long s, int n)
Constructor for ByteWindow.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description (package private) boolean
contains(PackFile neededFile, long neededPos)
protected abstract int
copy(int pos, byte[] dstbuf, int dstoff, int cnt)
Copy bytes from the window to a caller supplied buffer.(package private) int
copy(long pos, byte[] dstbuf, int dstoff, int cnt)
Copy bytes from the window to a caller supplied buffer.protected abstract int
setInput(int pos, java.util.zip.Inflater inf)
Set the input(package private) int
setInput(long pos, java.util.zip.Inflater inf)
(package private) int
size()
(package private) abstract void
write(PackOutputStream out, long pos, int cnt)
-
-
-
Field Detail
-
pack
protected final PackFile pack
-
start
protected final long start
-
end
protected final long end
-
-
Method Detail
-
size
final int size()
-
contains
final boolean contains(PackFile neededFile, long neededPos)
-
copy
final int copy(long pos, byte[] dstbuf, int dstoff, int cnt)
Copy bytes from the window to a caller supplied buffer.- Parameters:
pos
- offset within the file to start copying from.dstbuf
- destination buffer to copy into.dstoff
- offset withindstbuf
to start copying into.cnt
- number of bytes to copy. This value may exceed the number of bytes remaining in the window starting at offsetpos
.- Returns:
- number of bytes actually copied; this may be less than
cnt
ifcnt
exceeded the number of bytes available.
-
copy
protected abstract int copy(int pos, byte[] dstbuf, int dstoff, int cnt)
Copy bytes from the window to a caller supplied buffer.- Parameters:
pos
- offset within the window to start copying from.dstbuf
- destination buffer to copy into.dstoff
- offset withindstbuf
to start copying into.cnt
- number of bytes to copy. This value may exceed the number of bytes remaining in the window starting at offsetpos
.- Returns:
- number of bytes actually copied; this may be less than
cnt
ifcnt
exceeded the number of bytes available.
-
write
abstract void write(PackOutputStream out, long pos, int cnt) throws java.io.IOException
- Throws:
java.io.IOException
-
setInput
final int setInput(long pos, java.util.zip.Inflater inf) throws java.util.zip.DataFormatException
- Throws:
java.util.zip.DataFormatException
-
setInput
protected abstract int setInput(int pos, java.util.zip.Inflater inf) throws java.util.zip.DataFormatException
Set the input- Parameters:
pos
- positioninf
- anInflater
object.- Returns:
- size of the byte window
- Throws:
java.util.zip.DataFormatException
- if any.
-
-