org.figure8.join.core.persistence
Class HibernateXmlImportHandler

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by org.figure8.join.core.persistence.HibernateXmlImportHandler
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

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

This utility class is an Xml import handler for Hibernate entity objects. It is adapted from the one written by Ara Abrahamian and available on http://opensource.atlassian.com/projects/hibernate/browse/HB-493.

Version:
$Revision: 1.1 $
Author:
Laurent Broudoux

Constructor Summary
HibernateXmlImportHandler(net.sf.hibernate.SessionFactory factory)
          Creates a new instance of HibernateXmlImportHandler
 
Method Summary
 void characters(char[] iArr, int start, int length)
          Read content as characteers
 void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)
          End an Xml element handling method
protected  java.lang.String getContents()
           
 java.util.List getEntityObjects()
           
protected  net.sf.hibernate.persister.ClassPersister getPersister(java.lang.Class clazz)
           
 java.util.Collection loadEntityObjects(java.io.InputStream inputstream)
          Load the entity objects from their Xml representation read on stream
 void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attributes)
          Start an Xml element handling method
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HibernateXmlImportHandler

public HibernateXmlImportHandler(net.sf.hibernate.SessionFactory factory)
Creates a new instance of HibernateXmlImportHandler

Parameters:
factory - The SessionFactory to use for getting entities metadata
Method Detail

getEntityObjects

public java.util.List getEntityObjects()
Returns:
The loaded entity objects

loadEntityObjects

public java.util.Collection loadEntityObjects(java.io.InputStream inputstream)
                                       throws net.sf.hibernate.HibernateException
Load the entity objects from their Xml representation read on stream

Parameters:
inputstream - The stream for reading Xml representations
Throws:
net.sf.hibernate.HibernateException - if metadata on entity objects cannot be retrieved

startElement

public void startElement(java.lang.String uri,
                         java.lang.String localName,
                         java.lang.String qName,
                         org.xml.sax.Attributes attributes)
                  throws org.xml.sax.SAXException
Start an Xml element handling method

Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler
Parameters:
uri - The namespace URI of parsed stream
localName - Local name of started element
qName - Qualified name of started element
attributes - Attributes of started element
Throws:
org.xml.sax.SAXException - if something wrong occurs

characters

public void characters(char[] iArr,
                       int start,
                       int length)
                throws org.xml.sax.SAXException
Read content as characteers

Specified by:
characters in interface org.xml.sax.ContentHandler
Overrides:
characters in class org.xml.sax.helpers.DefaultHandler
Parameters:
iArr - The characters array read
start - Start index
length - Charactes length
Throws:
org.xml.sax.SAXException - if somethong wrong occurs

endElement

public void endElement(java.lang.String uri,
                       java.lang.String localName,
                       java.lang.String qName)
                throws org.xml.sax.SAXException
End an Xml element handling method

Specified by:
endElement in interface org.xml.sax.ContentHandler
Overrides:
endElement in class org.xml.sax.helpers.DefaultHandler
Parameters:
uri - The namespace URI of parsed stream
localName - Local name of ended element
qName - Qualified name of ended element
Throws:
org.xml.sax.SAXException - if somethong wrong occurs

getContents

protected java.lang.String getContents()
Returns:
The tag contents as text

getPersister

protected net.sf.hibernate.persister.ClassPersister getPersister(java.lang.Class clazz)
                                                          throws net.sf.hibernate.MappingException
Returns:
The ClassPersister correponsding to this class of entity
Throws:
net.sf.hibernate.MappingException


Copyright © 2005-2008 Join. All Rights Reserved.