org.figure8.join.core.persistence
Class HibernateXmlDatabinder

java.lang.Object
  extended by org.springframework.orm.hibernate.support.HibernateDaoSupport
      extended by org.figure8.join.core.persistence.HibernateXmlDatabinder
All Implemented Interfaces:
XmlDatabinder, org.springframework.beans.factory.InitializingBean

public class HibernateXmlDatabinder
extends org.springframework.orm.hibernate.support.HibernateDaoSupport
implements XmlDatabinder

This is an implementation of XmlDatabinder for entity objects using Hibernate as an ORM system.

Version:
$Revision: 1.1 $
Author:
Laurent Broudoux

Field Summary
static java.lang.String CARRIAGE_RETURN
           
static java.lang.String CONST_CLASS
           
static java.lang.String CONST_CLOSE_CDATA
           
static java.lang.String CONST_CLOSE_OBJECT_TAG
           
static java.lang.String CONST_COLLECTION
           
static java.lang.String CONST_COMPONENT
           
static java.lang.String CONST_COMPOSITE_ELEMENT
           
static java.lang.String CONST_COMPOSITE_ID
           
static java.lang.String CONST_ELEMENT
           
static java.lang.String CONST_ID
           
static java.lang.String CONST_INDEX_ID
           
static java.lang.String CONST_INDEX_TYPE
           
static java.lang.String CONST_NAME
           
static java.lang.String CONST_OBJECT
           
static java.lang.String CONST_OPEN_CDATA
           
static java.lang.String CONST_OPEN_OBJECT_TAG
           
static java.lang.String CONST_PROPERTY
           
static java.lang.String CONST_SUBCOLLECTION
           
static java.lang.String CONST_TYPE
           
static java.lang.String DEFAULT_ENCODING
          Constant representing default encoding for writing Xml
static java.lang.String END_TAG_CARRIAGE_RETURN
           
static java.text.SimpleDateFormat isoDateFormat
          Simple date formater for ISO dates
static java.text.SimpleDateFormat isoTimestampFormat
          Simple date formater for ISO timestamps
static java.lang.String LEFT_CHEVRON
           
static java.lang.String RIGHT_CHEVRON
           
static java.lang.String START_CLOSE_TAG
           
 
Fields inherited from class org.springframework.orm.hibernate.support.HibernateDaoSupport
logger
 
Constructor Summary
HibernateXmlDatabinder()
          Creates a new instance of HibernateXmlDatabinder
 
Method Summary
static java.lang.String formatDate(java.util.Date date)
           
static java.lang.String formatTimestamp(java.util.Date date)
           
 java.util.Collection loadFromXml(java.io.InputStream is)
          Load a collection of EntityObjects from a Xml stream
static java.util.Date parseDate(java.lang.String dateStr)
           
static java.util.Date parseTimestamp(java.lang.String dateStr)
           
 void setEncoding(java.lang.String encoding)
           
 void writeToXml(java.io.Writer writer, ObjectDao dao)
          Write a collection of EntityObjects using their Xml form
 
Methods inherited from class org.springframework.orm.hibernate.support.HibernateDaoSupport
afterPropertiesSet, closeSessionIfNecessary, convertHibernateAccessException, createHibernateTemplate, getHibernateTemplate, getSession, getSession, getSessionFactory, initDao, setHibernateTemplate, setSessionFactory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_ENCODING

public static final java.lang.String DEFAULT_ENCODING
Constant representing default encoding for writing Xml

See Also:
Constant Field Values

isoDateFormat

public static java.text.SimpleDateFormat isoDateFormat
Simple date formater for ISO dates


isoTimestampFormat

public static java.text.SimpleDateFormat isoTimestampFormat
Simple date formater for ISO timestamps


LEFT_CHEVRON

public static final java.lang.String LEFT_CHEVRON
See Also:
Constant Field Values

RIGHT_CHEVRON

public static final java.lang.String RIGHT_CHEVRON
See Also:
Constant Field Values

CARRIAGE_RETURN

public static final java.lang.String CARRIAGE_RETURN
See Also:
Constant Field Values

START_CLOSE_TAG

public static final java.lang.String START_CLOSE_TAG
See Also:
Constant Field Values

END_TAG_CARRIAGE_RETURN

public static final java.lang.String END_TAG_CARRIAGE_RETURN
See Also:
Constant Field Values

