com.evelopers.unimod.transform.xml
Class XMLToModel

java.lang.Object
  extended bycom.evelopers.unimod.transform.xml.XMLToModel
All Implemented Interfaces:
org.xml.sax.ErrorHandler, XML

public class XMLToModel
extends java.lang.Object
implements XML, org.xml.sax.ErrorHandler


Nested Class Summary
 
Nested classes inherited from class com.evelopers.unimod.transform.xml.XML
XML.Attribute, XML.Path, XML.Tag
 
Field Summary
protected  StateMachine currentMachine
           
protected  Model model
           
protected  java.util.Map unresolvedMachines
           
 
Fields inherited from interface com.evelopers.unimod.transform.xml.XML
DTD_RESOURCE, PUBLIC_ID, SYSTEM_ID
 
Constructor Summary
protected XMLToModel()
           
 
Method Summary
protected  Model _transform(java.io.InputStream xml)
           
protected  Model _transform(java.io.InputStream xml, org.xml.sax.XMLReader xmlReader)
           
static XMLToModel create()
           
protected  Model createModel(java.lang.String name)
           
protected  StateMachine createStateMachine(java.lang.String name)
           
 void error(org.xml.sax.SAXParseException exception)
           
 void fatalError(org.xml.sax.SAXParseException exception)
           
static Model load(java.io.InputStream is)
          Build in-memory model from given xml file.
static Model load(java.io.InputStream is, org.xml.sax.XMLReader xmlReader)
          Build in-memory model from given xml file.
static Model loadAndCompile(java.io.InputStream is)
          Read model from given URL and compiles it.
static Model loadAndCompile(java.io.InputStream is, org.xml.sax.XMLReader xmlReader)
          Read model from given URL and compiles it.
protected  ClassElement resolveClassElement(java.lang.String name)
           
protected  StateMachine resolveStateMachine(java.lang.String name)
           
 Model transform(java.io.InputStream source)
           
 Model transform(java.io.InputStream source, org.xml.sax.XMLReader xmlReader)
           
 void warning(org.xml.sax.SAXParseException exception)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

unresolvedMachines

protected java.util.Map unresolvedMachines

model

protected Model model

currentMachine

protected StateMachine currentMachine
Constructor Detail

XMLToModel

protected XMLToModel()
Method Detail

create

public static XMLToModel create()

transform

public Model transform(java.io.InputStream source)
                throws TransformException
Throws:
TransformException

transform

public Model transform(java.io.InputStream source,
                       org.xml.sax.XMLReader xmlReader)
                throws TransformException
Throws:
TransformException

_transform

protected Model _transform(java.io.InputStream xml)
                    throws TransformException
Throws:
TransformException

_transform

protected Model _transform(java.io.InputStream xml,
                           org.xml.sax.XMLReader xmlReader)
                    throws TransformException
Throws:
TransformException

error

public void error(org.xml.sax.SAXParseException exception)
           throws org.xml.sax.SAXException
Specified by:
error in interface org.xml.sax.ErrorHandler
Throws:
org.xml.sax.SAXException

fatalError

public void fatalError(org.xml.sax.SAXParseException exception)
                throws org.xml.sax.SAXException
Specified by:
fatalError in interface org.xml.sax.ErrorHandler
Throws:
org.xml.sax.SAXException

warning

public void warning(org.xml.sax.SAXParseException exception)
             throws org.xml.sax.SAXException
Specified by:
warning in interface org.xml.sax.ErrorHandler
Throws:
org.xml.sax.SAXException

createModel

protected Model createModel(java.lang.String name)

resolveClassElement

protected ClassElement resolveClassElement(java.lang.String name)

resolveStateMachine

protected StateMachine resolveStateMachine(java.lang.String name)

createStateMachine

protected StateMachine createStateMachine(java.lang.String name)

load

public static Model load(java.io.InputStream is)
                  throws TransformException
Build in-memory model from given xml file. Do not forget to compile model before use:
   StateMachineCompiler c = new StateMachineCompiler(null);
   DefaultCompilationListener cl = new DefaultCompilationListener();
   c.addCompilationListener(cl);
   c.compileWithIncluded(model.getRootStateMachine());
 
   String[] errors = cl.getErrors();
   if (errors.length > 0) {
       for (int i = 0; i < errors.length; i++) {
           System.out.println(errors[i]);
       }
 
       return;
   }
 

Parameters:
is -
Returns:
Throws:
TransformException

loadAndCompile

public static Model loadAndCompile(java.io.InputStream is,
                                   org.xml.sax.XMLReader xmlReader)
                            throws java.io.IOException,
                                   TransformException
Read model from given URL and compiles it.

Parameters:
is - input stream with automata model
xmlReader - explicit XMLReader
Returns:
read and compiled model
Throws:
java.io.IOException - if an I/O exception occurs.
TransformException - if given resource couldn't be transformed

loadAndCompile

public static Model loadAndCompile(java.io.InputStream is)
                            throws java.io.IOException,
                                   TransformException
Read model from given URL and compiles it.

Parameters:
is - input stream with automata model
Returns:
read and compiled model
Throws:
java.io.IOException - if an I/O exception occurs.
TransformException - if given resource couldn't be transformed

load

public static Model load(java.io.InputStream is,
                         org.xml.sax.XMLReader xmlReader)
                  throws TransformException
Build in-memory model from given xml file. Do not forget to compile model before use:
 StateMachineCompiler c = new StateMachineCompiler(null);
 DefaultCompilationListener cl = new DefaultCompilationListener();
 c.addCompilationListener(cl);
 c.compileWithIncluded(model.getRootStateMachine());
 
 String[] errors = cl.getErrors();
 if (errors.length > 0) {
     for (int i = 0; i < errors.length; i++) {
         System.out.println(errors[i]);
     }
 
     return;
 }
 

Parameters:
is -
Returns:
Throws:
TransformException