All Packages Class Hierarchy This Package Previous Next Index
Interface org.jos.fs.Medium
- public interface Medium
Interface specification for low-level access to a storage medium (hard disk,
floppy disk etc.)
Attention: A Medium is not a drive. If a disk is ejected out of a disk drive
and another one is inserted, this second disk has to be modeled by a new
Medium instance!
All implementations of this interface must be thread-safe!
Changes 3-2-98: changed references to EjectionVetoException into VetoException
- Version:
- JOS-FileSystem 4 Preview (25-Mar-98)
- Author:
- Stefan Reich
-
READONLY
- Flag: Medium is read-only
-
REMOUNTABLE
- Flag: Medium is remountable without user interaction (jukebox)
"Remount" can also mean "reestablish a connection", e.g.
-
REMOVABLE
- Flag: Medium is removable
-
REMOVABLE_WITHOUT_NOTIFICATION
- Flag: Medium can be removed without notification of listeners (e.g., because
the drive hardware doesn't report removals)
-
addMediumListener(MediumListener)
- add a listener
-
eject()
- ejects medium if ejectable.
eject() should perform the following steps:
- fire a mediumWillEject() event to all listeners
- if a listener throws a EjectionVetoException, rethrow it
and cancel operation
- fire a mediumEjects() event to all listeners
- do the physical ejection
- isRemoved has to return
true
from now on
-
flush()
- flushes all buffers if neccessary
-
getFlags()
- returns the flags (a constant value - not allowed to change during
the instance's lifetime)
-
getSize()
- returns total size (in Bytes)
-
isRemoved()
- is medium ejected?
-
readBytes(long, byte[], int, int)
- reads bytes from medium
-
remount()
- remounts the device.
If it doesn't throw an IOException, it was successful and the medium
is accessible again.
Attention: The medium contents may have changed.
-
removeMediumListener(MediumListener)
- remove a listener
-
writeBytes(long, byte[], int, int)
- writes bytes to medium
READONLY
public static final int READONLY
- Flag: Medium is read-only
REMOVABLE
public static final int REMOVABLE
- Flag: Medium is removable
REMOVABLE_WITHOUT_NOTIFICATION
public static final int REMOVABLE_WITHOUT_NOTIFICATION
- Flag: Medium can be removed without notification of listeners (e.g., because
the drive hardware doesn't report removals)
REMOUNTABLE
public static final int REMOUNTABLE
- Flag: Medium is remountable without user interaction (jukebox)
"Remount" can also mean "reestablish a connection", e.g. a FTP connection
that broke down because of a timeout.
getFlags
public abstract int getFlags()
- returns the flags (a constant value - not allowed to change during
the instance's lifetime)
getSize
public abstract long getSize()
- returns total size (in Bytes)
readBytes
public abstract void readBytes(long ofs,
byte[] buf,
int bOfs,
int count) throws IOException, MediumRemovedException, IllegalArgumentException
- reads bytes from medium
writeBytes
public abstract void writeBytes(long ofs,
byte[] buf,
int bOfs,
int count) throws IOException, MediumRemovedException, IllegalArgumentException, UnsupportedFeatureException
- writes bytes to medium
flush
public abstract void flush() throws IOException
- flushes all buffers if neccessary
eject
public abstract void eject() throws MediumRemovedException, VetoException, IOException, UnsupportedFeatureException
- ejects medium if ejectable.
eject() should perform the following steps:
- fire a mediumWillEject() event to all listeners
- if a listener throws a EjectionVetoException, rethrow it
and cancel operation
- fire a mediumEjects() event to all listeners
- do the physical ejection
- isRemoved has to return
true
from now on
remount
public abstract void remount() throws IOException, UnsupportedFeatureException
- remounts the device.
If it doesn't throw an IOException, it was successful and the medium
is accessible again.
Attention: The medium contents may have changed.
(Size and flags don't change, however.)
isRemoved
public abstract boolean isRemoved()
- is medium ejected?
addMediumListener
public abstract void addMediumListener(MediumListener l)
- add a listener
removeMediumListener
public abstract void removeMediumListener(MediumListener l)
- remove a listener
All Packages Class Hierarchy This Package Previous Next Index