CONST_OBJECT

public static final java.lang.String CONST_OBJECT
See Also:
Constant Field Values

CONST_OPEN_OBJECT_TAG

public static final java.lang.String CONST_OPEN_OBJECT_TAG
See Also:
Constant Field Values

CONST_CLOSE_OBJECT_TAG

public static final java.lang.String CONST_CLOSE_OBJECT_TAG
See Also:
Constant Field Values

CONST_NAME

public static final java.lang.String CONST_NAME
See Also:
Constant Field Values

CONST_CLASS

public static final java.lang.String CONST_CLASS
See Also:
Constant Field Values

CONST_INDEX_ID

public static final java.lang.String CONST_INDEX_ID
See Also:
Constant Field Values

CONST_INDEX_TYPE

public static final java.lang.String CONST_INDEX_TYPE
See Also:
Constant Field Values

CONST_COMPOSITE_ELEMENT

public static final java.lang.String CONST_COMPOSITE_ELEMENT
See Also:
Constant Field Values

CONST_ELEMENT

public static final java.lang.String CONST_ELEMENT
See Also:
Constant Field Values

CONST_SUBCOLLECTION

public static final java.lang.String CONST_SUBCOLLECTION
See Also:
Constant Field Values

CONST_ID

public static final java.lang.String CONST_ID
See Also:
Constant Field Values

CONST_COMPOSITE_ID

public static final java.lang.String CONST_COMPOSITE_ID
See Also:
Constant Field Values

CONST_COLLECTION

public static final java.lang.String CONST_COLLECTION
See Also:
Constant Field Values

CONST_PROPERTY

public static final java.lang.String CONST_PROPERTY
See Also:
Constant Field Values

CONST_COMPONENT

public static final java.lang.String CONST_COMPONENT
See Also:
Constant Field Values

CONST_TYPE

public static final java.lang.String CONST_TYPE
See Also:
Constant Field Values

CONST_OPEN_CDATA

public static final java.lang.String CONST_OPEN_CDATA
See Also:
Constant Field Values

CONST_CLOSE_CDATA

public static final java.lang.String CONST_CLOSE_CDATA
See Also:
Constant Field Values
Constructor Detail

HibernateXmlDatabinder

public HibernateXmlDatabinder()
Creates a new instance of HibernateXmlDatabinder

Method Detail

setEncoding

public void setEncoding(java.lang.String encoding)
Parameters:
encoding - The encoding for Xml output

formatDate

public static java.lang.String formatDate(java.util.Date date)
Parameters:
date - The date to format
Returns:
The string representing date

formatTimestamp

public static java.lang.String formatTimestamp(java.util.Date date)
Parameters:
date - The date to format as a timestamp
Returns:
The string representing timestamp

parseDate

public static java.util.Date parseDate(java.lang.String dateStr)
                                throws java.text.ParseException
Parameters:
dateStr - the string representation of date
Returns:
The date represented by this string
Throws:
java.text.ParseException - if string cannot be parsed

parseTimestamp

public static java.util.Date parseTimestamp(java.lang.String dateStr)
                                     throws java.text.ParseException
Parameters:
dateStr - the string representation of timestamp
Returns:
The timestamp represented by this string
Throws:
java.text.ParseException - if string cannot be parsed

loadFromXml

public java.util.Collection loadFromXml(java.io.InputStream is)
                                 throws InfrastructureException,
                                        java.io.IOException
Load a collection of EntityObjects from a Xml stream

Specified by:
loadFromXml in interface XmlDatabinder
Parameters:
is - An input stream containing Xml exported form of entity objects
Returns:
A collection of EntityObjects
Throws:
InfrastructureException - if entity objects cannot be recreated from stream
java.io.IOException - if stream cannot be correctly read

writeToXml

public void writeToXml(java.io.Writer writer,
                       ObjectDao dao)
                throws InfrastructureException,
                       java.io.IOException
Write a collection of EntityObjects using their Xml form

Specified by:
writeToXml in interface XmlDatabinder
Parameters:
writer - The writer to use for outputing entity objects
dao - The data access objects from whom are retrievied entities (using the findAll() method)
Throws:
InfrastructureException - if entity objects cannot be exported corectly
java.io.IOException - if writer cannot be correctly written


Copyright © 2005-2008 Join. All Rights Reserved.