当前位置: 首页>>代码示例>>Java>>正文


Java Utils.getRelativePath方法代码示例

本文整理汇总了Java中gov.nih.nci.cagrid.common.Utils.getRelativePath方法的典型用法代码示例。如果您正苦于以下问题:Java Utils.getRelativePath方法的具体用法?Java Utils.getRelativePath怎么用?Java Utils.getRelativePath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gov.nih.nci.cagrid.common.Utils的用法示例。


在下文中一共展示了Utils.getRelativePath方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: listHistoryFilesByDate

import gov.nih.nci.cagrid.common.Utils; //导入方法依赖的package包/类
private List<File> listHistoryFilesByDate() {
    final File historyDir = getHistoryDirectory();
    List<File> historyFiles = Utils.recursiveListFiles(historyDir, new FileFilter() {
           public boolean accept(File pathname) {
               return pathname.getName().endsWith(".xml") || pathname.isDirectory();
           }
       });
    Comparator<File> comp = new Comparator<File>() {
           public int compare(File o1, File o2) {
               int val = 0;
               try {
                   String rel1 = Utils.getRelativePath(historyDir, o1);
                   String rel2 = Utils.getRelativePath(historyDir, o2);
                   val = rel1.compareTo(rel2);
               } catch (Exception ex) {
                   // uhoh
               }
               return val;
           }
       };
       Collections.sort(historyFiles, comp);
       return historyFiles;
}
 
开发者ID:NCIP,项目名称:cagrid-core,代码行数:24,代码来源:HistoryManager.java

示例2: listHistoryFilesByDate

import gov.nih.nci.cagrid.common.Utils; //导入方法依赖的package包/类
private List<File> listHistoryFilesByDate() {
	final File historyDir = getHistoryDirectory();
	List<File> historyFiles = Utils.recursiveListFiles(historyDir, new FileFilter() {
		public boolean accept(File pathname) {
			return pathname.getName().endsWith(".xml") || pathname.isDirectory();
		}
	});
	Comparator<File> comp = new Comparator<File>() {
		public int compare(File o1, File o2) {
			int val = 0;
			try {
				String rel1 = Utils.getRelativePath(historyDir, o1);
				String rel2 = Utils.getRelativePath(historyDir, o2);
				val = rel1.compareTo(rel2);
			} catch (Exception ex) {
				// uhoh
			}
			return val;
		}
	};
	Collections.sort(historyFiles, comp);
	return historyFiles;
}
 
开发者ID:NCIP,项目名称:cagrid2,代码行数:24,代码来源:DefaultHistoryManager.java

示例3: getTranslator

import gov.nih.nci.cagrid.common.Utils; //导入方法依赖的package包/类
private CQL2ParameterizedHQL getTranslator() {
    if (translator == null) {
        try {
            InputStream hbmConfigStream = getClass().getResourceAsStream("/hibernate.cfg.xml");
            assertNotNull("Hibernate config was null", hbmConfigStream);
            Configuration hibernateConfig = new Configuration();
            hibernateConfig.addInputStream(hbmConfigStream);
            hibernateConfig.buildMapping();
            hibernateConfig.configure();
            hbmConfigStream.close();

            String base = System.getProperty(TESTS_BASEDIR_PROPERTY);
            File sdkLocalClientDir = new File(base, SDK_LOCAL_CLIENT_DIR);
            File sdkConfDir = new File(sdkLocalClientDir, "conf");
            File constantsFile = new File(sdkConfDir, "IsoConstants.xml");
            // Spring loads the config file from a location relative to the JVM working dir,
            // which causes massive headaches under non-windows platforms if you try to specify
            // the "absolutePath" to the constants file.  Therefore, we're using the relative path
            // full of ../'s and stuff
            String relPath = Utils.getRelativePath(new File("."), constantsFile);
            ApplicationContext isoContext = new FileSystemXmlApplicationContext(relPath);
            translator = new CQL2ParameterizedHQL(
                new HibernateConfigTypesInformationResolver(hibernateConfig, true), 
                new IsoDatatypesConstantValueResolver(isoContext),
                false);
        } catch (Exception ex) {
            ex.printStackTrace();
            fail("Error: " + ex.getMessage());
        }
    }
    
    return translator;
}
 
开发者ID:NCIP,项目名称:cagrid-core,代码行数:34,代码来源:InvokeLocalTranslatedCqlStep.java

示例4: main

import gov.nih.nci.cagrid.common.Utils; //导入方法依赖的package包/类
/**
 * @param args
 */
public static void main(String[] args) {
    try {
        MappingTool tool = new MappingTool();
        File srcDir = new File("src/java/beans/dcql2");
        List<File> files = Utils.recursiveListFiles(srcDir, new FileFilter() {
            public boolean accept(File pathname) {
                return pathname.getName().endsWith(".java");
            }
        });
        for (File f : files) {
            if (f.isFile() && !f.getName().startsWith("MappingDriver")) {
                String path = Utils.getRelativePath(srcDir, f.getCanonicalFile());
                path = path.substring(0, path.length() - 5);
                String className = path.replace(File.separatorChar, '.');
                System.out.println("Found " + className);
                System.out.flush();
                tool.addClass(className);
            }
        }
        StringWriter writer = new StringWriter();
        tool.write(writer);
        String pretty = XMLUtilities.formatXML(writer.getBuffer().toString());
        System.out.println(pretty);
    } catch (Exception ex) {
        ex.printStackTrace();
    }

}
 
