storage
Class UnitsStorageManager

java.lang.Object
  extended bystorage.UnitsStorageManager

public final class UnitsStorageManager
extends java.lang.Object

This class provides methods for using units. That methods are shortcuts of the underlying methods in the advanced storage component.


Constructor Summary
UnitsStorageManager(AdvancedStorageManager asm)
          Constructs a units storage manager from an advanced storage manager.
 
Method Summary
 void addUnit(int segmentNumber, int spaceNumber, long unitNumber)
          Adds a unit with specifified segment, space and unit numbers, i.e. occups that unit.
 void addUnit(int segmentNumber, UnitAddress unitAddress)
          Adds a unit with specifified segment and unit address, i.e. occups that unit.
 void dropUnit(int segmentNumber, int spaceNumber, long unitNumber)
          Drops a specific unit, i.e. frees the specified unit.
 void dropUnit(int segmentNumber, UnitAddress unitAddress)
          Drops a specific unit, i.e. frees the specified unit.
 UnitAddress findFreeUnit(int segmentNumber)
          Finds the first free unit in the segment.
 boolean findFreeUnit(int segmentNumber, UnitAddress freeUnit)
          Finds the first free unit in the segment.
 UnitAddress findFreeUnitAsCloserAsPosibleOf(int segmentNumber, int spaceNumber, long unitNumber)
          Tries to find a free unit, first in the same page, second in the same space and finally in the same segment of a specified unit.
 boolean findFreeUnitAsCloserAsPosibleOf(int segmentNumber, int spaceNumber, long unitNumber, UnitAddress freeUnit)
          Tries to find a free unit, first in the same page, second in the same space and finally in the same segment of a specified unit.
 UnitAddress findFreeUnitAsCloserAsPosibleOf(int segmentNumber, UnitAddress unitAddress)
          Tries to find a free unit, first in the same page, second in the same space and finally in the same segment of a specified unit.
 boolean findFreeUnitAsCloserAsPosibleOf(int segmentNumber, UnitAddress unitAddress, UnitAddress freeUnit)
          Tries to find a free unit, first in the same page, second in the same space and finally in the same segment of a specified unit.
 AdvancedStorageManager getAdvancedStorageManager()
          Returns the underlying advanced storage manager.
 IntermediateStorageManager getIntermediateStorageManager()
          Returns the underlying intermediate storage manager.
 PrimitiveStorageManager getPrimitiveStorageManager()
          Returns the underlying primitive storage manager.
 boolean isFreeUnit(int segmentNumber, int spaceNumber, long unitNumber)
          Checks if a unit is free.
 boolean isFreeUnit(int segmentNumber, UnitAddress unitAddress)
          Checks if a unit is free.
 boolean isOccupiedUnit(int segmentNumber, int spaceNumber, long unitNumber)
          Checks if a unit is occupied.
 boolean isOccupiedUnit(int segmentNumber, UnitAddress unitAddress)
          Checks if a unit is occupied.
 void readUnit(int segmentNumber, int spaceNumber, long unitNumber, byte[] b, int off)
          Reads fully a unit.
 void readUnit(int segmentNumber, int spaceNumber, long unitNumber, int unitOffset, int length, byte[] b, int off)
          Reads partially a unit starting from an offset and reading a specific length.
 void readUnit(int segmentNumber, UnitAddress unitAddress, byte[] b, int off)
          Reads fully a unit.
 void readUnit(int segmentNumber, UnitAddress unitAddress, int unitOffset, int length, byte[] b, int off)
          Reads partially a unit starting from an offset and reading a specific length.
 void writeUnit(int segmentNumber, int spaceNumber, long unitNumber, byte[] b, int off)
          Writes fully a unit.
 void writeUnit(int segmentNumber, int spaceNumber, long unitNumber, int unitOffset, int length, byte[] b, int off)
          Writes partially a unit starting from an offset and writing a specific length of bytes.
 void writeUnit(int segmentNumber, UnitAddress unitAddress, byte[] b, int off)
          Writes fully a unit.
 void writeUnit(int segmentNumber, UnitAddress unitAddress, int unitOffset, int length, byte[] b, int off)
          Writes partially a unit starting from an offset and writing a specific length of bytes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UnitsStorageManager

