Class ResourceParser

java.lang.Object
com.adobe.internal.mac.resource.ResourceParser

public class ResourceParser extends Object
A general framework for parsing Mac resource files. The location of the resource (data fork, resource fork, or other) doesn't matter as long the full location of the resource is given. This resource parser will read the basic structure of the resource (see http://developer.apple.com/documentation/mac/MoreToolbox/MoreToolbox-99.html for Apple's Resource File Format}) and will call back to handlers for each type of resource (e.g. 'FOND', 'sfnt', 'DITL', etc.) that are provided to the parser. Because Resource files are non-linear and the I/O interface is linear (a stream) the parsing is done in a two pass process. In the first pass the parser collects data about all of the individual resources in the Resource file. In the second pass the handlers for each resource type are called as the resources occur in the stream.
  • Constructor Details

    • ResourceParser

      public ResourceParser()
      Constructor. This parser can be reused to parse multiple Resource files.
  • Method Details

    • setURL

      public void setURL(URL url)
      Set the URL for the resource file to be parsed.
      Parameters:
      url - location of the resource data
    • addHandler

      public void addHandler(ResourceParser.ResourceHandler handler)
      Adds a resource handler to the parser. If a handler for that resource type has already been added then it is removed and the one being added replaces it.
      Parameters:
      handler - a handler for a specific resource type
    • parse

      public void parse() throws IOException
      Parse the Resource file.
      Throws:
      IOException