开发者ID:NCIP,项目名称:cagrid-core,代码行数:32,代码来源:MappingDriver.java

示例5: syncEclipseClasspath

import gov.nih.nci.cagrid.common.Utils; //导入方法依赖的package包/类
/**
 * Adds libraries to an eclipse .classpath file
 * 
 * @param classpathFile
 * 		The .classpath file
 * @param additionalLibs
 * 		The libraries (jars) to add to the .classpath.  The jars will be added
 * 		with paths <i>relative</i> to the .classpath file's location
 * @throws Exception
 */
public static void syncEclipseClasspath(File classpathFile, File[] additionalLibs) throws Exception {
	Element classpathElement = XMLUtilities.fileNameToDocument(classpathFile.getAbsolutePath()).getRootElement();
	
	// get the list of additional libraries to add to the classpath
	Set libNames = new HashSet();
	for (int i = 0; i < additionalLibs.length; i++) {
		String relativeLibName = Utils.getRelativePath(classpathFile, additionalLibs[i]);
		relativeLibName = convertToUnixStylePath(relativeLibName);
		libNames.add(relativeLibName);
	}
	
	// find out which libs are NOT yet in the classpath
	Iterator classpathEntryIter = classpathElement.getChildren(
		CLASSPATHENTRY_ELEMENT, classpathElement.getNamespace()).iterator();
	while (classpathEntryIter.hasNext()) {
		Element entry = (Element) classpathEntryIter.next();
		if (entry.getAttributeValue("kind").equals("lib")) {
			libNames.remove(entry.getAttributeValue("path"));
		}
	}
	
	// anything left over now has to be added to the classpath
	Iterator additionalLibIter = libNames.iterator();
	while (additionalLibIter.hasNext()) {
		String libName = (String) additionalLibIter.next();
		Element entryElement = new Element(CLASSPATHENTRY_ELEMENT);
		entryElement.setAttribute("kind", "lib");
		entryElement.setAttribute("path", libName);
		classpathElement.addContent(entryElement);
	}
	
	// write the .classpath file back out to disk
	XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat());
	FileWriter writer = new FileWriter(classpathFile);
	outputter.output(classpathElement, writer);
	writer.flush();
	writer.close();
}
 
开发者ID:NCIP,项目名称:cagrid-core,代码行数:49,代码来源:ExtensionUtilities.java

示例6: removeLibrariesFromClasspath

import gov.nih.nci.cagrid.common.Utils; //导入方法依赖的package包/类
/**
 * Removes library entries from an Eclipse .classpath file
 * Libraries to be removed may be fully qualified paths, and will first be
 * made relative to the .classpath file before removal is attempted.
 * 
 * @param classpathFile
 * @param removeLibs
 * @throws Exception
 */
public static void removeLibrariesFromClasspath(File classpathFile, File[] removeLibs) throws Exception {
    Element classpathElement = XMLUtilities.fileNameToDocument(classpathFile.getAbsolutePath()).getRootElement();
    
    // get the list of libraries to be removed
    Set<String> libNames = new HashSet();
    for (File remove : removeLibs) {
        String relativeLibName = Utils.getRelativePath(classpathFile, remove);
        relativeLibName = convertToUnixStylePath(relativeLibName);
        libNames.add(relativeLibName);
    }
    
    // start removing entries
    List<Element> keptEntries = new LinkedList();
    Iterator classpathEntryIter = classpathElement.getChildren(
        CLASSPATHENTRY_ELEMENT, classpathElement.getNamespace()).iterator();
    while (classpathEntryIter.hasNext()) {
        Element entry = (Element) classpathEntryIter.next();
        boolean keep = true;
        if (entry.getAttributeValue("kind").equals("lib")) {
            String libPath = entry.getAttributeValue("path");
            if (libNames.contains(libPath)) {
                keep = false;
            }
        }
        if (keep) {
            keptEntries.add(entry);
        }
    }
    // remove ALL classpath entries
    classpathElement.removeChildren(CLASSPATHENTRY_ELEMENT, classpathElement.getNamespace());
    // restore the ones we're not removing
    for (Element e : keptEntries) {
        classpathElement.addContent(e);
    }
    
    // write the .classpath file back out to disk
    XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat());
    FileWriter writer = new FileWriter(classpathFile);
    outputter.output(classpathElement, writer);
    writer.flush();
    writer.close();
}
 
开发者ID:NCIP,项目名称:cagrid-core,代码行数:52,代码来源:ExtensionUtilities.java


注:本文中的gov.nih.nci.cagrid.common.Utils.getRelativePath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。