public UnitsStorageManager(AdvancedStorageManager asm)
Constructs a units storage manager from an advanced storage manager.

Method Detail

findFreeUnit

public UnitAddress findFreeUnit(int segmentNumber)
                         throws StorageException,
                                java.io.IOException
Finds the first free unit in the segment.

Parameters:
segmentNumber - The number of the segment.
Returns:
A UnitAddress objec represents the unit found, null if a free unit is not found.
Throws:
StorageException
java.io.IOException

findFreeUnit

public boolean findFreeUnit(int segmentNumber,
                            UnitAddress freeUnit)
                     throws StorageException,
                            java.io.IOException
Finds the first free unit in the segment.

Parameters:
segmentNumber - The number of the segment.
freeUnit - Where the address of the free unit will be stored.
Returns:
true if the free unit is found, false otherwise.
Throws:
StorageException
java.io.IOException

findFreeUnitAsCloserAsPosibleOf

public UnitAddress findFreeUnitAsCloserAsPosibleOf(int segmentNumber,
                                                   int spaceNumber,
                                                   long unitNumber)
                                            throws StorageException,
                                                   java.io.IOException
Tries to find a free unit, first in the same page, second in the same space and finally in the same segment of a specified unit.

Parameters:
segmentNumber - The number of the segment of the close unit.
spaceNumber - The number of the space of the close unit.
unitNumber - The unit number of the close unit.
Returns:
A UnitAddress objec represents the unit found, null if a free unit is not found.
Throws:
StorageException
java.io.IOException

findFreeUnitAsCloserAsPosibleOf

public UnitAddress findFreeUnitAsCloserAsPosibleOf(int segmentNumber,
                                                   UnitAddress unitAddress)
                                            throws StorageException,
                                                   java.io.IOException
Tries to find a free unit, first in the same page, second in the same space and finally in the same segment of a specified unit.

Parameters:
segmentNumber - The number of the segment of the close unit.
unitAddress - unit address of the close unit.
Returns:
A UnitAddress objec represents the unit found, null if a free unit is not found.
Throws:
StorageException
java.io.IOException

findFreeUnitAsCloserAsPosibleOf

public boolean findFreeUnitAsCloserAsPosibleOf(int segmentNumber,
                                               int spaceNumber,
                                               long unitNumber,
                                               UnitAddress freeUnit)
                                        throws StorageException,
                                               java.io.IOException
Tries to find a free unit, first in the same page, second in the same space and finally in the same segment of a specified unit.

Parameters:
segmentNumber - The number of the segment of the close unit.
spaceNumber - The number of the space of the close unit.
unitNumber - The unit number of the close unit.
freeUnit - Where the address of the new unit will be stored.
Returns:
true if the unit is found, false otherwise.
Throws:
StorageException
java.io.IOException

findFreeUnitAsCloserAsPosibleOf

public boolean findFreeUnitAsCloserAsPosibleOf(int segmentNumber,
                                               UnitAddress unitAddress,
                                               UnitAddress freeUnit)
                                        throws StorageException,
                                               java.io.IOException
Tries to find a free unit, first in the same page, second in the same space and finally in the same segment of a specified unit.

Parameters:
segmentNumber - The number of the segment of the close unit.
unitAddress - unit address of the close unit.
freeUnit - Where the address of the new unit will be stored.
Returns:
true if the unit is found, false otherwise.
Throws:
StorageException
java.io.IOException

addUnit

public void addUnit(int segmentNumber,
                    int spaceNumber,
                    long unitNumber)
             throws StorageException,
                    java.io.IOException
Adds a unit with specifified segment, space and unit numbers, i.e. occups that unit.

