snaker-core/src/main/java/org/snaker/engine/parser/ModelParser.java
public static ProcessModel parse(byte[] bytes) {
		DocumentBuilder documentBuilder = XmlHelper.createDocumentBuilder();
		if(documentBuilder != null) {
			Document doc = null;
			try {
				doc = documentBuilder.parse(new ByteArrayInputStream(bytes));
				Element processE = doc.getDocumentElement();
				ProcessModel process = new ProcessModel();
				process.setName(processE.getAttribute(NodeParser.ATTR_NAME));
				process.setDisplayName(processE.getAttribute(NodeParser.ATTR_DISPLAYNAME));
				process.setExpireTime(processE.getAttribute(NodeParser.ATTR_EXPIRETIME));
				process.setInstanceUrl(processE.getAttribute(NodeParser.ATTR_INSTANCEURL));
				process.setInstanceNoClass(processE.getAttribute(NodeParser.ATTR_INSTANCENOCLASS));
				NodeList nodeList = processE.getChildNodes();
				int nodeSize = nodeList.getLength();
				for(int i = 0; i < nodeSize; i++) {
					Node node = nodeList.item(i);
					if (node.getNodeType() == Node.ELEMENT_NODE) {
						NodeModel model = parseModel(node);
						process.getNodes().add(model);
					}
				}
				
				//循环节点模型，构造变迁输入、输出的source、target
				for(NodeModel node : process.getNodes()) {
					for(TransitionModel transition : node.getOutputs()) {
						String to = transition.getTo();
						for(NodeModel node2 : process.getNodes()) {
							if(to.equalsIgnoreCase(node2.getName())) {
								node2.getInputs().add(transition);
								transition.setTarget(node2);
							}
						}
					}
				}
				return process;
			} catch (SAXException e) {
				e.printStackTrace();
				throw new SnakerException(e);
			} catch (IOException e) {
				throw new SnakerException(e);
			}
		} else {
			throw new SnakerException("documentBuilder is null");
		}
	}
public static ProcessModel parse(byte[] bytes) {
		DocumentBuilder documentBuilder = XmlHelper.createDocumentBuilder();
		if(documentBuilder != null) {
			Document doc = null;
			try {
				doc = documentBuilder.parse(new ByteArrayInputStream(bytes));
				Element processE = doc.getDocumentElement();
				ProcessModel process = new ProcessModel();
				process.setName(processE.getAttribute(NodeParser.ATTR_NAME));
				process.setDisplayName(processE.getAttribute(NodeParser.ATTR_DISPLAYNAME));
				process.setExpireTime(processE.getAttribute(NodeParser.ATTR_EXPIRETIME));
				process.setInstanceUrl(processE.getAttribute(NodeParser.ATTR_INSTANCEURL));
				process.setInstanceNoClass(processE.getAttribute(NodeParser.ATTR_INSTANCENOCLASS));
				NodeList nodeList = processE.getChildNodes();
				int nodeSize = nodeList.getLength();
				for(int i = 0; i < nodeSize; i++) {
					Node node = nodeList.item(i);
					if (node.getNodeType() == Node.ELEMENT_NODE) {
						NodeModel model = parseModel(node);
						process.getNodes().add(model);
					}
				}
				
				//循环节点模型，构造变迁输入、输出的source、target
				for(NodeModel node : process.getNodes()) {
					for(TransitionModel transition : node.getOutputs()) {
						String to = transition.getTo();
						for(NodeModel node2 : process.getNodes()) {
							if(to.equalsIgnoreCase(node2.getName())) {
								node2.getInputs().add(transition);
								transition.setTarget(node2);
							}
						}
					}
				}
				return process;
			} catch (SAXException e) {
				e.printStackTrace();
				throw new SnakerException(e);
			} catch (IOException e) {
				throw new SnakerException(e);
			}
		} else {
			throw new SnakerException("documentBuilder is null");
		}
	}
public static ProcessModel parse ( byte [ ] bytes ) { DocumentBuilder documentBuilder = XmlHelper . createDocumentBuilder ( ) ; if ( documentBuilder != null ) { Document doc = null ; try { doc = documentBuilder . parse ( new ByteArrayInputStream ( bytes ) ) ; Element processE = doc . getDocumentElement ( ) ; ProcessModel process = new ProcessModel ( ) ; process . setName ( processE . getAttribute ( NodeParser . ATTR_NAME ) ) ; process . setDisplayName ( processE . getAttribute ( NodeParser . ATTR_DISPLAYNAME ) ) ; process . setExpireTime ( processE . getAttribute ( NodeParser . ATTR_EXPIRETIME ) ) ; process . setInstanceUrl ( processE . getAttribute ( NodeParser . ATTR_INSTANCEURL ) ) ; process . setInstanceNoClass ( processE . getAttribute ( NodeParser . ATTR_INSTANCENOCLASS ) ) ; NodeList nodeList = processE . getChildNodes ( ) ; int nodeSize = nodeList . getLength ( ) ; for ( int i = 0 ; i < nodeSize ; i ++ ) { Node node = nodeList . item ( i ) ; if ( node . getNodeType ( ) == Node . ELEMENT_NODE ) { NodeModel model = parseModel ( node ) ; process . getNodes ( ) . add ( model ) ; } } //循环节点模型，构造变迁输入、输出的source、target for ( NodeModel node : process . getNodes ( ) ) { for ( TransitionModel transition : node . getOutputs ( ) ) { String to = transition . getTo ( ) ; for ( NodeModel node2 : process . getNodes ( ) ) { if ( to . equalsIgnoreCase ( node2 . getName ( ) ) ) { node2 . getInputs ( ) . add ( transition ) ; transition . setTarget ( node2 ) ; } } } } return process ; } catch ( SAXException e ) { e . printStackTrace ( ) ; throw new SnakerException ( e ) ; } catch ( IOException e ) { throw new SnakerException ( e ) ; } } else { throw new SnakerException ( "documentBuilder is null" ) ; } }
解析流程定义文件，并将解析后的对象放入模型容器中
@param bytes
解析流程定义文件，并将解析后的对象放入模型容器中