Subversion Repositories XServices

Compare Revisions

Ignore whitespace Rev 94 → Rev 165

/xservices/trunk/src/java/net/brutex/xservices/util/CVSRoot.java
1,67 → 1,82
package net.brutex.xservices.util;
/* */ package net.brutex.xservices.util;
/* */
/* */ import java.io.BufferedReader;
/* */ import java.io.File;
/* */ import java.io.FileReader;
/* */ import java.io.IOException;
/* */ import java.io.PrintStream;
/* */
/* */ public class CVSRoot
/* */ {
/* */ public String connectionType;
/* */ public String user;
/* */ public String host;
/* */ public String repository;
/* */
/* */ public CVSRoot(String root)
/* */ throws IllegalArgumentException
/* */ {
/* 19 */ if (!root.startsWith(":")) {
/* 20 */ throw new IllegalArgumentException();
/* */ }
/* 22 */ int oldColonPosition = 0;
/* 23 */ int colonPosition = root.indexOf(':', 1);
/* 24 */ if (colonPosition == -1)
/* 25 */ throw new IllegalArgumentException();
/* 26 */ this.connectionType = root.substring(oldColonPosition + 1, colonPosition);
/* 27 */ oldColonPosition = colonPosition;
/* 28 */ colonPosition = root.indexOf('@', colonPosition + 1);
/* 29 */ if (colonPosition == -1)
/* 30 */ throw new IllegalArgumentException();
/* 31 */ this.user = root.substring(oldColonPosition + 1, colonPosition);
/* 32 */ oldColonPosition = colonPosition;
/* 33 */ colonPosition = root.indexOf(':', colonPosition + 1);
/* 34 */ if (colonPosition == -1)
/* 35 */ throw new IllegalArgumentException();
/* 36 */ this.host = root.substring(oldColonPosition + 1, colonPosition);
/* 37 */ this.repository = root.substring(colonPosition + 1);
/* 38 */ if ((this.connectionType == null) || (this.user == null) || (this.host == null) ||
/* 39 */ (this.repository == null))
/* 40 */ throw new IllegalArgumentException();
/* */ }
/* */
/* */ public String getCVSRoot(File directory) {
/* 44 */ String root = null;
/* 45 */ BufferedReader r = null;
/* */ try {
/* 47 */ File rootFile = new File(directory, "CVS/Root");
/* 48 */ if (rootFile.exists()) {
/* 49 */ r = new BufferedReader(new FileReader(rootFile));
/* 50 */ root = r.readLine();
/* */ }
/* */ }
/* */ catch (IOException localIOException1)
/* */ {
/* */ try {
/* 56 */ if (r != null)
/* 57 */ r.close();
/* */ } catch (IOException e) {
/* 59 */ System.err.println("Warning: could not close CVS/Root file!");
/* */ }
/* */ }
/* */ finally
/* */ {
/* */ try
/* */ {
/* 56 */ if (r != null)
/* 57 */ r.close();
/* */ } catch (IOException e) {
/* 59 */ System.err.println("Warning: could not close CVS/Root file!");
/* */ }
/* */ }
/* 62 */ if (root == null) {
/* 63 */ root = System.getProperty("cvs.root");
/* */ }
/* 65 */ return root;
/* */ }
/* */ }
 
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
 
/**
* A struct containing the various bits of information in a CVS root string,
* allowing easy retrieval of individual items of information
*/
public class CVSRoot {
public String connectionType;
public String user;
public String host;
public String repository;
 
public CVSRoot(String root) throws IllegalArgumentException {
if (!root.startsWith(":"))
throw new IllegalArgumentException();
 
int oldColonPosition = 0;
int colonPosition = root.indexOf(':', 1);
if (colonPosition == -1)
throw new IllegalArgumentException();
connectionType = root.substring(oldColonPosition + 1, colonPosition);
oldColonPosition = colonPosition;
colonPosition = root.indexOf('@', colonPosition + 1);
if (colonPosition == -1)
throw new IllegalArgumentException();
user = root.substring(oldColonPosition + 1, colonPosition);
oldColonPosition = colonPosition;
colonPosition = root.indexOf(':', colonPosition + 1);
if (colonPosition == -1)
throw new IllegalArgumentException();
host = root.substring(oldColonPosition + 1, colonPosition);
repository = root.substring(colonPosition + 1);
if (connectionType == null || user == null || host == null
|| repository == null)
throw new IllegalArgumentException();
}
 
public String getCVSRoot(File directory) {
String root = null;
BufferedReader r = null;
try {
File rootFile = new File(directory, "CVS/Root");
if (rootFile.exists()) {
r = new BufferedReader(new FileReader(rootFile));
root = r.readLine();
}
} catch (IOException e) {
// ignore
} finally {
try {
if (r != null)
r.close();
} catch (IOException e) {
System.err.println("Warning: could not close CVS/Root file!");
}
}
if (root == null) {
root = System.getProperty("cvs.root");
}
return root;
}
}
/* Location: C:\Users\brosenberger\Documents\My Box Files\XBridgeNG-download\XServices-20130131 - Kopie\WEB-INF\classes\net.zip
* Qualified Name: net.brutex.xservices.util.CVSRoot
* JD-Core Version: 0.6.2
*/