package com.perforce.common.asset; import java.io.FileNotFoundException; import java.io.RandomAccessFile; import java.util.List; import java.util.SortedMap; import java.util.TreeMap; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.perforce.common.client.P4Factory; public class TypeMap { private static Logger logger = LoggerFactory.getLogger(TypeMap.class); private static SortedMap<String, String> map = new TreeMap<String, String>(); public static boolean load(String filename) throws Exception { RandomAccessFile rf; try { rf = new RandomAccessFile(filename, "r"); String line = null; if (logger.isInfoEnabled()) { logger.info("loading TypeMap: \t" + filename); } while ((line = rf.readLine()) != null) { // ignore comments starting with '#' and add lines to table if (!line.startsWith("#")) { line = line.trim(); if (!line.isEmpty()) { if (line.contains("//....")) { String[] parts = line.split("\\s+"); String type = parts[0]; String ext = parts[1].replaceFirst("//....", ""); map.put(ext, type); if (logger.isTraceEnabled()) { logger.trace("... map: " + ext + "\t => " + type); } } else { if (logger.isTraceEnabled()) { logger.trace("ignoring line: " + line); } } } } } rf.close(); return true; } catch (FileNotFoundException e) { // no file, then return return false; } } public static List<ContentProperty> getContentProperty(String svnPath) { int pos = svnPath.lastIndexOf("."); String extention = svnPath.substring(pos + 1); String typemap = map.get(extention); List<ContentProperty> prop; prop = P4Factory.p4javaToContentProperty(typemap); if (logger.isTraceEnabled()) { logger.trace("getContentProperty: " + typemap + " " + prop.toString()); } return prop; } public static ContentType getContentType(String svnPath) { int pos = svnPath.lastIndexOf("."); String extention = svnPath.substring(pos + 1); String typemap = map.get(extention); ContentType type; type = P4Factory.p4javaToContentType(typemap); if (logger.isTraceEnabled()) { logger.trace("getContentType: " + extention + " " + type.toString()); } return type; } /** * Test injection method. * @param ext * @param type */ public static void add(String ext, String type) { map.put(ext, type); } /** * Test cleanup method. */ public static void clear() { map.clear(); } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#3 | 26953 | Paul Allen | Move //guest/perforce_software/p4convert to //guest/perforce_software/p4convert/main | ||
#2 | 15579 | Paul Allen |
SVN: Fix for 'tampered with after resolve - edit or revert'. Includes a manufactured test case, seems to be related to an IGNORE resolve with keyword/properties. |
||
#1 | 13920 | Paul Allen | copy part 2 (no errors) | ||
//guest/paul_allen/p4convert-maven/src/main/java/com/perforce/common/asset/TypeMap.java | |||||
#1 | 13876 | Paul Allen | Rename/move file(s) | ||
//guest/paul_allen/p4convert-maven/src/com/perforce/common/asset/TypeMap.java | |||||
#1 | 13873 | Paul Allen | Branching using p4convert-maven | ||
//guest/perforce_software/p4convert/src/com/perforce/common/asset/TypeMap.java | |||||
#1 | 9807 | Paul Allen | Initial import of p4-convert (from change 894340) |