dmolony-DiskBrowser/src/com/bytezone/diskbrowser/infocom/InfocomAbstractFile.java

68 lines
2.0 KiB
Java
Raw Permalink Normal View History

2016-02-05 07:18:23 +00:00
package com.bytezone.diskbrowser.infocom;
import java.util.ArrayList;
import java.util.List;
import com.bytezone.diskbrowser.applefile.AbstractFile;
2016-02-24 21:11:14 +00:00
import com.bytezone.diskbrowser.utilities.HexFormatter;
2016-02-05 07:18:23 +00:00
2020-02-05 04:26:39 +00:00
// -----------------------------------------------------------------------------------//
2020-02-09 13:02:48 +00:00
class InfocomAbstractFile extends AbstractFile
2020-02-05 04:26:39 +00:00
// -----------------------------------------------------------------------------------//
2016-02-05 07:18:23 +00:00
{
2020-02-02 10:17:49 +00:00
protected List<HexBlock> hexBlocks = new ArrayList<> ();
2016-02-05 07:18:23 +00:00
2020-02-05 04:26:39 +00:00
// ---------------------------------------------------------------------------------//
2020-02-09 13:02:48 +00:00
InfocomAbstractFile (String name, byte[] buffer)
2020-02-05 04:26:39 +00:00
// ---------------------------------------------------------------------------------//
2016-02-05 07:18:23 +00:00
{
super (name, buffer);
}
2020-02-05 04:26:39 +00:00
// ---------------------------------------------------------------------------------//
2016-02-05 07:18:23 +00:00
@Override
public String getHexDump ()
2020-02-05 04:26:39 +00:00
// ---------------------------------------------------------------------------------//
2016-02-05 07:18:23 +00:00
{
if (hexBlocks.size () > 0)
{
StringBuilder text = new StringBuilder ();
for (HexBlock hb : hexBlocks)
{
if (hb.title != null)
text.append (hb.title + "\n\n");
text.append (HexFormatter.format (buffer, hb.ptr, hb.size) + "\n\n");
}
text.deleteCharAt (text.length () - 1);
text.deleteCharAt (text.length () - 1);
return text.toString ();
}
if (buffer == null || buffer.length == 0)
return "No buffer";
if (buffer.length <= 99999)
return HexFormatter.format (buffer, 0, buffer.length);
return HexFormatter.format (buffer, 0, 99999);
}
2020-02-05 04:26:39 +00:00
// ---------------------------------------------------------------------------------//
2016-02-05 07:18:23 +00:00
protected class HexBlock
2020-02-05 04:26:39 +00:00
// ---------------------------------------------------------------------------------//
2016-02-05 07:18:23 +00:00
{
public int ptr;
public int size;
public String title;
public HexBlock (int ptr, int size, String title)
{
this.ptr = ptr;
this.size = size;
this.title = title;
}
}
}