Subversion Repositories XServices

Rev

Rev 94 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 94 Rev 113
Line 1... Line 1...
1
package net.brutex.xservices.util;
1
/*    */ package net.brutex.xservices.util;
-
 
2
/*    */ 
-
 
3
/*    */ import java.io.BufferedReader;
-
 
4
/*    */ import java.io.File;
-
 
5
/*    */ import java.io.FileReader;
-
 
6
/*    */ import java.io.IOException;
-
 
7
/*    */ import java.io.PrintStream;
-
 
8
/*    */ 
-
 
9
/*    */ public class CVSRoot
-
 
10
/*    */ {
-
 
11
/*    */   public String connectionType;
-
 
12
/*    */   public String user;
-
 
13
/*    */   public String host;
-
 
14
/*    */   public String repository;
-
 
15
/*    */ 
-
 
16
/*    */   public CVSRoot(String root)
-
 
17
/*    */     throws IllegalArgumentException
-
 
18
/*    */   {
-
 
19
/* 19 */     if (!root.startsWith(":")) {
-
 
20
/* 20 */       throw new IllegalArgumentException();
-
 
21
/*    */     }
-
 
22
/* 22 */     int oldColonPosition = 0;
-
 
23
/* 23 */     int colonPosition = root.indexOf(':', 1);
-
 
24
/* 24 */     if (colonPosition == -1)
-
 
25
/* 25 */       throw new IllegalArgumentException();
-
 
26
/* 26 */     this.connectionType = root.substring(oldColonPosition + 1, colonPosition);
-
 
27
/* 27 */     oldColonPosition = colonPosition;
-
 
28
/* 28 */     colonPosition = root.indexOf('@', colonPosition + 1);
-
 
29
/* 29 */     if (colonPosition == -1)
-
 
30
/* 30 */       throw new IllegalArgumentException();
-
 
31
/* 31 */     this.user = root.substring(oldColonPosition + 1, colonPosition);
-
 
32
/* 32 */     oldColonPosition = colonPosition;
-
 
33
/* 33 */     colonPosition = root.indexOf(':', colonPosition + 1);
-
 
34
/* 34 */     if (colonPosition == -1)
-
 
35
/* 35 */       throw new IllegalArgumentException();
-
 
36
/* 36 */     this.host = root.substring(oldColonPosition + 1, colonPosition);
-
 
37
/* 37 */     this.repository = root.substring(colonPosition + 1);
-
 
38
/* 38 */     if ((this.connectionType == null) || (this.user == null) || (this.host == null) || 
-
 
39
/* 39 */       (this.repository == null))
-
 
40
/* 40 */       throw new IllegalArgumentException();
-
 
41
/*    */   }
-
 
42
/*    */ 
-
 
43
/*    */   public String getCVSRoot(File directory) {
-
 
44
/* 44 */     String root = null;
-
 
45
/* 45 */     BufferedReader r = null;
-
 
46
/*    */     try {
-
 
47
/* 47 */       File rootFile = new File(directory, "CVS/Root");
-
 
48
/* 48 */       if (rootFile.exists()) {
-
 
49
/* 49 */         r = new BufferedReader(new FileReader(rootFile));
-
 
50
/* 50 */         root = r.readLine();
-
 
51
/*    */       }
-
 
52
/*    */     }
-
 
53
/*    */     catch (IOException localIOException1)
-
 
54
/*    */     {
-
 
55
/*    */       try {
-
 
56
/* 56 */         if (r != null)
-
 
57
/* 57 */           r.close();
-
 
58
/*    */       } catch (IOException e) {
-
 
59
/* 59 */         System.err.println("Warning: could not close CVS/Root file!");
-
 
60
/*    */       }
-
 
61
/*    */     }
-
 
62
/*    */     finally
-
 
63
/*    */     {
-
 
64
/*    */       try
-
 
65
/*    */       {
-
 
66
/* 56 */         if (r != null)
-
 
67
/* 57 */           r.close();
-
 
68
/*    */       } catch (IOException e) {
-
 
69
/* 59 */         System.err.println("Warning: could not close CVS/Root file!");
-
 
70
/*    */       }
-
 
71
/*    */     }
-
 
72
/* 62 */     if (root == null) {
-
 
73
/* 63 */       root = System.getProperty("cvs.root");
-
 
74
/*    */     }
-
 
75
/* 65 */     return root;
-
 
76
/*    */   }
-
 
77
/*    */ }
Line 2... Line -...
2
 
