📄 instancebinding.java
字号:
/* * InstanceBinding.java * * Created on 2004年12月22日, 下午4:20 */package workflow.xwfbox.engine;import org.exolab.castor.mapping.*;import org.exolab.castor.xml.*;import java.io.*;/** * * @author Administrator */public class InstanceBinding { /** Creates a new instance of InstanceBinding */ public InstanceBinding() { } public static Object getXMLInfo(String inXMLFile, String bindMapping) { Object read = null; try { // write it out as XML (if not already present) Mapping map = new Mapping(); map.loadMapping(bindMapping); File inFile = new File(inXMLFile); if (inFile.exists()) { // now restore the value and list what we get Reader reader = new FileReader(inFile); Unmarshaller unmarshaller = new Unmarshaller(map); unmarshaller.setIgnoreExtraElements(true); read = unmarshaller.unmarshal(reader); } } catch (IOException ex) { ex.printStackTrace(System.err); } catch (MappingException ex) { ex.printStackTrace(System.err); } catch (MarshalException ex) { ex.printStackTrace(System.err); } catch (ValidationException ex) { ex.printStackTrace(System.err); } return read; } public static int putXMLInfo(Object xmlObj, String outXML, String bindMapping) { int ret = 0; try { // write it out as XML (if not already present) Mapping map = new Mapping(); map.loadMapping(bindMapping); String encoding = "gb2312"; FileOutputStream outFile = new FileOutputStream(outXML); OutputStreamWriter writer = new OutputStreamWriter(outFile,encoding); Marshaller marshaller = new Marshaller(writer); marshaller.setEncoding(encoding); marshaller.setMapping(map); marshaller.marshal(xmlObj); } catch (IOException ex) { ex.printStackTrace(System.err);ret = 1; } catch (MappingException ex) { ex.printStackTrace(System.err);ret = 2; } catch (MarshalException ex) { ex.printStackTrace(System.err);ret = 3; } catch (ValidationException ex) { ex.printStackTrace(System.err);ret = 4; } return ret; } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -