1 19 package org.netbeans.modules.subversion.client.parser; 20 21 import java.io.File ; 22 import java.io.IOException ; 23 import java.text.ParseException ; 24 import java.text.SimpleDateFormat ; 25 import java.util.Date ; 26 27 import java.io.File ; 28 import java.io.IOException ; 29 import java.text.ParseException ; 30 import java.text.SimpleDateFormat ; 31 import java.util.Date ; 32 import org.netbeans.modules.subversion.client.*; 33 34 38 public class SvnWcUtils { 39 40 private static final String ENTRIES = "entries"; public static final String [] ADMIN_DIR_NAMES = new String [] {".svn", "_svn" }; 42 43 private static final String PROPS = "props"; 44 private static final String PROPS_BASE = "prop-base"; 45 46 private static final SimpleDateFormat dateFormat = new SimpleDateFormat ("yyyy-MM-dd'T'HH:mm:ss.SSSSSS'Z'"); 47 48 public static File getSvnFile(File file, String svnFileName) throws IOException { 49 for (int i = 0; i < ADMIN_DIR_NAMES.length; i++) { 50 File svnFile = new File (file, ADMIN_DIR_NAMES[i] + "/" + svnFileName); 51 if(svnFile.canRead()) { 52 return svnFile; 53 }; 54 } 55 return null; 56 } 57 58 public static File getPropertiesFile(File file, boolean base) throws IOException { 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 getPropFileNameSuffix(boolean base) { 72 if (base) { 73 return ".svn-base"; 74 } else { 75 return ".svn-work"; 76 } 77 } 78 79 public static File getTextBaseFile(File file) throws IOException { 80 return getSvnFile(file.getParentFile(), "text-base/" + file.getName() + ".svn-base"); 81 } 82 83 public static Date parseSvnDate(String inputValue) throws ParseException { 84 Date returnValue = null; 85 if (inputValue != null) { 86 returnValue = dateFormat.parse(inputValue); 87 } 88 return returnValue; 89 } 90 91 static File getEntriesFile(File file) throws IOException { 92 return getSvnFile(!file.isDirectory() ? file.getParentFile() : file, ENTRIES); 93 } 94 95 } 96 | Popular Tags |