changed da.compareTo (da) == 0 to da.matches(da)

This commit is contained in:
Denis Molony
2016-07-19 11:24:36 +10:00
parent a5f57d54e3
commit edaa7954c7
14 changed files with 21 additions and 18 deletions

View File

@@ -107,7 +107,7 @@ public class DirectoryEntry implements AppleFileSource
public boolean contains (DiskAddress da) public boolean contains (DiskAddress da)
{ {
for (DiskAddress sector : blocks) for (DiskAddress sector : blocks)
if (sector.compareTo (da) == 0) if (sector.matches (da))
return true; return true;
return false; return false;
} }

View File

@@ -94,7 +94,7 @@ public class DefaultAppleFileSource implements AppleFileSource
public boolean contains (DiskAddress diskAddress) public boolean contains (DiskAddress diskAddress)
{ {
for (DiskAddress da : blocks) for (DiskAddress da : blocks)
if (da.compareTo (diskAddress) == 0) if (da.matches (diskAddress))
return true; return true;
return false; return false;
} }

View File

@@ -18,7 +18,7 @@ public interface FormattedDisk
public List<DiskAddress> getFileSectors (int fileNo); public List<DiskAddress> getFileSectors (int fileNo);
// Methods implemented by AbstractFormattedDisk // Methods implemented by AbstractFormattedDisk
public JTree getCatalogTree (); // each node is an AppleFileSource public JTree getCatalogTree (); // each node is an AppleFileSource
public List<AppleFileSource> getCatalogList (); public List<AppleFileSource> getCatalogList ();

View File

@@ -40,9 +40,10 @@ public class SectorList extends AbstractFile
String owner = formattedDisk.getSectorFilename (da); String owner = formattedDisk.getSectorFilename (da);
if (owner == null) if (owner == null)
owner = ""; owner = "";
text.append (String.format (" %04X %-18s %s%n", da.getBlock (), sectorType.name, owner)); text.append (String.format (" %04X %-18s %s%n", da.getBlock (), sectorType.name,
owner));
} }
return text.toString (); return text.toString ();
} }
} }

View File

@@ -260,11 +260,11 @@ abstract class AbstractCatalogEntry implements AppleFileSource
public boolean contains (DiskAddress da) public boolean contains (DiskAddress da)
{ {
for (DiskAddress sector : tsSectors) for (DiskAddress sector : tsSectors)
if (sector.compareTo (da) == 0) if (sector.matches (da))
return true; return true;
for (DiskAddress sector : dataSectors) for (DiskAddress sector : dataSectors)
// random access files may have gaps, and thus null sectors // random access files may have gaps, and thus null sectors
if (sector != null && sector.compareTo (da) == 0) if (sector != null && sector.matches (da))
return true; return true;
return false; return false;
} }

View File

@@ -83,7 +83,7 @@ class CatalogEntry extends AbstractCatalogEntry
break; break;
} }
if (thisDA.compareTo (da) == 0) if (thisDA.matches (da))
{ {
System.out.printf ("Next T/S list in sector %s points to itself%n", thisDA); System.out.printf ("Next T/S list in sector %s points to itself%n", thisDA);
break; break;

View File

@@ -15,7 +15,7 @@ import com.bytezone.common.State;
public class DiskBrowser extends JFrame implements DiskSelectionListener, QuitListener public class DiskBrowser extends JFrame implements DiskSelectionListener, QuitListener
{ {
private static final String windowTitle = "Apple ][ Disk Browser"; private static final String windowTitle = "Apple ][ Disk Browser";
private static final String PREFS_FULL_SCREEN = "full screen"; // private static final String PREFS_FULL_SCREEN = "full screen";
private final Preferences prefs = Preferences.userNodeForPackage (this.getClass ()); private final Preferences prefs = Preferences.userNodeForPackage (this.getClass ());
private WindowSaver windowSaver; private WindowSaver windowSaver;
@@ -36,7 +36,8 @@ public class DiskBrowser extends JFrame implements DiskSelectionListener, QuitLi
setLayout (new BorderLayout ()); setLayout (new BorderLayout ());
add (toolBar, BorderLayout.NORTH); add (toolBar, BorderLayout.NORTH);
RedoHandler redoHandler = new RedoHandler (getRootPane (), toolBar); // add nav buttons // add navigation buttons
RedoHandler redoHandler = new RedoHandler (getRootPane (), toolBar);
toolBar.addSeparator (); toolBar.addSeparator ();
// create and add the left-hand catalog panel // create and add the left-hand catalog panel

View File

@@ -36,6 +36,7 @@ class DiskDetails
@Override @Override
public String toString () public String toString ()
{ {
return String.format ("%s (%s)", file.getAbsolutePath (), duplicate ? "duplicate" : "OK"); return String.format ("%s (%s)", file.getAbsolutePath (),
duplicate ? "duplicate" : "OK");
} }
} }

View File

@@ -36,7 +36,7 @@ class DiskLayoutSelection implements Iterable<DiskAddress>
* If the click was on an existing highlight, just remove it (regardless of modifiers) * If the click was on an existing highlight, just remove it (regardless of modifiers)
*/ */
for (DiskAddress setDA : highlights) for (DiskAddress setDA : highlights)
if (da.compareTo (setDA) == 0) if (da.matches (setDA))
{ {
highlights.remove (setDA); highlights.remove (setDA);
return; return;

View File

@@ -20,7 +20,7 @@ public class InfocomDisk extends AbstractFormattedDisk
private static final boolean TYPE_NODE = true; private static final boolean TYPE_NODE = true;
private static final boolean TYPE_LEAF = false; private static final boolean TYPE_LEAF = false;
private byte[] data; private byte[] data;
private int version; // private int version;
private final Header header; private final Header header;
Color green = new Color (0, 200, 0); Color green = new Color (0, 200, 0);

View File

@@ -41,7 +41,7 @@ abstract class CatalogEntry implements AppleFileSource
public boolean contains (DiskAddress da) public boolean contains (DiskAddress da)
{ {
for (DiskAddress sector : blocks) for (DiskAddress sector : blocks)
if (sector.compareTo (da) == 0) if (sector.matches (da))
return true; return true;
return false; return false;
} }

View File

@@ -52,7 +52,7 @@ class PascalCodeObject implements AppleFileSource
public boolean contains (DiskAddress da) public boolean contains (DiskAddress da)
{ {
for (DiskAddress sector : blocks) for (DiskAddress sector : blocks)
if (sector.compareTo (da) == 0) if (sector.matches (da))
return true; return true;
return false; return false;
} }

View File

@@ -53,7 +53,7 @@ abstract class CatalogEntry implements AppleFileSource
public boolean contains (DiskAddress da) public boolean contains (DiskAddress da)
{ {
for (DiskAddress sector : dataBlocks) for (DiskAddress sector : dataBlocks)
if (sector.compareTo (da) == 0) if (sector.matches (da))
return true; return true;
return false; return false;
} }

View File

@@ -542,10 +542,10 @@ class FileEntry extends CatalogEntry implements ProdosConstants
if (da.equals (masterIndexBlock)) if (da.equals (masterIndexBlock))
return true; return true;
for (DiskAddress block : indexBlocks) for (DiskAddress block : indexBlocks)
if (block.compareTo (da) == 0) if (block.matches (da))
return true; return true;
for (DiskAddress block : dataBlocks) for (DiskAddress block : dataBlocks)
if (block.compareTo (da) == 0) if (block.matches (da))
return true; return true;
return false; return false;
} }