本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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();
}
}
示例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();
}
示例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();
}