-
 
3
import java.io.BufferedReader;
-
 
4
import java.io.File;
-
 
5
import java.io.FileReader;
-
 
6
import java.io.IOException;
-
 
7
 
-
 
8
/**
-
 
9
 * A struct containing the various bits of information in a CVS root string,
-
 
10
 * allowing easy retrieval of individual items of information
-
 
11
 */
-
 
12
public class CVSRoot {
-
 
13
	public String connectionType;
-
 
14
	public String user;
-
 
15
	public String host;
-
 
16
	public String repository;
-
 
17
 
-
 
18
	public CVSRoot(String root) throws IllegalArgumentException {
-
 
19
		if (!root.startsWith(":"))
-
 
20
			throw new IllegalArgumentException();
-
 
21
 
-
 
22
		int oldColonPosition = 0;
-
 
23
		int colonPosition = root.indexOf(':', 1);
-
 
24
		if (colonPosition == -1)
-
 
25
			throw new IllegalArgumentException();
-
 
26
		connectionType = root.substring(oldColonPosition + 1, colonPosition);
-
 
27
		oldColonPosition = colonPosition;
-
 
28
		colonPosition = root.indexOf('@', colonPosition + 1);
-
 
29
		if (colonPosition == -1)
-
 
30
			throw new IllegalArgumentException();
-
 
31
		user = root.substring(oldColonPosition + 1, colonPosition);
-
 
32
		oldColonPosition = colonPosition;
-
 
33
		colonPosition = root.indexOf(':', colonPosition + 1);
-
 
34
		if (colonPosition == -1)
-
 
35
			throw new IllegalArgumentException();
-
 
36
		host = root.substring(oldColonPosition + 1, colonPosition);
-
 
37
		repository = root.substring(colonPosition + 1);
-
 
38
		if (connectionType == null || user == null || host == null
-
 
39
				|| repository == null)
-
 
40
			throw new IllegalArgumentException();
-
 
41
	}
-
 
42
 
-
 
43
	public String getCVSRoot(File directory) {
-
 
44
		String root = null;
-
 
45
		BufferedReader r = null;
-
 
46
		try {
-
 
47
			File rootFile = new File(directory, "CVS/Root");
-
 
48
			if (rootFile.exists()) {
-
 
49
				r = new BufferedReader(new FileReader(rootFile));
-
 
50
				root = r.readLine();
-
 
51
			}
-
 
52
		} catch (IOException e) {
-
 
53
			// ignore
-
 
54
		} finally {
-
 
55
			try {
-
 
56
				if (r != null)
-
 
57
					r.close();
-
 
58
			} catch (IOException e) {
-
 
59
				System.err.println("Warning: could not close CVS/Root file!");
-
 
60
			}
-
 
61
		}
-
 
62
		if (root == null) {
-
 
63
			root = System.getProperty("cvs.root");
-
 
64
		}
-
 
65
		return root;
-
 
66
	}
-
 
67
}
78
 
-
 
79
/* Location:           C:\Users\brosenberger\Documents\My Box Files\XBridgeNG-download\XServices-20130131 - Kopie\WEB-INF\classes\net.zip
-
 
80
 * Qualified Name:     net.brutex.xservices.util.CVSRoot
-
 
81
 * JD-Core Version:    0.6.2
-
 
82
 */
68
 
83