ResourceManager
Class ResourceModel

java.lang.Object
  |
  +--java.util.Observable
        |
        +--ResourceManager.ResourceModel

public class ResourceModel
extends java.util.Observable

ResourceModel: A Data Model (as in MVC Model) for managing the Resources stored in the Resource Fork of a Macintosh File. After reading, the raw byte data of the loaded Resources can be accessed and interpreted as a client sees fit.


Constructor Summary
ResourceModel()
          Sets up a new ResourceModel
ResourceModel(java.lang.String inName)
          Sets up a new ResourceModel to load from the given filename
 
Method Summary
 void become(ResourceModel become_this)
          A sort of copy constructor; allows an existing ResourceModel to take over the data of another rather than instantiating a new one.
 boolean contains(java.lang.String inType)
          A method to check whether any Resources of the given Type exist
 boolean contains(java.lang.String inType, short idtocheck)
          A convenience method allowing a test with a primitive short key in addition to the Short Object method
 boolean contains(java.lang.String inType, java.lang.Short idtocheck)
          A method to check whether a Resource of the given Type and ID exists
 int getCountOfType(java.lang.String inType)
          Returns the number of Resources of the given type
 java.lang.String getFilename()
          Returns the name of the Mac Resource Fork file being managed
 Resource getResource(java.lang.String inType, short idtoget)
          A convenience method allowing access with a primitive short key in addition to the Short Object method
 Resource getResource(java.lang.String inType, java.lang.Short idtoget)
          Returns the single Resource keyed to the given numeric Resource ID of the ResourceType keyed to the given 4-Letter Type ID.
 ResourceType getResourceType(java.lang.String inType)
          Returns the single ResourceType keyed to the given ID.
 java.lang.String[] getTypeArray()
          Returns a String array of all the Types of the Model
 java.util.Enumeration getTypes()
          Returns an Enumeration of all the Type keys of the Model to enable iterative Hashtable access to all the ResourceType of this Model
 void init()
          Prepares the ResourceModel for loading.
 void init(java.lang.String inName)
          Prepares the ResourceModel for loading and sets the name of the file being loaded.
 void print(java.io.PrintStream ps)
          Dumps the ResourceModel information (not including data) to a Stream
 void printAll(java.io.PrintStream ps)
          Dumps the ResourceModel information (not including data) to a Stream as well as the info of all the Types it holds
 void read(java.io.RandomAccessFile inraf)
          Initiates a full read, parse and store of the Mac Resource Fork specified by the given RandomAccessFile.
 void read(java.io.RandomAccessFile inraf, long seekSet)
          Initiates a full read, parse and store of the Mac Resource Fork specified by the given RandomAccessFile.
 void setFilename(java.lang.String inName)
          Sets the name of the Mac Resource Fork file being managed
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceModel

public ResourceModel()
Sets up a new ResourceModel

ResourceModel

public ResourceModel(java.lang.String inName)
Sets up a new ResourceModel to load from the given filename
Parameters:
inName - the new name of the file
Method Detail

init

public void init()
Prepares the ResourceModel for loading. Can be used to reset the model for reloading as well

init

public void init(java.lang.String inName)
Prepares the ResourceModel for loading and sets the name of the file being loaded. Can be used to reset the model for reloading as well
Parameters:
inName - the new name of the file

become

public void become(ResourceModel become_this)
A sort of copy constructor; allows an existing ResourceModel to take over the data of another rather than instantiating a new one. Necessary for some cases where a reference to particular instance needs to be maintatined in various parts of a program.
Parameters:
become_this - the ResourceModel whose data we will assume.

setFilename

public void setFilename(java.lang.String inName)
Sets the name of the Mac Resource Fork file being managed
Parameters:
inName - the new name of the file

getFilename

public java.lang.String getFilename()
Returns the name of the Mac Resource Fork file being managed

read

public void read(java.io.RandomAccessFile inraf)
          throws java.io.IOException
Initiates a full read, parse and store of the Mac Resource Fork specified by the given RandomAccessFile. It reads ALL types and resources in the file into memory, eliminating the need for further file access.
Parameters:
inraf - the RandomAccessFile Object specifying the Resource Fork to be loaded

read

public void read(java.io.RandomAccessFile inraf,
                 long seekSet)
          throws java.io.IOException
Initiates a full read, parse and store of the Mac Resource Fork specified by the given RandomAccessFile. It reads ALL types and resources in the file into memory, eliminating the need for further file access.
Parameters:
inraf - the RandomAccessFile Object specifying the Resource Fork to be loaded
seekSet - the file position of the beginning of the Resource Fork

print

public void print(java.io.PrintStream ps)
Dumps the ResourceModel information (not including data) to a Stream
Parameters:
ps - the PrintStream to print the info

printAll

public void printAll(java.io.PrintStream ps)
Dumps the ResourceModel information (not including data) to a Stream as well as the info of all the Types it holds
Parameters:
ps - the PrintStream to print the info

getTypes

public java.util.Enumeration getTypes()
Returns an Enumeration of all the Type keys of the Model to enable iterative Hashtable access to all the ResourceType of this Model

getTypeArray

public java.lang.String[] getTypeArray()
Returns a String array of all the Types of the Model

getResourceType

public ResourceType getResourceType(java.lang.String inType)
Returns the single ResourceType keyed to the given ID. This is Hashtable style access.
Parameters:
inType - the 4-Letter ID Key of the desired ResourceType

getResource

public Resource getResource(java.lang.String inType,
                            java.lang.Short idtoget)
Returns the single Resource keyed to the given numeric Resource ID of the ResourceType keyed to the given 4-Letter Type ID. This is Hashtable style access - at two levels. This method allows the client to grab a single Resource in one operation
Parameters:
inType - the 4-Letter ID Key of the desired ResourceType
idtoget - the numeric ID Key of the desired Resource

getResource

public Resource getResource(java.lang.String inType,
                            short idtoget)
A convenience method allowing access with a primitive short key in addition to the Short Object method
Parameters:
inType - the 4-Letter ID Key of the desired ResourceType
idtoget - the numeric ID Key of the desired Resource

contains

public boolean contains(java.lang.String inType)
A method to check whether any Resources of the given Type exist
Parameters:
inType - the 4-Letter ID Key of the desired ResourceType

contains

public boolean contains(java.lang.String inType,
                        java.lang.Short idtocheck)
A method to check whether a Resource of the given Type and ID exists
Parameters:
inType - the 4-Letter ID Key of the desired ResourceType
idtocheck - the numeric ID Key of the desired Resource

contains

public boolean contains(java.lang.String inType,
                        short idtocheck)
A convenience method allowing a test with a primitive short key in addition to the Short Object method
Parameters:
inType - the 4-Letter ID Key of the desired ResourceType
idtocheck - the numeric ID Key of the desired Resource

getCountOfType

public int getCountOfType(java.lang.String inType)
Returns the number of Resources of the given type
Parameters:
inType - the 4-Letter ID Key of the desired ResourceType