1 6 7 package net.sourceforge.cvsgrab.web; 8 9 import net.sourceforge.cvsgrab.CVSGrab; 10 import net.sourceforge.cvsgrab.InvalidVersionException; 11 import net.sourceforge.cvsgrab.MarkerNotFoundException; 12 13 import org.apache.commons.jxpath.JXPathContext; 14 import org.w3c.dom.Document ; 15 16 25 public class Sourcecast1_0Interface extends CvsWeb2_0Interface { 26 27 30 public Sourcecast1_0Interface(CVSGrab grabber) { 31 super(grabber); 32 33 setFilesXpath("//TR[TD/A/A/IMG/@alt = '[TXT]']"); 34 setDirectoriesXpath("//TR[TD/A/A/IMG/@alt = '[DIR]'][TD/A/@name != 'Attic']"); 35 setWebInterfaceType("browse"); 36 } 37 38 44 public void detect(Document htmlPage) throws MarkerNotFoundException, InvalidVersionException { 45 JXPathContext context = JXPathContext.newContext(htmlPage); 46 context.setLenient(true); 47 48 String version = (String ) context.getValue("//META[@name = 'SOURCECAST-VERSION']/@content"); 50 if (version == null) { 51 throw new MarkerNotFoundException(); 52 } 53 if (!version.startsWith("1.")) { 54 throw new InvalidVersionException("Invalid version " + version); 55 } 56 setType("SourceCast " + version); 57 } 58 59 } 60 | Popular Tags |