View Javadoc

1   package net.sf.statsvn.util;
2   
3   import java.io.IOException;
4   import java.io.InputStream;
5   
6   import net.sf.statcvs.input.LogSyntaxException;
7   
8   /**
9    * Performs svn info queries.
10   *  
11   * @author jkealey
12   *
13   */
14  public interface ISvnInfoProcessor {
15  
16      /**
17       * Converts an absolute path in the repository to a path relative to the
18       * working folder root.
19       * 
20       * Will return null if absolute path does not start with getModuleName();
21       * 
22       * @param absolute
23       *            Example (assume getModuleName() returns /trunk/statsvn)
24       *            /trunk/statsvn/package.html
25       * @return Example: package.html
26       */
27      public abstract String absoluteToRelativePath(String absolute);
28  
29      /**
30       * Converts an absolute path in the repository to a URL, using the
31       * repository URL
32       * 
33       * @param absolute
34       *            Example: /trunk/statsvn/package.html
35       * @return Example: svn://svn.statsvn.org/statsvn/trunk/statsvn/package.html
36       */
37      public abstract String absolutePathToUrl(final String absolute);
38  
39      /**
40       * Converts a relative path in the working folder to a URL, using the
41       * working folder's root URL
42       * 
43       * @param relative
44       *            Example: src/Messages.java
45       * @return Example:
46       *         svn://svn.statsvn.org/statsvn/trunk/statsvn/src/Messages.java
47       * 
48       */
49      public abstract String relativePathToUrl(String relative);
50  
51      /**
52       * Converts a relative path in the working folder to an absolute path in the
53       * repository.
54       * 
55       * @param relative
56       *            Example: src/Messages.java
57       * @return Example: /trunk/statsvn/src/Messages.java
58       * 
59       */
60      public abstract String relativeToAbsolutePath(final String relative);
61  
62      /**
63       * Returns true if the file exists in the working copy (according to the svn
64       * metadata, and not file system checks).
65       * 
66       * @param relativePath
67       *            the path
68       * @return <tt>true</tt> if it exists
69       */
70      public abstract boolean existsInWorkingCopy(final String relativePath);
71  
72      /**
73       * Assumes #loadInfo(String) has been called. Never ends with /, might be
74       * empty.
75       * 
76       * @return The absolute path of the root of the working folder in the
77       *         repository.
78       */
79      public abstract String getModuleName();
80  
81      /**
82       * Returns the revision number of the file in the working copy.
83       * 
84       * @param relativePath
85       *            the filename
86       * @return the revision number if it exists in the working copy, null
87       *         otherwise.
88       */
89      public abstract String getRevisionNumber(final String relativePath);
90  
91      /**
92       * Assumes #loadInfo() has been invoked.
93       * 
94       * @return the root of the working folder's revision number (last checked
95       *         out revision number)
96       */
97      public abstract String getRootRevisionNumber();
98  
99      /**
100      * Assumes #loadInfo() has been invoked.
101      * 
102      * @return the root of the working folder's url (example:
103      *         svn://svn.statsvn.org/statsvn/trunk/statsvn)
104      */
105     public abstract String getRootUrl();
106 
107     /**
108      * Assumes #loadInfo() has been invoked.
109      * 
110      * @return the uuid of the repository
111      */
112     public abstract String getRepositoryUuid();
113 
114     /**
115      * Assumes #loadInfo() has been invoked.
116      * 
117      * @return the repository url (example: svn://svn.statsvn.org/statsvn)
118      */
119     public abstract String getRepositoryUrl();
120 
121     /**
122      * Returns true if the path has been identified as a directory.
123      * 
124      * @param relativePath
125      *            the path
126      * @return true if it is a known directory.
127      */
128     public abstract boolean isDirectory(final String relativePath);
129 
130     /**
131      * Adds a directory to the list of known directories. Used when inferring
132      * implicit actions on deleted paths.
133      * 
134      * @param relativePath
135      *            the relative path.
136      */
137     public abstract void addDirectory(final String relativePath);
138 
139     /**
140      * Loads the information from svn info if needed.
141      * 
142      * @param stream
143      *            the input stream representing 
144      *            an svn info command.
145      * @throws LogSyntaxException
146      *             if the format of the svn info is invalid
147      * @throws IOException
148      *             if we can't read from the response stream.
149      */
150     public abstract void loadInfo(final InputStream stream) throws LogSyntaxException, IOException;
151 
152     /**
153      * Initializes our representation of the repository.
154      * 
155      * @throws LogSyntaxException
156      *             if the svn info --xml is malformed
157      * @throws IOException
158      *             if there is an error reading from the stream
159      */
160     public abstract void loadInfo() throws LogSyntaxException, IOException;
161 
162     /**
163      * Converts a url to an absolute path in the repository.
164      * 
165      * @param url
166      *            Examples: svn://svn.statsvn.org/statsvn/trunk/statsvn,
167      *            svn://svn.statsvn.org/statsvn/trunk/statsvn/package.html
168      * @return Example: /trunk/statsvn, /trunk/statsvn/package.html
169      */
170     public abstract String urlToAbsolutePath(String url);
171 
172     /**
173      * Converts a url to a relative path in the repository.
174      * 
175      * @param url
176      *            Examples: svn://svn.statsvn.org/statsvn/trunk/statsvn,
177      *            svn://svn.statsvn.org/statsvn/trunk/statsvn/package.html
178      * @return Example: ".", package.html
179      */
180     public abstract String urlToRelativePath(final String url);
181 
182     
183     /**
184      * Verifies that the "svn info" command can return the repository root
185      * (info available in svn >= 1.3.0)
186      * 
187      * @throws SvnVersionMismatchException
188      *             if <tt>svn info</tt> failed to provide a non-empty repository root
189      */
190     public abstract void checkRepoRootAvailable() throws SvnVersionMismatchException ;
191 }