eu.xtreemos.xosd.xmlextractor
Class XMLExtractor

java.lang.Object
  extended by eu.xtreemos.system.eventmachine.stage.AbstractStage
      extended by eu.xtreemos.system.eventmachine.stage.AbstractReceivingStage
          extended by eu.xtreemos.system.eventmachine.stage.Abstract2wayStage
              extended by eu.xtreemos.xosd.xmlextractor.XMLExtractor
All Implemented Interfaces:
eu.xtreemos.system.eventmachine.queue.IEventHandler, eu.xtreemos.system.eventmachine.stage.IStage

public class XMLExtractor
extends eu.xtreemos.system.eventmachine.stage.Abstract2wayStage

A class for service for dealing with XMLs, primarily GLUE and JDSL.

Author:
Matej

Field Summary
static java.lang.Integer GLUEV12
          Specifies that the XML uses the GLUE v12 schema.
static java.lang.Integer JSDL
          Specifies that the XML uses the JDSL schema.
(package private) static org.apache.log4j.Logger logger
           
 
Fields inherited from class eu.xtreemos.system.eventmachine.stage.Abstract2wayStage
context, counter, curContext, sink
 
Fields inherited from class eu.xtreemos.system.eventmachine.stage.AbstractReceivingStage
queue
 
Fields inherited from class eu.xtreemos.system.eventmachine.stage.AbstractStage
handlerChain, handlerGroup, handlerThreads, name, running, serviceListeners
 
Constructor Summary
XMLExtractor()
           
 
Method Summary
 java.lang.String getHandledEventType()
           
 java.util.Hashtable<java.lang.String,java.lang.Object> getXMLObject(java.lang.String path, java.lang.Integer schemaType)
          Transform an XML stored in a file into a hash table containing the searchable elements of the source XML.
 java.util.Hashtable<java.lang.String,java.lang.Object> getXMLObjectFromDocument(org.w3c.dom.Document xmlDocument, java.lang.Integer schemaType)
          Transform an XML stored in a DOM document into a hash table containing the searchable elements of the source XML.
 java.util.Hashtable<java.lang.String,java.lang.Object> getXMLObjectFromString(java.lang.String xmlDocument, java.lang.Integer schemaType)
          Transform an XML stored in a string into a hash table containing the searchable elements of the source XML.
 void handleEvent(java.lang.Object event)
           
 void init()
           
protected  java.lang.String selectSchemaFile(java.lang.Integer schemaType)
           
 
Methods inherited from class eu.xtreemos.system.eventmachine.stage.Abstract2wayStage
getContext, removeContext, SendException, SendException, SendException, SendReply, SendReply, SendReply, setSink
 
Methods inherited from class eu.xtreemos.system.eventmachine.stage.AbstractReceivingStage
dequeue, getSource
 
Methods inherited from class eu.xtreemos.system.eventmachine.stage.AbstractStage
addHandler, addHandler, addServiceListener, getName, getShortName, getThreadCount, notifyServiceInitialised, notifyServiceStarted, notifyServiceStopped, processEvent, removeHandler, removeServiceListener, setThreadCount, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

static final org.apache.log4j.Logger logger

GLUEV12

public static final java.lang.Integer GLUEV12
Specifies that the XML uses the GLUE v12 schema.


JSDL

public static final java.lang.Integer JSDL
Specifies that the XML uses the JDSL schema.

Constructor Detail

XMLExtractor

public XMLExtractor()
Method Detail

selectSchemaFile

protected java.lang.String selectSchemaFile(java.lang.Integer schemaType)

getXMLObject

public java.util.Hashtable<java.lang.String,java.lang.Object> getXMLObject(java.lang.String path,
                                                                           java.lang.Integer schemaType)
                                                                    throws java.security.InvalidParameterException,
                                                                           java.io.IOException,
                                                                           org.xml.sax.SAXException
Transform an XML stored in a file into a hash table containing the searchable elements of the source XML. The elements of the hashtable are either strings for simple tags, instances of Hashtable for complex structures, and instances of ArrayList for multiple entries having the same key.

Parameters:
path - The path to the xml file on the file system of the service's host.
schemaType - The type of schema. (TODO use some sort of an enum type instead of int)
Returns:
A Hashtable containing the searchable elements of the source XML.
Throws:
org.xml.sax.SAXException
java.io.IOException
java.security.InvalidParameterException

getXMLObjectFromDocument

public java.util.Hashtable<java.lang.String,java.lang.Object> getXMLObjectFromDocument(org.w3c.dom.Document xmlDocument,
                                                                                       java.lang.Integer schemaType)
                                                                                throws java.lang.Exception
Transform an XML stored in a DOM document into a hash table containing the searchable elements of the source XML. The elements of the hashtable are either strings for simple tags, instances of Hashtable for complex structures, and instances of ArrayList for multiple entries having the same key.

Parameters:
xmlDocument - xml document object
schemaType - The type of schema. (TODO use some sort of an enum type instead of int)
Returns:
A Hashtable containing the searchable elements of the source XML.
Throws:
java.lang.Exception

getXMLObjectFromString

public java.util.Hashtable<java.lang.String,java.lang.Object> getXMLObjectFromString(java.lang.String xmlDocument,
                                                                                     java.lang.Integer schemaType)
                                                                              throws java.lang.Exception
Transform an XML stored in a string into a hash table containing the searchable elements of the source XML. The elements of the hashtable are either strings for simple tags, instances of Hashtable for complex structures, and instances of ArrayList for multiple entries having the same key.

Parameters:
xmlDocument - The contents of the XML contents.
schemaType - The type of schema. (TODO use some sort of an enum type instead of int)
Returns:
A Hashtable containing the searchable elements of the source XML.
Throws:
java.lang.Exception

init

public void init()
Specified by:
init in interface eu.xtreemos.system.eventmachine.stage.IStage
Overrides:
init in class eu.xtreemos.system.eventmachine.stage.AbstractStage

getHandledEventType

public java.lang.String getHandledEventType()
Specified by:
getHandledEventType in class eu.xtreemos.system.eventmachine.stage.AbstractReceivingStage

handleEvent

public void handleEvent(java.lang.Object event)
                 throws java.lang.Exception
Specified by:
handleEvent in interface eu.xtreemos.system.eventmachine.queue.IEventHandler
Specified by:
handleEvent in class eu.xtreemos.system.eventmachine.stage.AbstractReceivingStage
Throws:
java.lang.Exception