/* * AppleCommander - An Apple ][ image utility. * Copyright (C) 2002 by Robert Greene * robgreene at users.sourceforge.net * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package com.webcodepro.applecommander.storage; import java.io.IOException; import java.io.InputStream; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; import com.webcodepro.applecommander.storage.physical.ImageOrder; import com.webcodepro.applecommander.util.TextBundle; /** * Abstract representation of a formatted Apple2 disk (floppy, 800k, hard disk). *
* Date created: Oct 5, 2002 3:51:44 PM
* @author Rob Greene
*/
public abstract class FormattedDisk extends Disk implements DirectoryEntry {
private TextBundle textBundle = StorageBundle.getInstance();
/**
* Use this inner class for label/value mappings in the disk info page.
*/
public class DiskInformation {
private String label;
private String value;
public DiskInformation(String label, String value) {
this.label = label;
this.value = value;
}
public DiskInformation(String label, int value) {
this.label = label;
this.value = Integer.toString(value);
}
public DiskInformation(String label, Date value) {
SimpleDateFormat dateFormat = new SimpleDateFormat(
StorageBundle.getInstance().get("DateFormat")); //$NON-NLS-1$
this.label = label;
if (value != null) {
this.value = dateFormat.format(value);
} else {
this.value = StorageBundle.getInstance()
.get("FormattedDisk.NullDate"); //$NON-NLS-1$
}
}
public String getLabel() {
return this.label;
}
public String getValue() {
return this.value;
}
}
/**
* Use this inner interface for managing the disk usage data.
* This offloads format-specific implementation to the implementing class.
* The usage is very similar to a Java2 Iterator - next must be called to
* set the value and isFree/isUsed are available for that location.
*/
public interface DiskUsage {
public boolean hasNext();
public void next();
public boolean isFree();
public boolean isUsed();
}
/**
* This inner class represents the column header information used
* in the directory display. Note that this needs to be synchronized
* with the appropriate FileEntry objects.
*/
public static final int FILE_DISPLAY_STANDARD = 1;
public static final int FILE_DISPLAY_NATIVE = 2;
public static final int FILE_DISPLAY_DETAIL = 3;
public class FileColumnHeader {
public static final int ALIGN_LEFT = 1;
public static final int ALIGN_CENTER = 2;
public static final int ALIGN_RIGHT = 3;
private String title;
private int maximumWidth;
private int alignment;
public FileColumnHeader(String title, int maximumWidth, int alignment) {
this.title = title;
this.maximumWidth = maximumWidth;
this.alignment = alignment;
}
public String getTitle() {
return title;
}
public int getMaximumWidth() {
return maximumWidth;
}
public int getAlignment() {
return alignment;
}
public boolean isLeftAlign() {
return alignment == ALIGN_LEFT;
}
public boolean isCenterAlign() {
return alignment == ALIGN_CENTER;
}
public boolean isRightAlign() {
return alignment == ALIGN_RIGHT;
}
}
/**
* Constructor for FormattedDisk.
*/
public FormattedDisk(String filename, ImageOrder imageOrder) {
super(filename, imageOrder);
}
/**
* Return the name of the disk. Not the physical file name,
* but "DISK VOLUME #xxx" (DOS 3.3) or "/MY.DISK" (ProDOS).
*/
public abstract String getDiskName();
/**
* Set the name of the disk to volumeName.
*/
public void setDiskName(String volumeName) {
}
/**
* Identify the operating system format of this disk.
*/
public abstract String getFormat();
/**
* Return the amount of free space in bytes.
*/
public abstract int getFreeSpace();
/**
* Return the amount of used space in bytes.
*/
public abstract int getUsedSpace();
/**
* Get suggested dimensions for display of bitmap.
* Typically, this will be only used for 5.25" floppies.
* This can return null if there is no suggestion.
*/
public abstract int[] getBitmapDimensions();
/**
* Get the length of the bitmap.
*/
public abstract int getBitmapLength();
/**
* Get the disk usage iterator.
*/
public abstract DiskUsage getDiskUsage();
/**
* Get the labels to use in the bitmap.
* Note that this should, at a minimum, return an array of
* String[1] unless the bitmap has not been implemented.
*/
public abstract String[] getBitmapLabels();
/**
* Get disk information. This is intended to be pretty generic -
* each disk format can build this as appropriate. Each subclass should
* override this method and add its own detail.
*/
public List