Class ResourceParser


  • public class ResourceParser
    extends java.lang.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 Summary

      Constructors 
      Constructor Description
      ResourceParser()
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addHandler​(ResourceParser.ResourceHandler handler)
      Adds a resource handler to the parser.
      void parse()
      Parse the Resource file.
      void setURL​(java.net.URL url)
      Set the URL for the resource file to be parsed.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ResourceParser

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

      • setURL

        public void setURL​(java.net.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 java.io.IOException
        Parse the Resource file.
        Throws:
        java.io.IOException