Data Request Broker
2-3-release

fr.gael.drb.impl.xml
Class XmlFactory

java.lang.Object
  extended by fr.gael.drb.impl.xml.XmlFactory
All Implemented Interfaces:
DrbFactoryImpl, DrbUpdateImpl

public class XmlFactory
extends Object
implements DrbFactoryImpl, DrbUpdateImpl

Factory of XML nodes. This factory creates DrbNodes breaking down an XML document. The nodes generated by this class are wrappers to Java implementation of DOM. This factory uses the default javax.parsers.DOMParser to load the XML document contents and return the root element of the document as an XmlNode that implement the DrbNode interface. Because the XmlNode holds all the necessary data to live alone, the parser results as weel as the document loaded in this class are not stored.


Field Summary
protected static long MAXIMUM_DOM_SIZE
          The maximum file size for the DOM implementation.
 
Constructor Summary
XmlFactory()
           
 
Method Summary
 String getIdentifier()
          XML identifier.
 String getName()
          The name of the XML implementation.
static void main(String[] args)
          Make this class runnable for testing.
 DrbNode open(DrbNode base_node)
          XML root node from an existing node.
 DrbNode open(URL uri)
          XML root node matching a given URI.
 DrbNode open(URL uri, DrbNode base_node)
          XML node matching a given URI from an existing node.
 void put(DrbNode input, DrbNode target_node)
          Put a node as child of an existing node.
 void put(DrbNode input, URL uri)
          Put a node at the given path.
 void put(DrbNode input, URL uri, DrbNode base_node)
          Opens the node matching a given URI from an existing node.
static void writeXML(DrbNode node, OutputStream file)
          Writes the input tree nodes into a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAXIMUM_DOM_SIZE

protected static long MAXIMUM_DOM_SIZE
The maximum file size for the DOM implementation.

Constructor Detail

XmlFactory

public XmlFactory()
Method Detail

getIdentifier

public String getIdentifier()
XML identifier. The indentifier of this implementation is "xml.

Specified by:
getIdentifier in interface DrbFactoryImpl
Returns:
"xml" string.

getName

public String getName()
The name of the XML implementation. The explicit name of the implementation is "eXtensible Markup Language (XML)".

Specified by:
getName in interface DrbFactoryImpl
Returns:
"eXtensible Markup Language (XML)".

open

public DrbNode open(URL uri)
XML root node matching a given URI. Not supported.

Specified by:
open in interface DrbFactoryImpl
Parameters:
uri - Not considered.
Returns:
Always null.

open

public DrbNode open(DrbNode base_node)
XML root node from an existing node. The provided base node shall exist and it shall be able to provide a FileInputStream implementation.

Specified by:
open in interface DrbFactoryImpl
Parameters:
base_node - The node to be considered in input.
Returns:
DrbNode the xml node to open

open

public DrbNode open(URL uri,
                    DrbNode base_node)
XML node matching a given URI from an existing node. This operation does not consider the uri parameter and delegate the node creation to the open(DrbNode baseNode) operation.

Specified by:
open in interface DrbFactoryImpl
Parameters:
uri - Not considered here.
base_node - The input node to be used as context or base.
Returns:
A root node or null if an error occured or if the implementation does not supports URI or the input node.

put

public void put(DrbNode input,
                URL uri)
Put a node at the given path. This operation creates and returns a DrbNode corresponding to the given "Uniform Resource Identifier" (URI). Because URL class provided by java.net package supports the URI specifications, it has been used has URI parameter. The implementation is supposed to be able to handle the URI with a default or absolute context.

Specified by:
put in interface DrbUpdateImpl

put

public void put(DrbNode input,
                DrbNode target_node)
Put a node as child of an existing node. This operation creates and returns a DrbNode using an existing node as base or context. The input DrbNode has to be used as base of the creation. If the implementation is not able to handle any input node, it shall always return null. The reference to the input shall not be null.

Specified by:
put in interface DrbUpdateImpl
Parameters:
input - An input node
target_node - The input node to be used as context or base. This parameter shall not be null.

put

public void put(DrbNode input,
                URL uri,
                DrbNode base_node)
Opens the node matching a given URI from an existing node. This operation creates and returns a DrbNode corresponding to the given "Uniform Resource Identifier" (URI) using an existing node as base or context. Because URL class provided by java.net package supports the URI specifications, it has been used has URI parameter. The input DrbNode has to be used as base of the creation. If the implementation is not able to handle any input node, it shall always return null even if it is able to use the passed URI standalone. If the reference to the URI is null the operation works as the open(DrbNode baseNode). Similary, if the URI reference is null, the operation works as the open(URL uri).

Specified by:
put in interface DrbUpdateImpl
Parameters:
input - An input node
uri - The "Uniform Resource Identifier" (URI) to be handled.
base_node - The input node to be used as context or base.

writeXML

public static void writeXML(DrbNode node,
                            OutputStream file)
Writes the input tree nodes into a file.

Parameters:
node - the input node to be printed.
file - the output stream to be used for printing XML document

main

public static void main(String[] args)
Make this class runnable for testing.

Parameters:
args - the arguments.

Data Request Broker - DRB API®
2-3-release

Copyright© 2001-2009 GAEL Consultant. All rights reserved. Use is subject to license terms .