JADE v6.1

com.dautelle.xml
Class Constructor

java.lang.Object
  extended bycom.dautelle.xml.Constructor

public class Constructor
extends java.lang.Object

This class restores objects which have been serialized in XML format using an ObjectWriter.

When the XML document is parsed, each elements are recursively processed and Java objects are created using the factory method static Object valueOf(XmlElement) of the class identified by the name of the XML element. The final object constructed (and returned) is always the root element of the XML input source.

Processing instructions are ignored, but namespaces may be used to specify package names (java addressing scheme).

For example, the following XML representation can be used to create a matrix composed of complex elements:

 <?xml version='1.0'?>
 <Matrix xmlns="java:com.dautelle.math" row='2' column='2'>
   <Complex real='0.0' imaginary='0.0'/>
   <Complex real='0.0' imaginary='1.0'/>
   <Complex real='0.0' imaginary='1.0'/>
   <Complex real='0.0' imaginary='0.0'/>
 </Matrix>
 

The following code segment creates the matrix from a file.

     Constructor constructor = new Constructor();
     Matrix M = (Matrix) constructor.create(file);
 

Version:
4.5, May 29, 2003
Author:
Jean-Marie Dautelle
See Also:
ObjectWriter

Constructor Summary
Constructor()
          Default constructor (use RealtimeParser to parse XML document).
 
Method Summary
 java.lang.Object create(java.io.File file)
          Creates an object from its XML representation read from the specified File.
 java.lang.Object create(org.xml.sax.InputSource xmlSource)
          Creates an object from its XML representation read from the specified InputSource.
 java.lang.Object create(java.io.InputStream in)
          Creates an object from its XML representation read from the specified InputStream.
 java.lang.Object create(java.io.Reader reader)
          Creates an object from its XML representation read from the specified Reader.
 java.lang.Object create(java.net.URL url)
          Creates an object from its XML representation read from the specified URL.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Constructor

public Constructor()
Default constructor (use RealtimeParser to parse XML document).

Method Detail

create

public java.lang.Object create(java.io.InputStream in)
                        throws ConstructorException
Creates an object from its XML representation read from the specified InputStream.

Parameters:
in - the input stream containing the XML representation of the object being created.
Returns:
a new object dynamically created.
Throws:
ConstructorException - if the object cannot be created.

create

public java.lang.Object create(java.io.Reader reader)
                        throws ConstructorException
Creates an object from its XML representation read from the specified Reader.

Parameters:
reader - the reader containing the XML representation of the object being created.
Returns:
a new object dynamically created.
Throws:
ConstructorException - if the object cannot be created.

create

public java.lang.Object create(java.io.File file)
                        throws ConstructorException
Creates an object from its XML representation read from the specified File.

Parameters:
file - the file containing the XML representation of the object being created.
Returns:
a new object dynamically created.
Throws:
ConstructorException - if the object cannot be created.

create

public java.lang.Object create(java.net.URL url)
                        throws ConstructorException
Creates an object from its XML representation read from the specified URL.

Parameters:
url - the url containing the XML representation of the object being created.
Returns:
a new object dynamically created.
Throws:
ConstructorException - if the object cannot be created.

create

public java.lang.Object create(org.xml.sax.InputSource xmlSource)
                        throws ConstructorException
Creates an object from its XML representation read from the specified InputSource.

Parameters:
xmlSource - the input source to read from.
Returns:
a new object dynamically created.
Throws:
ConstructorException - if the object cannot be created.

JADE v6.1

Copyright © 2004 Jean-Marie Dautelle.