Main Page   Packages   Class Hierarchy   Compound List   File List   Compound Members  

OpenXMLDecoder Class Reference

Inheritance diagram for OpenXMLDecoder:

Inheritance graph
[legend]
Collaboration diagram for OpenXMLDecoder:

Collaboration graph
[legend]
List of all members.

Public Methods

 OpenXMLDecoder (Context _decoders)
 OpenXMLDecoder ()
void importElement (Context _configuration, String _xml_file_name, ContextFactory _context_factory, ClassPathFinder _finder) throws JonathanException

Private Methods

XMLElement readXMLElementFromResource (String _resource_name, ClassPathFinder _finder) throws JonathanException

Static Private Attributes

HTable default_decoders = HTable.newTable()

Detailed Description

XML to runtime components translator. Has built-in alias, atom, assemblage, include & property decoders. May handle any other component types as long as their specific decoders are provided.

In order to be able to decode a given custom-made component type, a specific TagCompiler must be implemented for this type, and provided in the OpenXMLDecoder configuration context (i.e. in its constructor Context parameter) as the value of an Element named after the component type's XML tag.

An instance of OpenXMLDecoder is automatically used at startup by Jonathan's KKernel to decode Jonathan's runtime configuration file. A complete configuration of OpenXMLDecoder is therefore provided in Jonathan's compiled boot configuration.

See also:
org.objectweb.jonathan.libs.kernel.KKernel

Definition at line 74 of file OpenXMLDecoder.java.


Constructor & Destructor Documentation

OpenXMLDecoder::OpenXMLDecoder ( Context _decoders ) [inline]
 

creates a new xml decoder with the given additional specific decoders

Parameters:
_decoders   contains the additional specific decoders; their elements have the name of their component types' XML tags.

Definition at line 95 of file OpenXMLDecoder.java.

00095                                             {
00096       decoders = _decoders;
00097    }

OpenXMLDecoder::OpenXMLDecoder ( ) [inline]
 

Definition at line 99 of file OpenXMLDecoder.java.

00099                            {
00100       decoders = null;
00101    }


Member Function Documentation

void OpenXMLDecoder::importElement ( Context _configuration,
String _xml_file_name,
ContextFactory _context_factory,
ClassPathFinder _finder ) [inline]
 

imports an XML file in the given configuration. First reads the root XML element, and then dispatches its decoding to a new Dispatcher.

Parameters:
_configuration   the destination configuration context
_xml_file_name   the XML source file name
_context_factory   used to create new Contexts
_finder   used to find the XML file (that's all??)

Reimplemented from File2Configuration.

Definition at line 112 of file OpenXMLDecoder.java.

00116                                {
00117       XMLElement $xml_element = readXMLElementFromResource(_xml_file_name,_finder);
00118       String $current_tag = $xml_element.getTagName();
00119       Dispatcher $dispatcher = new Dispatcher(_context_factory,decoders,_finder);
00120       if ($current_tag.equals("CONFIGURATION")) {
00121          $dispatcher.importXMLElements($xml_element.enumerateChildren(),_configuration);
00122       } else {
00123          $dispatcher.importXMLElement($xml_element,_configuration);
00124       }
00125    }

XMLElement OpenXMLDecoder::readXMLElementFromResource ( String _resource_name,
ClassPathFinder _finder ) [inline, private]
 

Reads a resource and parses it as an XML file. Used by importElement.

Parameters:
_xml_file_name   the XML source file name
_finder   used to find the XML files to be parsed.
Returns:
the corresponding NanoXML element.

Definition at line 134 of file OpenXMLDecoder.java.

00135                                {
00136       try {
00137          InputStream $is = _finder.findResource(_resource_name);
00138          if ($is == null) {
00139             throw new JonathanException("Resource " + _resource_name + " not found.");
00140          }
00141          XMLElement $result = new XMLElement();
00142          $result.parseFromReader(new BufferedReader(new InputStreamReader($is)));
00143          return $result;
00144       } catch (IOException e) {
00145          throw new JonathanException(e);
00146       } catch (XMLParseException e) {
00147          throw new JonathanException(e);
00148       }
00149    }


Member Data Documentation

HTable OpenXMLDecoder::default_decoders = HTable.newTable() [static, private]
 

the built-in decoders

Definition at line 77 of file OpenXMLDecoder.java.


The documentation for this class was generated from the following file:
Generated at Fri May 31 19:24:55 2002 for Jonathan by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001