Interface FreeSlotsHandler
- All Known Implementing Classes:
FreeSlotsDynamicLength
,FreeSlotsFixedLength
public interface FreeSlotsHandler
Manages free slots of file pieces
- Author:
- angele
-
Method Summary
Modifier and TypeMethodDescriptionint
allocate
(int length) allocate a new address and get index of itvoid
allocate
(int index, int length) search for a new address for indexint
append
(int len) append a slot of length len at end of filevoid
clear()
clear all used slotsvoid
copy
(FreeSlotsHandler freeSlots) copy all pages and free slots from freeSlots to thisvoid
free
(int index) free address at indexvoid
free
(long index) free addresslong
getAddress
(int index) get the file address of slot indexboolean
isValid()
is it valid?void
load()
load slot table from filevoid
save()
save slot table to filevoid
setFile
(RandomAccessToFile file) set basic filevoid
setValid
(boolean b) set valid flagint
size()
number of slots
-
Method Details
-
setFile
set basic file- Parameters:
file
-
-
clear
void clear()clear all used slots -
load
load slot table from file- Throws:
IOException
-
save
save slot table to file- Throws:
IOException
-
allocate
search for a new address for index- Parameters:
length
- TODOindex
- , indexlength
- , length of file piece- Throws:
IOException
-
allocate
allocate a new address and get index of it- Parameters:
length
- TODOlength
- , length of file piece- Returns:
- slot index
- Throws:
IOException
-
free
free address at index- Parameters:
index
-- Throws:
IOException
-
free
free address- Parameters:
index
-- Throws:
IOException
-
getAddress
long getAddress(int index) get the file address of slot index- Parameters:
index
-- Returns:
-
append
append a slot of length len at end of file- Parameters:
len
- , length of slot- Returns:
- Throws:
IOException
-
size
int size()number of slots- Returns:
-
copy
copy all pages and free slots from freeSlots to this- Parameters:
freeSlots
-
-
setValid
set valid flag- Parameters:
b
-- Throws:
IOException
-
isValid
is it valid?- Returns:
- Throws:
IOException
-