org.datanucleus.metadata.xml
Class MetaDataParser

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by org.datanucleus.metadata.xml.MetaDataParser
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

public class MetaDataParser
extends org.xml.sax.helpers.DefaultHandler

Class to provide the parsing framework for parsing metadata files. This will support parsing of any metadata files where the resultant object is derived from org.datanucleus.metadata.MetaData, so can be used on JDO files, ORM files, JDOQUERY files, JPA files, or "persistence.xml" files. Can be used for any future metadata files too.

Provides 3 different entry points depending on whether the caller has a URL, a file, or an InputStream.


Field Summary
protected static Localiser LOCALISER
          Localiser for messages
protected  MetaDataManager mgr
          MetaData manager.
protected  boolean validate
          Whether to validate while parsing.
 
Constructor Summary
MetaDataParser(MetaDataManager mgr, boolean validate)
          Constructor.
 
Method Summary
 MetaData parseMetaDataFile(java.lang.String fileName, java.lang.String handlerName)
          Method to parse a MetaData file given the filename.
 MetaData parseMetaDataStream(java.io.InputStream in, java.lang.String filename, java.lang.String handlerName)
          Method to parse a MetaData file given an InputStream.
 MetaData parseMetaDataURL(java.net.URL url, java.lang.String handlerName)
          Method to parse a MetaData file given the URL of the file.
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
characters, endDocument, endElement, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startElement, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCALISER

protected static Localiser LOCALISER
Localiser for messages


mgr

protected final MetaDataManager mgr
MetaData manager.


validate

protected final boolean validate
Whether to validate while parsing.

Constructor Detail

MetaDataParser

public MetaDataParser(MetaDataManager mgr,
                      boolean validate)
Constructor.

Parameters:
mgr - MetaDataManager
validate - Whether to validate while parsing
Method Detail

parseMetaDataURL

public MetaData parseMetaDataURL(java.net.URL url,
                                 java.lang.String handlerName)
Method to parse a MetaData file given the URL of the file.

Parameters:
url - Url of the metadata file
handlerName - Name of the handler plugin to use when parsing
Returns:
The MetaData for this file
Throws:
NucleusException - thrown if error occurred

parseMetaDataFile

public MetaData parseMetaDataFile(java.lang.String fileName,
                                  java.lang.String handlerName)
Method to parse a MetaData file given the filename.

Parameters:
fileName - Name of the file
handlerName - Name of the handler plugin to use when parsing
Returns:
The MetaData for this file
Throws:
NucleusException - if error occurred

parseMetaDataStream

public MetaData parseMetaDataStream(java.io.InputStream in,
                                    java.lang.String filename,
                                    java.lang.String handlerName)
Method to parse a MetaData file given an InputStream.

Parameters:
in - input stream
filename - Name of the file (if applicable)
handlerName - Name of the handler plugin to use when parsing
Returns:
The MetaData for this file
Throws:
NucleusException - thrown if error occurred


Copyright © 2009. All Rights Reserved.