sun.module.repository
Class ModuleInfoXMLReader

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by sun.module.repository.ModuleInfoXMLReader
All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler

public class ModuleInfoXMLReader
extends DefaultHandler
implements ErrorHandler

Reads from data from a URL which conforms to the RepositoryMetadata.xml schema, providing a set of ModuleInfo instances for the current platform & arch.

Author:
Dave Bristor

Method Summary
 void characters(char[] ch, int start, int length)
           
 void endElement(String ns, String name, String qname)
           
 void error(SAXParseException ex)
           
 void fatalError(SAXParseException ex)
           
static Set<ModuleInfo> read(URL source, String platform, String arch)
          Returns information from given URL as a set of ModuleInfo instances.
 void setDocumentLocator(Locator locator)
           
 void startElement(String ns, String name, String qname, Attributes attrs)
           
 void warning(SAXParseException ex)
           
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

read

public static Set<ModuleInfo> read(URL source,
                                   String platform,
                                   String arch)
                            throws SAXException,
                                   IOException
Returns information from given URL as a set of ModuleInfo instances. Validates the data aginst the java/module/RepositoryMetadata.xml. The set will only have ModuleInfo elements that match the given platform and arch, or which do not specify those.

Parameters:
source - URL to a file which conforms to the RepositoryMetadata.xml schema.
platform - Name of the current platform; must not be null
arch - Name of the current architecture; must not benull.
Returns:
a Set<ModuleInfo>, with one ModuleInfo for each module entry in the repository-metadata.xml.
Throws:
NullPointerException - if any argument is null.
IllegalArgumentException - if the source has duplicate entries (note that the path element is not considered when checking for duplicates, though other elements are).
SAXException
IOException

error

public void error(SAXParseException ex)
           throws SAXException
Specified by:
error in interface ErrorHandler
Overrides:
error in class DefaultHandler
Throws:
SAXException

fatalError

public void fatalError(SAXParseException ex)
                throws SAXException
Specified by:
fatalError in interface ErrorHandler
Overrides:
fatalError in class DefaultHandler
Throws:
SAXException

warning

public void warning(SAXParseException ex)
             throws SAXException
Specified by:
warning in interface ErrorHandler
Overrides:
warning in class DefaultHandler
Throws:
SAXException

setDocumentLocator

public void setDocumentLocator(Locator locator)
Specified by:
setDocumentLocator in interface ContentHandler
Overrides:
setDocumentLocator in class DefaultHandler

startElement

public void startElement(String ns,
                         String name,
                         String qname,
                         Attributes attrs)
                  throws SAXException
Specified by:
startElement in interface ContentHandler
Overrides:
startElement in class DefaultHandler
Throws:
SAXException

endElement

public void endElement(String ns,
                       String name,
                       String qname)
                throws SAXException,
                       IllegalArgumentException
Specified by:
endElement in interface ContentHandler
Overrides:
endElement in class DefaultHandler
Throws:
SAXException
IllegalArgumentException

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws SAXException
Specified by:
characters in interface ContentHandler
Overrides:
characters in class DefaultHandler
Throws:
SAXException