KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > subversion > client > parser > SvnWcUtils


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.subversion.client.parser;
20
21 import java.io.File JavaDoc;
22 import java.io.IOException JavaDoc;
23 import java.text.ParseException JavaDoc;
24 import java.text.SimpleDateFormat JavaDoc;
25 import java.util.Date JavaDoc;
26
27 import java.io.File JavaDoc;
28 import java.io.IOException JavaDoc;
29 import java.text.ParseException JavaDoc;
30 import java.text.SimpleDateFormat JavaDoc;
31 import java.util.Date JavaDoc;
32 import org.netbeans.modules.subversion.client.*;
33
34 /**
35  *
36  * @author Ed Hillmann
37  */

38 public class SvnWcUtils {
39
40     private static final String JavaDoc ENTRIES = "entries"; // NOI18N
41
public static final String JavaDoc[] ADMIN_DIR_NAMES = new String JavaDoc[] {".svn", "_svn" };
42
43     private static final String JavaDoc PROPS = "props";
44     private static final String JavaDoc PROPS_BASE = "prop-base";
45
46     private static final SimpleDateFormat JavaDoc dateFormat = new SimpleDateFormat JavaDoc("yyyy-MM-dd'T'HH:mm:ss.SSSSSS'Z'");
47         
48     public static File JavaDoc getSvnFile(File JavaDoc file, String JavaDoc svnFileName) throws IOException JavaDoc {
49         for (int i = 0; i < ADMIN_DIR_NAMES.length; i++) {
50             File JavaDoc svnFile = new File JavaDoc(file, ADMIN_DIR_NAMES[i] + "/" + svnFileName);
51             if(svnFile.canRead()) {
52                 return svnFile;
53             };
54         }
55         return null;
56     }
57     
58     public static File JavaDoc getPropertiesFile(File JavaDoc file, boolean base) throws IOException JavaDoc {
59
60         if(file.isFile()) {
61             if (base) {
62                 return getSvnFile(file.getParentFile(), PROPS_BASE + "/" + file.getName() + getPropFileNameSuffix(base));
63             } else {
64                 return getSvnFile(file.getParentFile(), PROPS + "/" + file.getName() + getPropFileNameSuffix(base));
65             }
66         } else {
67             return getSvnFile(file, base ? "/dir-prop-base" : "/dir-props");
68         }
69     }
70
71     private static String JavaDoc getPropFileNameSuffix(boolean base) {
72         if (base) {
73             return ".svn-base";
74         } else {
75             return ".svn-work";
76         }
77     }
78     
79     public static File JavaDoc getTextBaseFile(File JavaDoc file) throws IOException JavaDoc {
80         return getSvnFile(file.getParentFile(), "text-base/" + file.getName() + ".svn-base");
81     }
82
83     public static Date JavaDoc parseSvnDate(String JavaDoc inputValue) throws ParseException JavaDoc {
84         Date JavaDoc returnValue = null;
85         if (inputValue != null) {
86             returnValue = dateFormat.parse(inputValue);
87         }
88         return returnValue;
89     }
90
91     static File JavaDoc getEntriesFile(File JavaDoc file) throws IOException JavaDoc {
92         return getSvnFile(!file.isDirectory() ? file.getParentFile() : file, ENTRIES);
93     }
94     
95 }
96
Popular Tags