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

Variable Index

 o READONLY
Flag: Medium is read-only
 o REMOUNTABLE
Flag: Medium is remountable without user interaction (jukebox)

"Remount" can also mean "reestablish a connection", e.g.

 o REMOVABLE
Flag: Medium is removable
 o REMOVABLE_WITHOUT_NOTIFICATION
Flag: Medium can be removed without notification of listeners (e.g., because the drive hardware doesn't report removals)

Method Index

 o addMediumListener(MediumListener)
add a listener
 o eject()
ejects medium if ejectable.

eject() should perform the following steps:

 o flush()
flushes all buffers if neccessary
 o getFlags()
returns the flags (a constant value - not allowed to change during the instance's lifetime)
 o getSize()
returns total size (in Bytes)
 o isRemoved()
is medium ejected?
 o readBytes(long, byte[], int, int)
reads bytes from medium
 o 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.

 o removeMediumListener(MediumListener)
remove a listener
 o writeBytes(long, byte[], int, int)
writes bytes to medium

Variables

 o READONLY
public static final int READONLY
Flag: Medium is read-only

 o REMOVABLE
public static final int REMOVABLE
Flag: Medium is removable

 o 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)

 o 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.

Methods

 o getFlags
public abstract int getFlags()
returns the flags (a constant value - not allowed to change during the instance's lifetime)

 o getSize
public abstract long getSize()
returns total size (in Bytes)

 o readBytes
public abstract void readBytes(long ofs,
                               byte[] buf,
                               int bOfs,
                               int count) throws IOException, MediumRemovedException, IllegalArgumentException
reads bytes from medium

 o writeBytes
public abstract void writeBytes(long ofs,
                                byte[] buf,
                                int bOfs,
                                int count) throws IOException, MediumRemovedException, IllegalArgumentException, UnsupportedFeatureException
writes bytes to medium

 o flush
public abstract void flush() throws IOException
flushes all buffers if neccessary

 o eject
public abstract void eject() throws MediumRemovedException, VetoException, IOException, UnsupportedFeatureException
ejects medium if ejectable.

eject() should perform the following steps:

 o 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.)

 o isRemoved
public abstract boolean isRemoved()
is medium ejected?

 o addMediumListener
public abstract void addMediumListener(MediumListener l)
add a listener

 o removeMediumListener
public abstract void removeMediumListener(MediumListener l)
remove a listener


All Packages  Class Hierarchy  This Package  Previous  Next  Index