de.waldheinz.fs.fat
Class FatLfnDirectoryEntry

java.lang.Object
  extended by de.waldheinz.fs.AbstractFsObject
      extended by de.waldheinz.fs.fat.FatLfnDirectoryEntry
All Implemented Interfaces:
FsDirectoryEntry, FsObject

public final class FatLfnDirectoryEntry
extends AbstractFsObject
implements FsDirectoryEntry

Represents an entry in a FatLfnDirectory. Besides implementing the FsDirectoryEntry interface for FAT file systems, it allows access to the archive, hidden, read-only and system flags specifed for the FAT file system.

Since:
0.6
Author:
Matthias Treydte <waldheinz at gmail.com>

Field Summary
 
Fields inherited from interface de.waldheinz.fs.FsDirectoryEntry
DIRECTORY_ENTRY_COMPARATOR
 
Method Summary
 long getCreated()
          Returns the time when this entry was created as ms since 1970.
 FatLfnDirectory getDirectory()
          Gets the directory this entry refers to.
 FatFile getFile()
          Gets the file this entry refers to.
 long getLastAccessed()
          Returns the time when this entry was last accessed as ms since 1970.
 long getLastModified()
          Gets the last modification time of this entry.
 String getName()
          Gets the name of this entry.
 FsDirectory getParent()
          Gets the directory this entry is a part of.
 boolean isArchiveFlag()
          Returns if this directory entry has the FAT "archive" flag set.
 boolean isDirectory()
          Is this entry refering to a (sub-)directory?
 boolean isDirty()
          Indicate if the entry has been modified in memory (ie need to be saved)
 boolean isFile()
          Is this entry refering to a file?
 boolean isHiddenFlag()
          Returns if this directory entry has the FAT "hidden" flag set.
 boolean isReadOnlyFlag()
          Returns if this directory entry has the FAT "read-only" flag set.
 boolean isSystemFlag()
          Returns if this directory entry has the FAT "system" flag set.
 void moveTo(FatLfnDirectory target, String newName)
          Moves this entry to a new directory under the specified name.
 void setArchiveFlag(boolean archive)
          Sets the "archive" flag on this FatLfnDirectoryEntry to the specified value.
 void setHiddenFlag(boolean hidden)
          Sets the "hidden" flag on this FatLfnDirectoryEntry to the specified value.
 void setLastModified(long lastModified)
          Sets the last modification time of this entry.
 void setName(String newName)
          Sets the name of this entry.
 void setReadOnlyFlag(boolean readOnly)
          Sets the "read only" flag on this FatLfnDirectoryEntry to the specified value.
 void setSystemFlag(boolean systemEntry)
          Sets the "system" flag on this FatLfnDirectoryEntry to the specified value.
 String toString()
           
 
Methods inherited from class de.waldheinz.fs.AbstractFsObject
checkValid, checkWritable, invalidate, isReadOnly, isValid
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface de.waldheinz.fs.FsObject
isReadOnly, isValid
 

Method Detail

isHiddenFlag

public boolean isHiddenFlag()
Returns if this directory entry has the FAT "hidden" flag set.

Returns:
if this is a hidden directory entry
See Also:
setHiddenFlag(boolean)

setHiddenFlag

public void setHiddenFlag(boolean hidden)
                   throws ReadOnlyException
Sets the "hidden" flag on this FatLfnDirectoryEntry to the specified value.

Parameters:
hidden - if this entry should have the hidden flag set
Throws:
ReadOnlyException - if this entry is read-only
See Also:
isHiddenFlag()

isSystemFlag

public boolean isSystemFlag()
Returns if this directory entry has the FAT "system" flag set.

Returns:
if this is a "system" directory entry
See Also:
setSystemFlag(boolean)

setSystemFlag

public void setSystemFlag(boolean systemEntry)
                   throws ReadOnlyException
Sets the "system" flag on this FatLfnDirectoryEntry to the specified value.

Parameters:
systemEntry - if this entry should have the system flag set
Throws:
ReadOnlyException - if this entry is read-only
See Also:
isSystemFlag()

isReadOnlyFlag

public boolean isReadOnlyFlag()
Returns if this directory entry has the FAT "read-only" flag set. This entry may still modified if AbstractFsObject.isReadOnly() returns true.

Returns:
if this entry has the read-only flag set
See Also:
setReadOnlyFlag(boolean)

setReadOnlyFlag

public void setReadOnlyFlag(boolean readOnly)
                     throws ReadOnlyException
