KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > cvsgrab > web > ViewCvs0_7Interface


1 /*
2  * CVSGrab
3  * Author: Ludovic Claude (ludovicc@users.sourceforge.net)
4  * Distributable under BSD license.
5  * See terms of license at gnu.org.
6  */

7 package net.sourceforge.cvsgrab.web;
8
9 import net.sourceforge.cvsgrab.CVSGrab;
10 import net.sourceforge.cvsgrab.RemoteFile;
11 import net.sourceforge.cvsgrab.WebBrowser;
12
13 import org.apache.commons.httpclient.URIException;
14 import org.apache.commons.jxpath.JXPathContext;
15
16
17 /**
18  * Support for ViewCvs 0.7 interfaces to a cvs repository
19  *
20  * @author <a HREF="mailto:ludovicc@users.sourceforge.net">Ludovic Claude</a>
21  * @version $Revision: 1.7 $ $Date: 2005/06/22 19:18:28 $
22  * @created on 11 oct. 2003
23  */

24 public class ViewCvs0_7Interface extends ViewCvsInterface {
25
26     /**
27      * Constructor for ViewCvs0_7Interface
28      */

29     public ViewCvs0_7Interface(CVSGrab grabber) {
30         super(grabber);
31         
32         setFilesXpath("//TR[TD//A/IMG/@alt = '[FILE_ICON]']");
33         setFileNameXpath("TD[1]/A/@name");
34         setDirectoriesXpath("//TR[TD//A/IMG/@alt = '[DIR_ICON]'][TD/A/@name != 'Attic']");
35         setDirectoryXpath("TD[1]/A/@name");
36         setCheckoutPath("~checkout~/");
37     }
38
39     /**
40      * @param rootUrl
41      * @param file
42      * @return
43      */

44     public String JavaDoc getDownloadUrl(String JavaDoc rootUrl, RemoteFile file) {
45         try {
46             // http://dev.eclipse.org/viewcvs/index.cgi/~checkout~/org.eclipse.ant.core/about.html?rev=1.20
47
String JavaDoc url = WebBrowser.forceFinalSlash(rootUrl);
48             String JavaDoc dir = file.getDirectory().getDirectoryPath();
49             url += getCheckoutPath();
50             url += WebBrowser.forceFinalSlash(quote(dir));
51             url += quote(file.getName());
52             url = WebBrowser.addQueryParam(url, "rev", quote(file.getVersion()));
53             url = WebBrowser.addQueryParam(url, getQueryParams());
54             return url;
55         } catch (URIException ex) {
56             ex.printStackTrace();
57             throw new RuntimeException JavaDoc("Cannot create URI");
58         }
59     }
60
61     protected String JavaDoc getVersionMarker() {
62         return "ViewCVS 0.7";
63     }
64
65     protected void adjustFile(RemoteFile file, JXPathContext nodeContext) {
66         super.adjustFile(file, nodeContext);
67         String JavaDoc href = (String JavaDoc) nodeContext.getValue("TD/A/@href");
68         if (href.startsWith("Attic/")) {
69             file.setInAttic(true);
70         }
71     }
72
73 }
74
Popular Tags