1 18 19 package org.objectweb.jac.core.parsers.xml; 20 21 import java.io.IOException ; 22 import java.io.InputStream ; 23 import java.util.List ; 24 import java.util.Set ; 25 import java.util.Vector ; 26 import org.apache.log4j.Logger; 27 import org.objectweb.jac.core.InputStreamParser; 28 import org.w3c.dom.Document ; 29 30 33 public class JacXmlParser implements InputStreamParser { 34 static Logger logger = Logger.getLogger("xml"); 35 36 private DefaultDocumentInterpreter documentInterpreter; 37 private XmlParser xmlParser; 38 39 42 public JacXmlParser() { 43 documentInterpreter = new DefaultDocumentInterpreter(); 44 documentInterpreter.setElementInterpreter(new ACElementInterpreter()); 45 xmlParser = new XmlParserJAXP(); 46 } 47 48 51 public List parse(InputStream input, String filePath, 52 String targetClassName, Set blockKeywords) 53 throws IOException 54 { 55 Vector vector = new Vector (); 56 try { 57 Document document = xmlParser.parse(input, false); 58 logger.debug("XML parsed "+filePath); 59 vector = documentInterpreter.interpret( 60 document, 61 Class.forName(targetClassName)); 62 } catch (Exception e) { 63 throw new IOException (e.getMessage()); 64 } 65 return vector; 66 } 67 } 68 | Popular Tags |