INRIA & FluxMedia

fr.fluxmedia.transmorpher.parser
Class ProcessParser

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by fr.fluxmedia.transmorpher.parser.FMParser
          extended by fr.fluxmedia.transmorpher.parser.ProcessParser
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

public class ProcessParser
extends FMParser

This class allows the creation of a parser for a Transmorpher process. Methods are provided to create a graph corresponding to the process defined in the transmorpher language.


Field Summary
protected  Call currentCall
          the current call in creation
protected  Iterator currentIterator
          the current iterator to parse
protected  java.lang.String currentParam
          the name of the current parameter to parse
protected  Parameters currentParams
          the current parameters
protected  ModTag currentRule
          the current rule in creation
protected  Transformation currentTransformation
          the current transformation in creation
protected  Transmorpher currentTransmorpher
          the current transmorpher in creation
protected  java.lang.String currentWParam
          the name of the current with-param to parse
protected  java.util.Hashtable imports
          to store imported processes
protected  boolean inLitteralXSLT
          Are we copying some XSLT
protected  boolean inQuery
          If true , parser is in a query part of the process
protected  boolean inRuleSet
          If true , parser is in a ruleset part of the process
protected  java.lang.Object[] observers
          for the GUI (flowcomposer)
protected  QueryParser queryParser
          a parser for the query
protected  Rule rule
          a rule
protected  RuleSetParser ruleSetParser
          a parser for the ruleset
protected  java.lang.String tmp
          a buffer
protected  java.util.Stack tStack
           
protected  java.lang.String uri
          an uri to a process
 
Fields inherited from class fr.fluxmedia.transmorpher.parser.FMParser
debugMode, iContext, output, parser
 
Constructor Summary
ProcessParser(int debugMode)
          Creates an XML Parser.
ProcessParser(int debugMode, java.lang.Object[] observers)
          Creates an XML Parser.
 
Method Summary
static java.lang.String[] AnalysePortNames(java.lang.String pListe)
          Analyzes the port Name attributes "a b c" will be translate to {"a","b","c"}
 void characters(char[] ch, int start, int length)
          This method is used to get data of an element Data are stored in a buffer (tmp)
 void checkChannels(Process t)
          Checks the channel of the process.
protected  void cleanStack()
          Resets the parameters as they were after taking care of a Call
 void endElement(java.lang.String namespaceURI, java.lang.String pName, java.lang.String qName)
          Called by the XML parser at the end of an element.
protected  void fixBuf(Transformation t, PortList bufList, PortList inList, java.lang.String[] portNames, int expected)
          Creates the buffered ports of a transformation.
protected  void fixInPorts(Call c, PortList list, java.lang.String[] portNames, int expected, java.lang.String type)
          Creates the in ports of a call.
protected  void fixInPorts(Transformation t, PortList list, java.lang.String[] portNames)
          Creates the in ports of a transformation.
protected  void fixOutBuf(Repeat r, PortList list, java.lang.String[] portNames, int expected)
          Creates the out buffered ports of a repeat.
protected  void fixOutPorts(Call c, PortList list, java.lang.String[] portNames, int expected, java.lang.String type)
          Creates the out ports of a call.
protected  void fixOutPorts(Transformation t, PortList list, java.lang.String[] portNames)
          Creates the out ports of a transformation.
 java.lang.String listAttribute(org.xml.sax.Attributes atts)
          Returns a XML-attribute string from the result of such a string
 Transmorpher newParse(java.lang.String uri)
          Parses the document corresponding to the URI given in parameter If the current process has links (import or include) to others documents then they are parsed.
 void registerChannelIn(PortList list, boolean Callp)
          Register a channel with its input The algorithm depends on the context (transformation or call) If we are in a Transformation: the in are input for the channel, they cannot be anything but Channel the out are output for the channel, they cannot be anything but Channel If we are in a Call: the in are output to the channel, they cannot be anything but Channel and _stdin_ the out are input to the channel, they cannot be anything but Channel and _stdout_ or _null_
 void registerChannelOut(PortList list, boolean Callp)
          Register a channel with its output The algorithm depends on the context (transformation or call) If we are in a Transformation: the in are input for the channel, they cannot be anything but Channel the out are output for the channel, they cannot be anything but Channel If we are in a Call: the in are output to the channel, they cannot be anything but Channel and _stdin_ the out are input to the channel, they cannot be anything but Channel and _stdout_ or _null_
 void setEndQuery()
          Sets the inQuery flag to false.
 void setEndRuleSet()
          Sets the inRuleset flag to false.
 void startElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qname, org.xml.sax.Attributes atts)
          Called by the XML parser at the begining of an element.
 
