Interface FreeSlotsHandler
- All Known Implementing Classes:
FreeSlotsDynamicLength,FreeSlotsFixedLength
public interface FreeSlotsHandler
Manages free slots of file pieces
- Author:
- angele
-
Method Summary
Modifier and TypeMethodDescriptionintallocate(int length) allocate a new address and get index of itvoidallocate(int index, int length) search for a new address for indexintappend(int len) append a slot of length len at end of filevoidclear()clear all used slotsvoidcopy(FreeSlotsHandler freeSlots) copy all pages and free slots from freeSlots to thisvoidfree(int index) free address at indexvoidfree(long index) free addresslonggetAddress(int index) get the file address of slot indexbooleanisValid()is it valid?voidload()load slot table from filevoidsave()save slot table to filevoidsetFile(RandomAccessToFile file) set basic filevoidsetValid(boolean b) set valid flagintsize()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
-