Parameters:
segmentNumber - The number of the segment of the specified unit.
spaceNumber - The number of the space of the specified unit.
unitNumber - The unit number of the specified unit.
Throws:
StorageException
java.io.IOException

addUnit

public void addUnit(int segmentNumber,
                    UnitAddress unitAddress)
             throws StorageException,
                    java.io.IOException
Adds a unit with specifified segment and unit address, i.e. occups that unit.

Parameters:
segmentNumber - The number of the segment of the specified unit.
unitAddress - unit address of the specified unit.
Throws:
StorageException
java.io.IOException

dropUnit

public void dropUnit(int segmentNumber,
                     int spaceNumber,
                     long unitNumber)
              throws StorageException,
                     java.io.IOException
Drops a specific unit, i.e. frees the specified unit.

Parameters:
segmentNumber - The number of the segment.
spaceNumber - The number of the space.
unitNumber - The number of the unit. .
Throws:
StorageException
java.io.IOException

dropUnit

public void dropUnit(int segmentNumber,
                     UnitAddress unitAddress)
              throws StorageException,
                     java.io.IOException
Drops a specific unit, i.e. frees the specified unit.

Parameters:
segmentNumber - The number of the segment.
unitAddress - unit address of the specified unit.
Throws:
StorageException
java.io.IOException

readUnit

public void readUnit(int segmentNumber,
                     int spaceNumber,
                     long unitNumber,
                     byte[] b,
                     int off)
              throws StorageException,
                     java.io.IOException
Reads fully a unit. This method does not consider anything about the free status of the unit.

Parameters:
segmentNumber - The number of the segment.
spaceNumber - The number of the space.
unitNumber - The number of the unit. .
b - The byte array which the content of the readed unit will be stored.
off - The offset of b from which the readed content will be stored.
Throws:
StorageException
java.io.IOException

readUnit

public void readUnit(int segmentNumber,
                     UnitAddress unitAddress,
                     byte[] b,
                     int off)
              throws StorageException,
                     java.io.IOException
Reads fully a unit. This method does not consider anything about the free status of the unit.

Parameters:
segmentNumber - The number of the segment.
unitAddress - The address of the unit. .
b - The byte array which the content of the readed unit will be stored.
off - The offset of b from which the readed content will be stored.
Throws:
StorageException
java.io.IOException

readUnit

public void readUnit(int segmentNumber,
                     int spaceNumber,
                     long unitNumber,
                     int unitOffset,
                     int length,
                     byte[] b,
                     int off)
              throws StorageException,
                     java.io.IOException
Reads partially a unit starting from an offset and reading a specific length. This method does not consider anything about the free status of the unit.

Parameters:
segmentNumber - The number of the segment.
spaceNumber - The number of the space.
unitNumber - The number of the unit. .
unitOffset - The position of the unit from which the reading starts.
length - The number of bytes to be readed.
b - The byte array which the content of the readed unit will be stored.
off - The offset of b from which the readed content will be stored.
Throws:
StorageException
java.io.IOException

readUnit

public void readUnit(int segmentNumber,
                     UnitAddress unitAddress,
                     int unitOffset,
                     int length,
                     byte[] b,
                     int off)
              throws StorageException,
                     java.io.IOException
Reads partially a unit starting from an offset and reading a specific length. This method does not consider anything about the free status of the unit.

Parameters:
segmentNumber - The number of the segment.
unitAddress - The address of the unit. .
unitOffset - The position of the unit from which the reading starts.
length - The number of bytes to be readed.
b - The byte array which the content of the readed unit will be stored.
off - The offset of b from which the readed content will be stored.
Throws:
StorageException
java.io.IOException

writeUnit

public void writeUnit(int segmentNumber,
                      int spaceNumber,
                      long unitNumber,
                      byte[] b,
                      int off)
               throws StorageException,
                      java.io.IOException
Writes fully a unit. This method does not consider anything about the free status of the unit.

Parameters:
segmentNumber - The number of the segment.
spaceNumber - The number of the space.
unitNumber - The number of the unit.
b - The byte array from which the units's content will be get.
off - The offset of b from which the unit's content will be get.
Throws:
StorageException
java.io.IOException

