de.keepondreaming.xml
Class XmlConverter
java.lang.Object
org.xml.sax.helpers.DefaultHandler
de.keepondreaming.xml.XmlConverter
- All Implemented Interfaces:
- org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler
public class XmlConverter
- extends org.xml.sax.helpers.DefaultHandler
Reads an xml file and sets the data using the passed strategy patterns
$Author: wintermond $ $Date: 2005/07/10 18:37:00 $ $Log: XmlConverter.java,v $
$Author: wintermond $ $Date: 2005/07/10 18:37:00 $ Revision 1.1 2005/07/10 18:37:00 wintermond
$Author: wintermond $ $Date: 2005/07/10 18:37:00 $ Renamed Parser to XMLConverter
$Author: wintermond $ $Date: 2005/07/10 18:37:00 $ Major performance improvements
$Author: wintermond $ $Date: 2005/07/10 18:37:00 $ Support for java.util.Date, java.sql.Date and java.sql.TimeStamp as return types
$Author: wintermond $ $Date: 2005/07/10 18:37:00 $ Support for attributes modelled as sub tags
$Author: wintermond $ $Date: 2005/07/10 18:37:00 $ Support for method getters/setter with names different from the xml names
$Author: wintermond $ $Date: 2005/07/10 18:37:00 $
Revision 1.4 2005/07/09 14:11:54 wintermond Introduced ability to handle
subtags that contain simple values
Revision 1.3 2005/07/09 09:57:58 wintermond Javadoc, moved some methods to
Util class
Method Summary |
void |
characters(char[] chars,
int start,
int len)
|
java.lang.Object |
convert(java.io.InputStream in,
java.lang.Class rootElement)
Reads the xml from the stream and sets the data structures accordingly
using reflection. |
void |
endElement(java.lang.String arg0,
java.lang.String arg1,
java.lang.String elementName)
|
java.lang.Object |
parse(org.xml.sax.InputSource in,
java.lang.Class rootElement)
Reads the xml from the stream and sets the data structures accordingly
using reflection. |
void |
startElement(java.lang.String arg0,
java.lang.String arg1,
java.lang.String elementName,
org.xml.sax.Attributes attributes)
|
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 |
XmlConverter
public XmlConverter(AnnotationStrategy parserStrategy,
ObjectStrategy objectStrategy)
throws javax.xml.parsers.ParserConfigurationException,
org.xml.sax.SAXException
- Default constructor
- Throws:
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
java.lang.NullPointerException
- If any parameter is null
convert
public java.lang.Object convert(java.io.InputStream in,
java.lang.Class rootElement)
throws java.io.IOException,
org.xml.sax.SAXException
- Reads the xml from the stream and sets the data structures accordingly
using reflection. The type of is expected to be the root
node in the xml structure
- Parameters:
in
- rootElement
- Must be an interface
- Returns:
- An object containing the root data read from the
inpustream. This object is assignable to the interface
passed by
rootElement
- Throws:
java.io.IOException
- Error while reading the data from the stream
org.xml.sax.SAXException
java.lang.IllegalArgumentException
- rootElement
is not an interface
parse
public java.lang.Object parse(org.xml.sax.InputSource in,
java.lang.Class rootElement)
throws java.io.IOException,
org.xml.sax.SAXException
- Reads the xml from the stream and sets the data structures accordingly
using reflection. The type of is expected to be the root
node in the xml structure
- Parameters:
in
- rootElement
-
- Returns:
- An object containing the root data read from the
inpustream. This object is assignable to the interface
passed by
rootElement
- Throws:
java.io.IOException
- Error while reading the data from the stream
org.xml.sax.SAXException
java.lang.IllegalArgumentException
- rootElement
is not an interface
characters
public void characters(char[] chars,
int start,
int len)
throws org.xml.sax.SAXException
- Specified by:
characters
in interface org.xml.sax.ContentHandler
- Overrides:
characters
in class org.xml.sax.helpers.DefaultHandler
- Throws:
org.xml.sax.SAXException
endElement
public void endElement(java.lang.String arg0,
java.lang.String arg1,
java.lang.String elementName)
throws org.xml.sax.SAXException
- Specified by:
endElement
in interface org.xml.sax.ContentHandler
- Overrides:
endElement
in class org.xml.sax.helpers.DefaultHandler
- Throws:
org.xml.sax.SAXException
startElement
public void startElement(java.lang.String arg0,
java.lang.String arg1,
java.lang.String elementName,
org.xml.sax.Attributes attributes)
throws org.xml.sax.SAXException
- Specified by:
startElement
in interface org.xml.sax.ContentHandler
- Overrides:
startElement
in class org.xml.sax.helpers.DefaultHandler
- Throws:
org.xml.sax.SAXException
Copyright © -2005 . All Rights Reserved.