com.evelopers.unimod.transform.xml
Class XMLToModel
java.lang.Object
com.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
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
unresolvedMachines
protected java.util.Map unresolvedMachines
model
protected Model model
currentMachine
protected StateMachine currentMachine
XMLToModel
protected XMLToModel()
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 modelxmlReader
- 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