Methods inherited from class fr.fluxmedia.transmorpher.parser.FMParser
error, fatalError, warning
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

uri

protected java.lang.String uri
an uri to a process


tmp

protected java.lang.String tmp
a buffer


currentTransmorpher

protected Transmorpher currentTransmorpher
the current transmorpher in creation


currentTransformation

protected Transformation currentTransformation
the current transformation in creation


currentCall

protected Call currentCall
the current call in creation


currentRule

protected ModTag currentRule
the current rule in creation


rule

protected Rule rule
a rule


currentParam

protected java.lang.String currentParam
the name of the current parameter to parse


currentWParam

protected java.lang.String currentWParam
the name of the current with-param to parse


currentIterator

protected Iterator currentIterator
the current iterator to parse


currentParams

protected Parameters currentParams
the current parameters


imports

protected java.util.Hashtable imports
to store imported processes


tStack

protected java.util.Stack tStack

observers

protected java.lang.Object[] observers
for the GUI (flowcomposer)


ruleSetParser

protected RuleSetParser ruleSetParser
a parser for the ruleset


queryParser

protected QueryParser queryParser
a parser for the query


inLitteralXSLT

protected boolean inLitteralXSLT
Are we copying some XSLT


inRuleSet

protected boolean inRuleSet
If true , parser is in a ruleset part of the process


inQuery

protected boolean inQuery
If true , parser is in a query part of the process

Constructor Detail

ProcessParser

public ProcessParser(int debugMode)
              throws javax.xml.parsers.ParserConfigurationException,
                     org.xml.sax.SAXException
Creates an XML Parser.

Parameters:
debugMode - The value of the debug mode
Throws:
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException

ProcessParser

public ProcessParser(int debugMode,
                     java.lang.Object[] observers)
              throws javax.xml.parsers.ParserConfigurationException,
                     org.xml.sax.SAXException
Creates an XML Parser. This constructor is used by Flowcomposer only.

Parameters:
debugMode - The value of the debug mode
observers - the observers for flowcomposer
Throws:
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
Method Detail

newParse

public Transmorpher newParse(java.lang.String uri)
                      throws org.xml.sax.SAXException,
                             java.io.IOException
Parses the document corresponding to the URI given in parameter If the current process has links (import or include) to others documents then they are parsed.

Overrides:
newParse in class FMParser
Parameters:
uri - URI of the document to parse
Returns:
a graph structure
Throws:
org.xml.sax.SAXException
java.io.IOException - sends when an IO errors occurs

startElement

public void startElement(java.lang.String namespaceURI,
                         java.lang.String localName,
                         java.lang.String qname,
                         org.xml.sax.Attributes atts)
Called by the XML parser at the begining of an element. The corresponing graph component is create for each element.

Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler
Parameters:
namespaceURI - The namespace of the current element
localName - The local name of the current element
qname - The name of the current element
atts - The attributes name of the current element

characters

public void characters(char[] ch,
                       int start,
                       int length)
This method is used to get data of an element Data are stored in a buffer (tmp)

Specified by:
characters in interface org.xml.sax.ContentHandler
Overrides:
characters in class org.xml.sax.helpers.DefaultHandler

setEndRuleSet

public void setEndRuleSet()
Sets the inRuleset flag to false.


setEndQuery

public void setEndQuery()
Sets the inQuery flag to false.


endElement

public void endElement(java.lang.String namespaceURI,
                       java.lang.String pName,
                       java.lang.String qName)