Sets the "read only" flag on this FatLfnDirectoryEntry to the specified value. This method only modifies the read-only flag as specified by the FAT file system, which is essentially ignored by the fat32-lib. The true indicator if it is possible to alter this

Parameters:
readOnly - if this entry should be flagged as read only
Throws:
ReadOnlyException - if this entry is read-only as given by AbstractFsObject.isReadOnly() method
See Also:
isReadOnlyFlag()

isArchiveFlag

public boolean isArchiveFlag()
Returns if this directory entry has the FAT "archive" flag set.

Returns:
if this entry has the archive flag set

setArchiveFlag

public void setArchiveFlag(boolean archive)
                    throws ReadOnlyException
Sets the "archive" flag on this FatLfnDirectoryEntry to the specified value.

Parameters:
archive - if this entry should have the archive flag set
Throws:
ReadOnlyException - if this entry is read-only

getName

public String getName()
Description copied from interface: FsDirectoryEntry
Gets the name of this entry.

Specified by:
getName in interface FsDirectoryEntry
Returns:
this entrys name

getParent

public FsDirectory getParent()
Description copied from interface: FsDirectoryEntry
Gets the directory this entry is a part of.

Specified by:
getParent in interface FsDirectoryEntry
Returns:
the parent directory of this entry, or null

setName

public void setName(String newName)
             throws IOException
Description copied from interface: FsDirectoryEntry
Sets the name of this entry.

Specified by:
setName in interface FsDirectoryEntry
Parameters:
newName - the new name of this entry
Throws:
IOException - on error setting the new name

moveTo

public void moveTo(FatLfnDirectory target,
                   String newName)
            throws IOException,
                   ReadOnlyException
Moves this entry to a new directory under the specified name.

Parameters:
target - the direcrory where this entry should be moved to
newName - the new name under which this entry will be accessible in the target directory
Throws:
IOException - on error moving this entry
ReadOnlyException - if this directory is read-only

setLastModified

public void setLastModified(long lastModified)
Description copied from interface: FsDirectoryEntry
Sets the last modification time of this entry.

Specified by:
setLastModified in interface FsDirectoryEntry
Parameters:
lastModified - the new last modification time of this entry

getFile

public FatFile getFile()
                throws IOException
Description copied from interface: FsDirectoryEntry
Gets the file this entry refers to. This method can only be called if isFile returns true.

Specified by:
getFile in interface FsDirectoryEntry
Returns:
the file described by this entry
Throws:
IOException - on error accessing the file

getDirectory

public FatLfnDirectory getDirectory()
                             throws IOException
Description copied from interface: FsDirectoryEntry
Gets the directory this entry refers to. This method can only be called if isDirectory returns true.

Specified by:
getDirectory in interface FsDirectoryEntry
Returns:
The directory described by this entry
Throws:
IOException - on read error

toString

public String toString()
Overrides:
toString in class Object

getLastModified

public long getLastModified()
                     throws IOException
Description copied from interface: FsDirectoryEntry
Gets the last modification time of this entry.

Specified by:
getLastModified in interface FsDirectoryEntry
Returns:
the last modification time of the entry as milliseconds since 1970, or 0 if this filesystem does not support getting the last modification time
Throws:
IOException - if an error occurs retrieving the time stamp

getCreated

public long getCreated()
                throws IOException
Description copied from interface: FsDirectoryEntry
Returns the time when this entry was created as ms since 1970.

Specified by:
getCreated in interface FsDirectoryEntry
Returns:
the creation time, or 0 if this feature is not supported
Throws:
IOException - on error retrieving the time stamp

getLastAccessed

public long getLastAccessed()
                     throws IOException
Description copied from interface: FsDirectoryEntry
Returns the time when this entry was last accessed as ms since 1970.

Specified by:
getLastAccessed in interface FsDirectoryEntry
Returns:
the last access time, or 0 if this feature is not supported
Throws:
IOException - on error retrieving the last access time

isFile

public boolean isFile()
Description copied from interface: FsDirectoryEntry
Is this entry refering to a file?

Specified by:
isFile in interface FsDirectoryEntry
Returns:
if this entry refers to a file

isDirectory

public boolean isDirectory()
Description copied from interface: FsDirectoryEntry
Is this entry refering to a (sub-)directory?

Specified by:
isDirectory in interface FsDirectoryEntry
Returns:
if this entry refers to a directory

isDirty

public boolean isDirty()
Description copied from interface: FsDirectoryEntry
Indicate if the entry has been modified in memory (ie need to be saved)

Specified by:
isDirty in interface FsDirectoryEntry
Returns:
true if the entry needs to be saved


Copyright © 2014. All rights reserved.