de.waldheinz.fs
Class AbstractFsObject

java.lang.Object
  extended by de.waldheinz.fs.AbstractFsObject
All Implemented Interfaces:
FsObject
Direct Known Subclasses:
FatFile, FatLfnDirectory, FatLfnDirectoryEntry

public class AbstractFsObject
extends Object
implements FsObject

A base class that helps to implement the FsObject interface.

Since:
0.6
Author:
Ewout Prangsma <epr at jnode.org>, Matthias Treydte <waldheinz at gmail.com>

Constructor Summary
protected AbstractFsObject(boolean readOnly)
          Creates a new instance of AbstractFsObject which will be valid and have the specified read-only state.
 
Method Summary
protected  void checkValid()
          Convience method to check if this object is still valid and throw an IllegalStateException if it is not.
protected  void checkWritable()
          Convience method to check if this object is writable.
protected  void invalidate()
          Marks this object as invalid.
 boolean isReadOnly()
          Checks if this FsObject is read-only.
 boolean isValid()
          Checks if this FsObject is still valid.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractFsObject

protected AbstractFsObject(boolean readOnly)
Creates a new instance of AbstractFsObject which will be valid and have the specified read-only state.

Parameters:
readOnly - if the new object will be read-only
Method Detail

isValid

public final boolean isValid()
Checks if this FsObject is still valid. An object is not valid anymore if it has been removed from the filesystem. All invocations on methods (except this method and the methods inherited from Object) of invalid objects must throw an IllegalStateException.

Specified by:
isValid in interface FsObject
Returns:
if this FsObject is still valid
See Also:
checkValid(), invalidate()

invalidate

protected final void invalidate()
Marks this object as invalid.

See Also:
isValid(), checkValid()

checkValid

protected final void checkValid()
                         throws IllegalStateException
Convience method to check if this object is still valid and throw an IllegalStateException if it is not.

Throws:
IllegalStateException - if this object was invalidated
Since:
0.6
See Also:
isValid(), invalidate()

checkWritable

protected final void checkWritable()
                            throws IllegalStateException,
                                   ReadOnlyException
Convience method to check if this object is writable. An object is writable if it is both, valid and not read-only.

Throws:
IllegalStateException - if this object was invalidated
ReadOnlyException - if this object was created with the read-only flag set
Since:
0.6

isReadOnly

public final boolean isReadOnly()
Description copied from interface: FsObject
Checks if this FsObject is read-only. Any attempt to modify a read-only FsObject must result in a ReadOnlyException being thrown, and the modification must not be performed.

Specified by:
isReadOnly in interface FsObject
Returns:
if this FsObject is read-only


Copyright © 2014. All rights reserved.