Called by the XML parser at the end of an element.

Specified by:
endElement in interface org.xml.sax.ContentHandler
Overrides:
endElement in class org.xml.sax.helpers.DefaultHandler
Parameters:
namespaceURI - The namespace of the current element
localName - The local name of the current element
qname - The name of the current element

fixInPorts

protected void fixInPorts(Transformation t,
                          PortList list,
                          java.lang.String[] portNames)
Creates the in ports of a transformation.

Parameters:
t - The transformation
list - The port list which store the in ports
portNames - The names of the ports to create

fixOutPorts

protected void fixOutPorts(Transformation t,
                           PortList list,
                           java.lang.String[] portNames)
Creates the out ports of a transformation.

Parameters:
t - The transformation
list - The port list which store the out ports
portNames - The names of the ports to create

fixBuf

protected void fixBuf(Transformation t,
                      PortList bufList,
                      PortList inList,
                      java.lang.String[] portNames,
                      int expected)
Creates the buffered ports of a transformation.

Parameters:
t - The transformation
bufList - The port list which store the buffered ports
inList - The port list which store the in ports
portNames - The names of the ports to create
expected - The required number of ports

fixOutBuf

protected void fixOutBuf(Repeat r,
                         PortList list,
                         java.lang.String[] portNames,
                         int expected)
Creates the out buffered ports of a repeat.

Parameters:
r - The repeat
list - The port list which store the buffered ports
inList - The port list which store the in ports
portNames - The names of the ports to create
expected - The required number of ports

fixInPorts

protected void fixInPorts(Call c,
                          PortList list,
                          java.lang.String[] portNames,
                          int expected,
                          java.lang.String type)
Creates the in ports of a call.

Parameters:
t - The call
list - The port list which store the in ports
portNames - The names of the ports to create
expected - The required number of ports
type - The type of the call

fixOutPorts

protected void fixOutPorts(Call c,
                           PortList list,
                           java.lang.String[] portNames,
                           int expected,
                           java.lang.String type)
Creates the out ports of a call.

Parameters:
t - The call
list - The port list which store the in ports
portNames - The names of the ports to create
expected - The required number of ports
type - The type of the call

checkChannels

public void checkChannels(Process t)
Checks the channel of the process. Channel must be connected to in and out port

Parameters:
process - the process to check

registerChannelIn

public void registerChannelIn(PortList list,
                              boolean Callp)
Register a channel with its input The algorithm depends on the context (transformation or call) If we are in a Transformation: the in are input for the channel, they cannot be anything but Channel the out are output for the channel, they cannot be anything but Channel If we are in a Call: the in are output to the channel, they cannot be anything but Channel and _stdin_ the out are input to the channel, they cannot be anything but Channel and _stdout_ or _null_

Parameters:
list - the list of the port to register
Callp - if true, this is a call, else this is a transformation

registerChannelOut

public void registerChannelOut(PortList list,
                               boolean Callp)
Register a channel with its output The algorithm depends on the context (transformation or call) If we are in a Transformation: the in are input for the channel, they cannot be anything but Channel the out are output for the channel, they cannot be anything but Channel If we are in a Call: the in are output to the channel, they cannot be anything but Channel and _stdin_ the out are input to the channel, they cannot be anything but Channel and _stdout_ or _null_

Parameters:
list - the list of the port to register
Callp - if true, this is a call, else this is a transformation

AnalysePortNames

public static java.lang.String[] AnalysePortNames(java.lang.String pListe)
Analyzes the port Name attributes "a b c" will be translate to {"a","b","c"}

Parameters:
pList - the list of ports names
Returns:
String[] contains the names of the ports or null if pList is null

cleanStack

protected void cleanStack()
Resets the parameters as they were after taking care of a Call


listAttribute

public java.lang.String listAttribute(org.xml.sax.Attributes atts)
Returns a XML-attribute string from the result of such a string

Parameters:
atts - attributes to transform
Returns:
String a string (in XML format) which contains the attributes

INRIA & FluxMedia

..no bottom yet...