📄 xmlbeanreaderimpl.java
字号:
/**
* =============================================
* Copyright 2005 TransFar
*
* Change Revision
* --------------------------------
* Date Author Remarks
* 2006-3-10 YHuang Create class com.szmx.component.xml.rw.impl.XmlBeanReaderImpl
* =============================================
*/
package com.szmx.component.xml.rw.impl;
import com.szmx.component.xml.rw.XmlBeanReader;
import com.szmx.component.xml.rw.AbstractXmlBean;
import com.szmx.component.xml.rw.XmlBeanException;
import com.wutka.jox.JOXBeanInputStream;
import java.io.InputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* <TODO: Write a short description on the purpose of the program>
*
* @author YHuang
* @version 1.0
* @class com.szmx.component.xml.rw.impl.XmlBeanReaderImpl
* @since 2006-3-10
*/
public class XmlBeanReaderImpl implements XmlBeanReader {
private static Log log = LogFactory.getLog(XmlBeanReader.class);
public AbstractXmlBean parseXmlFile(Class clazz, String xmlPath) throws XmlBeanException {
FileInputStream in;
try {
in = new FileInputStream(xmlPath);
return parseXmlFile(clazz,in);
} catch (FileNotFoundException e) {
log.error("file not found " + e.getMessage());
throw new XmlBeanException("file not found " + e.getMessage());
}
}
public AbstractXmlBean parseXmlFile(Class clazz, InputStream inputStream) throws XmlBeanException {
try {
JOXBeanInputStream joxIn = new JOXBeanInputStream(inputStream);
return (AbstractXmlBean) joxIn.readObject(clazz);
} catch (IOException e) {
log.error("can't parse XML " + e.getMessage());
throw new XmlBeanException("can't parse XML " + e.getMessage());
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -