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 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

      Constructor Description
    • 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​( 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​( url)
        Set the URL for the resource file to be parsed.
        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.
        handler - a handler for a specific resource type
      • parse

        public void parse()
        Parse the Resource file.