writeUnit

public void writeUnit(int segmentNumber,
                      UnitAddress unitAddress,
                      byte[] b,
                      int off)
               throws StorageException,
                      java.io.IOException
Writes fully a unit. This method does not consider anything about the free status of the unit.

Parameters:
segmentNumber - The number of the segment.
unitAddress - The address of the unit.
b - The byte array from which the units's content will be get.
off - The offset of b from which the unit's content will be get.
Throws:
StorageException
java.io.IOException

writeUnit

public void writeUnit(int segmentNumber,
                      int spaceNumber,
                      long unitNumber,
                      int unitOffset,
                      int length,
                      byte[] b,
                      int off)
               throws StorageException,
                      java.io.IOException
Writes partially a unit starting from an offset and writing a specific length of bytes. This method does not consider anything about the free status of the unit.

Parameters:
segmentNumber - The number of the segment.
spaceNumber - The number of the space.
unitNumber - The number of the unit.
unitOffset - The position of the unit from which the writing starts.
length - The number of bytes to be wrote.
b - The byte array from which the units's content will be get.
off - The offset of b from which the unit's content will be get.
Throws:
StorageException
java.io.IOException

writeUnit

public void writeUnit(int segmentNumber,
                      UnitAddress unitAddress,
                      int unitOffset,
                      int length,
                      byte[] b,
                      int off)
               throws StorageException,
                      java.io.IOException
Writes partially a unit starting from an offset and writing a specific length of bytes. This method does not consider anything about the free status of the unit.

Parameters:
segmentNumber - The number of the segment.
unitAddress - The address of the unit.
unitOffset - The position of the unit from which the writing starts.
length - The number of bytes to be wrote.
b - The byte array from which the units's content will be get.
off - The offset of b from which the unit's content will be get.
Throws:
StorageException
java.io.IOException

isFreeUnit

public boolean isFreeUnit(int segmentNumber,
                          int spaceNumber,
                          long unitNumber)
                   throws StorageException,
                          java.io.IOException
Checks if a unit is free.

Parameters:
segmentNumber - The number of the segment.
spaceNumber - The number of the space.
unitNumber - The number of the unit.
Returns:
true if the specified unit is free, false otherwise.
Throws:
StorageException
java.io.IOException

isFreeUnit

public boolean isFreeUnit(int segmentNumber,
                          UnitAddress unitAddress)
                   throws StorageException,
                          java.io.IOException
Checks if a unit is free.

Parameters:
segmentNumber - The number of the segment.
unitAddress - The address of the unit.
Returns:
true if the specified unit is free, false otherwise.
Throws:
StorageException
java.io.IOException

isOccupiedUnit

public boolean isOccupiedUnit(int segmentNumber,
                              int spaceNumber,
                              long unitNumber)
                       throws StorageException,
                              java.io.IOException
Checks if a unit is occupied.

Parameters:
segmentNumber - The number of the segment.
spaceNumber - The number of the space.
unitNumber - The number of the unit.
Returns:
true if the specified unit is occupied, false otherwise.
Throws:
StorageException
java.io.IOException

isOccupiedUnit

public boolean isOccupiedUnit(int segmentNumber,
                              UnitAddress unitAddress)
                       throws StorageException,
                              java.io.IOException
Checks if a unit is occupied.

Parameters:
segmentNumber - The number of the segment.
unitAddress - The address of the unit.
Returns:
true if the specified unit is occupied, false otherwise.
Throws:
StorageException
java.io.IOException

getPrimitiveStorageManager

public PrimitiveStorageManager getPrimitiveStorageManager()
Returns the underlying primitive storage manager.


getIntermediateStorageManager

public IntermediateStorageManager getIntermediateStorageManager()
Returns the underlying intermediate storage manager.


getAdvancedStorageManager

public AdvancedStorageManager getAdvancedStorageManager()
Returns the underlying advanced storage manager.