| | |
| | | import org.w3c.dom.Document; |
| | | import org.w3c.dom.Node; |
| | | import org.w3c.dom.NodeList; |
| | | import org.xml.sax.SAXException; |
| | | import org.yeshi.utils.generater.GeneraterManagerV2; |
| | | import org.yeshi.utils.generater.annotation.admin.DaoQueryCondition; |
| | | import org.yeshi.utils.generater.annotation.admin.Show; |
| | |
| | | |
| | | import javax.xml.parsers.DocumentBuilder; |
| | | import javax.xml.parsers.DocumentBuilderFactory; |
| | | import javax.xml.parsers.ParserConfigurationException; |
| | | import java.io.*; |
| | | import java.io.FileInputStream; |
| | | import java.io.FileNotFoundException; |
| | | import java.io.InputStream; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | |
| | | */ |
| | | public class XmlConfigParseUtil { |
| | | |
| | | public static GenertorConfig parse(InputStream inputStream) throws IOException, ParserConfigurationException, SAXException, ClassNotFoundException { |
| | | public static GenertorConfig parse(InputStream inputStream) throws Exception { |
| | | if (inputStream == null) { |
| | | throw new FileNotFoundException(); |
| | | } |
| | |
| | | DocumentBuilder builder = factory.newDocumentBuilder(); |
| | | Document root = builder.parse(inputStream); |
| | | NodeList nodelist = root.getElementsByTagName("generator-config"); |
| | | if (nodelist.getLength() == 0) { |
| | | throw new Exception("xml格式错误"); |
| | | } |
| | | Node rootNode = nodelist.item(0); |
| | | String clazz = rootNode.getAttributes().getNamedItem("class").getNodeValue(); |
| | | genertorConfig.setEntity(Class.forName(clazz)); |