1 29 package net.sourceforge.groboutils.pmti.v1.autodoc.v1.xml; 30 31 32 import java.io.File ; 33 import java.io.Reader ; 34 import java.io.FileReader ; 35 import java.io.IOException ; 36 37 import java.net.URL ; 38 39 import net.sourceforge.groboutils.pmti.v1.itf.parser.AbstractParser; 40 import net.sourceforge.groboutils.pmti.v1.itf.IIssueRecord; 41 import net.sourceforge.groboutils.pmti.v1.itf.ITestIssueRecord; 42 43 import net.sourceforge.groboutils.pmti.v1.itf.impl.DefaultIssueRecord; 44 import net.sourceforge.groboutils.pmti.v1.itf.impl.ImmutableTestRecord; 45 import net.sourceforge.groboutils.pmti.v1.itf.impl.DefaultTestIssueRecord; 46 47 import java.util.Locale ; 48 49 import org.xml.sax.Locator ; 50 import org.xml.sax.InputSource ; 51 import org.xml.sax.HandlerBase ; 52 import org.xml.sax.SAXException ; 53 import org.xml.sax.SAXParseException ; 54 import org.xml.sax.DocumentHandler ; 55 import org.xml.sax.AttributeList ; 56 import org.xml.sax.helpers.XMLReaderAdapter ; 57 import org.xml.sax.Parser ; 58 59 import org.apache.log4j.Logger; 60 61 62 69 public class XMLFileParser extends AbstractParser 70 { 71 private static final Class THIS_CLASS = XMLFileParser.class; 72 private static final org.apache.log4j.Logger LOG = 73 org.apache.log4j.Logger.getLogger( THIS_CLASS ); 74 75 76 private File file; 77 private Parser parser; 78 79 80 public XMLFileParser( File f, Parser p ) 81 { 82 if ( f == null 83 || !f.exists() 84 || !f.isFile() 85 || !f.canRead() ) 86 { 87 throw new IllegalArgumentException ("not valid file: "+f); 88 } 89 if ( p == null ) 90 { 91 throw new IllegalArgumentException ("no null SAX parser"); 92 } 93 94 this.parser = p; 95 this.file = f; 96 } 97 98 99 protected void findRecords() 100 { 101 try 102 { 103 FileReader fr = new FileReader ( this.file ); 104 try 105 { 106 InputSource source = new InputSource ( fr ); 107 source.setSystemId( (new URL ( "file:" + 108 this.file.getAbsolutePath() )).toString() ); 109 } 110 finally 111 { 112 fr.close(); 113 } 114 } 115 catch (IOException ioe) 116 { 117 LOG.warn( "Error accessing file: "+this.file, ioe ); 118 } 119 } 120 121 122 } 124 125 | Popular Tags |