de.waldheinz.fs.fat
Class SuperFloppyFormatter

java.lang.Object
  extended by de.waldheinz.fs.fat.SuperFloppyFormatter

public final class SuperFloppyFormatter
extends Object

Allows to create FAT file systems on BlockDevices which follow the "super floppy" standard. This means that the device will be formatted so that it does not contain a partition table. Instead, the entire device holds a single FAT file system.

This class follows the "builder" pattern, which means it's methods always returns the SuperFloppyFormatter instance they're called on. This allows to chain the method calls like this:

  BlockDevice dev = new RamDisk(16700000);
  FatFileSystem fs = SuperFloppyFormatter.get(dev).
          setFatType(FatType.FAT12).format();
 

Author:
Matthias Treydte <matthias.treydte at meetwise.com>

Field Summary
static int DEFAULT_FAT_COUNT
          The default number of FATs.
static int DEFAULT_HEADS
          The default number of heads.
static String DEFAULT_OEM_NAME
          The default OEM name for file systems created by this class.
static int DEFAULT_SECTORS_PER_TRACK
          The default number of sectors per track.
static int DEFULT_HEADS
          Deprecated. the name of this constant was mistyped
static int MEDIUM_DESCRIPTOR_HD
          The media descriptor used (hard disk).
 
Method Summary
 FatFileSystem format()
          Initializes the boot sector and file system for the device.
static SuperFloppyFormatter get(BlockDevice dev)
          Retruns a SuperFloppyFormatter instance suitable for formatting the specified device.
 FatType getFatType()
          Returns the exact type of FAT the will be created by this formatter.
 String getOemName()
          Returns the OEM name that will be written to the BootSector.
 String getVolumeLabel()
          Returns the volume label that will be given to the new file system.
 SuperFloppyFormatter setFatType(FatType fatType)
          Sets the type of FAT that will be created by this SuperFloppyFormatter.
 SuperFloppyFormatter setOemName(String oemName)
          Sets the OEM name of the boot sector.
 SuperFloppyFormatter setVolumeLabel(String label)
          Sets the volume label of the file system to create.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MEDIUM_DESCRIPTOR_HD

public static final int MEDIUM_DESCRIPTOR_HD
The media descriptor used (hard disk).

See Also:
Constant Field Values

DEFAULT_FAT_COUNT

public static final int DEFAULT_FAT_COUNT
The default number of FATs.

See Also:
Constant Field Values

DEFAULT_SECTORS_PER_TRACK

public static final int DEFAULT_SECTORS_PER_TRACK
The default number of sectors per track.

See Also:
Constant Field Values

DEFAULT_HEADS

public static final int DEFAULT_HEADS
The default number of heads.

Since:
0.6
See Also:
Constant Field Values

DEFULT_HEADS

@Deprecated
public static final int DEFULT_HEADS
Deprecated. the name of this constant was mistyped
The default number of heads.

See Also:
DEFAULT_HEADS, Constant Field Values

DEFAULT_OEM_NAME

public static final String DEFAULT_OEM_NAME
The default OEM name for file systems created by this class.

See Also:
Constant Field Values
Method Detail

get

public static SuperFloppyFormatter get(BlockDevice dev)
                                throws IOException
Retruns a SuperFloppyFormatter instance suitable for formatting the specified device.

Parameters:
dev - the device that should be formatted
Returns:
the formatter for the device
Throws:
IOException - on error creating the formatter

getOemName

public String getOemName()
Returns the OEM name that will be written to the BootSector.

Returns:
the OEM name of the new file system

setOemName

public SuperFloppyFormatter setOemName(String oemName)
Sets the OEM name of the boot sector. TODO: throw an exception early if name is invalid (too long, ...)

Parameters:
oemName - the new OEM name
Returns:
this SuperFloppyFormatter
See Also:
BootSector.setOemName(java.lang.String)

setVolumeLabel

public SuperFloppyFormatter setVolumeLabel(String label)
Sets the volume label of the file system to create. TODO: throw an exception early if label is invalid (too long, ...)

Parameters:
label - the new file system label, may be null
Returns:
this SuperFloppyFormatter
See Also:
FatFileSystem.setVolumeLabel(java.lang.String)

getVolumeLabel

public String getVolumeLabel()
Returns the volume label that will be given to the new file system.

Returns:
the file system label, may be null
See Also:
FatFileSystem.getVolumeLabel()

format

public FatFileSystem format()
                     throws IOException
Initializes the boot sector and file system for the device. The file system created by this method will always be in read-write mode.

Returns:
the file system that was created
Throws:
IOException - on write error

getFatType

public FatType getFatType()
Returns the exact type of FAT the will be created by this formatter.

Returns:
the FAT type

setFatType

public SuperFloppyFormatter setFatType(FatType fatType)
                                throws IOException,
                                       IllegalArgumentException
Sets the type of FAT that will be created by this SuperFloppyFormatter.

Parameters:
fatType - the desired FatType
Returns:
this SuperFloppyFormatter
Throws:
IOException - on error setting the fatType
IllegalArgumentException - if fatType does not support the size of the device


Copyright © 2014. All rights reserved.