本文整理汇总了Java中org.openide.filesystems.FileUtil.createMemoryFileSystem方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtil.createMemoryFileSystem方法的具体用法?Java FileUtil.createMemoryFileSystem怎么用?Java FileUtil.createMemoryFileSystem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openide.filesystems.FileUtil
的用法示例。
在下文中一共展示了FileUtil.createMemoryFileSystem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFileSystemFromCache
import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
private static FileSystem getFileSystemFromCache(Map<String,Reference<RemoteFileSystem>> cache, String key, Callable<RemoteFileSystem> create) {
synchronized (cache) {
RemoteFileSystem fs = cache.containsKey(key) ? cache.get(key).get() : null;
if (fs == null) {
try {
fs = create.call();
if (fs == null) {
return null;
}
cache.put(key, new WeakReference<RemoteFileSystem>(fs));
} catch (Exception ex) {
Exceptions.printStackTrace(ex);
return FileUtil.createMemoryFileSystem();
}
}
return fs;
}
}
示例2: testNaturalComparator
import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
private void testNaturalComparator(String[] fileNames,
String[] expectedOrder) throws IOException {
FolderComparator c = new FolderComparator(FolderComparator.NATURAL);
FileSystem fs = FileUtil.createMemoryFileSystem();
FileObject root = fs.getRoot();
List<DataObject> list = new ArrayList<DataObject>();
for (String n : fileNames) {
FileObject fo = root.createData(n);
assertNotNull(fo);
list.add(DataObject.find(fo));
}
Collections.sort(list, c);
for (int i = 0; i < expectedOrder.length; i++) {
assertEquals(expectedOrder[i], list.get(i).getName());
}
}
示例3: testGetIteratorHonoursDataObjectsCookies
import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
/** Does getIterator honours DataObject's cookies?
*/
public void testGetIteratorHonoursDataObjectsCookies () throws Exception {
FileSystem fs = FileUtil.createMemoryFileSystem();
DataObject obj;
Loader l = Loader.findObject (Loader.class, true);
try {
AddLoaderManuallyHid.addRemoveLoader (l, true);
obj = DataObject.find (fs.getRoot ());
} finally {
AddLoaderManuallyHid.addRemoveLoader (l, false);
}
TemplateWizard.Iterator it = TemplateWizard.getIterator (obj);
assertEquals ("Iterator obtained from the object's cookie", obj, it);
}
示例4: rememberConfigurations
import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
private void rememberConfigurations () {
FileObject fo = project.getProjectDirectory().getFileObject(ProjectConfigurations.CONFIG_PROPS_PATH);
if (fo != null) {
//Has configurations
try {
FileSystem fs = FileUtil.createMemoryFileSystem();
FileUtil.copyFile(fo, fs.getRoot(),fo.getName());
fo = project.getProjectDirectory().getFileObject("nbproject/private/configs"); //NOI18N
if (fo != null && fo.isFolder()) {
FileObject cfgs = fs.getRoot().createFolder("configs"); //NOI18N
for (FileObject child : fo.getChildren()) {
FileUtil.copyFile(child, cfgs, child.getName());
}
}
configs = fs;
} catch (IOException ioe) {
Exceptions.printStackTrace(ioe);
}
}
}
示例5: setUp
import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
protected void setUp () throws Exception {
cnt = 0;
File f = new File(getWorkDir(), "layer.xml");
FileWriter w = new FileWriter(f);
w.write("<filesystem><file name='x.instance'> ");
w.write(" <attr name='name' methodvalue='" + InstanceDataObjectGetNameTest.class.getName() + ".computeName'/> ");
w.write("</file></filesystem> ");
w.close();
fs = new MultiFileSystem(new FileSystem[] {
FileUtil.createMemoryFileSystem(),
new XMLFileSystem(f.toURL())
});
FileObject fo = fs.findResource("x.instance");
assertNotNull(fo);
assertNull(fo.getAttribute("name"));
assertEquals("One call", 1, cnt);
// clean
cnt = 0;
obj = DataObject.find(fo);
assertEquals("No calls now", 0, cnt);
}
示例6: createDefFs
import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
private static FileSystem createDefFs() {
try
{
FileSystem writeFs = FileUtil.createMemoryFileSystem();
FileSystem layerFs = new XMLFileSystem(RepositoryImpl.class.getClassLoader().getResource("org/netbeans/modules/css/resources/layer.xml"));
return new MultiFileSystem(new FileSystem[] { writeFs, layerFs });
} catch (SAXException e) {
return null;
}
}
示例7: createDefFs
import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
private static FileSystem createDefFs() {
try
{
FileSystem writeFs = FileUtil.createMemoryFileSystem();
FileSystem layerFs = new XMLFileSystem(RepositoryImpl.class.getClassLoader().getResource("org/netbeans/modules/db/resources/mf-layer.xml"));
FileSystem dbapiLayerFs = new XMLFileSystem(RepositoryImpl.class.getClassLoader().getResource("org/netbeans/modules/dbapi/resources/layer.xml"));
return new MultiFileSystem(new FileSystem[] { writeFs, layerFs, dbapiLayerFs });
} catch (SAXException e) {
return null;
}
}
示例8: DefaultJavaPlatformProviderTest
import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public DefaultJavaPlatformProviderTest(final String name) {
super(name);
fs = FileUtil.createMemoryFileSystem();
fs.getRoot();
rp = new Repository(fs);
System.setProperty("org.openide.util.Lookup", DefaultJavaPlatformProviderTest.Lkp.class.getName()); //NOI18N
Assert.assertEquals(DefaultJavaPlatformProviderTest.Lkp.class, Lookup.getDefault().getClass());
}
示例9: testFindOriginal
import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
/**
* Tests the method findOriginal()
* @throws Exception
*/
public void testFindOriginal() throws Exception {
FileSystem fs = FileUtil.createMemoryFileSystem();
FileObject orig = FileUtil.createData(fs.getRoot(), "path/to/orig");
FileObject shadow = FileUtil.createData(fs.getRoot(), "link.shadow");
shadow.setAttribute("originalFile", "path/to/orig");
assertEquals("found the right original file",
orig, DataShadow.findOriginal(shadow));
}
示例10: testFindBrokenOriginal
import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
/**
* Checks that findOriginal throws Exception on a malformed
* shadow
* @throws Exception
*/
public void testFindBrokenOriginal() throws Exception {
FileSystem fs = FileUtil.createMemoryFileSystem();
FileObject orig = FileUtil.createData(fs.getRoot(), "path/to/orig");
FileObject shadow = FileUtil.createData(fs.getRoot(), "link.shadow");
try {
DataShadow.findOriginal(shadow);
fail("IOException should be thrown on malformed shadow");
} catch (IOException ex) {
// this is oK
}
}
示例11: testFindOriginalFromAnonymousFilesystem
import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public void testFindOriginalFromAnonymousFilesystem() throws Exception {
// Helpful for XML layer editing.
FileSystem fs = FileUtil.createMemoryFileSystem();
FileObject orig = FileUtil.createData(fs.getRoot(), "path/to/orig");
FileObject shadow = FileUtil.createData(fs.getRoot(), "link.shadow");
shadow.setAttribute("originalFile", "path/to/orig");
assertEquals("found the right original file", DataObject.find(orig), DataShadow.deserialize(shadow));
orig = FileUtil.createData(fs.getRoot(), "path to orig");
shadow = FileUtil.createData(fs.getRoot(), "link2.shadow");
shadow.setAttribute("originalFile", "path to orig");
assertEquals("found the right original file", DataObject.find(orig), DataShadow.deserialize(shadow));
}
示例12: setup
import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
/**
* Set the global default lookup with the specified content.
*
* @param layers xml-layer URLs to be present in the system filesystem.
* @param instances object instances to be present in the default lookup.
*/
public static void setup (
String[] layers,
Object[] instances
) {
ClassLoader classLoader = IDEInitializer.class.getClassLoader ();
File workDir = new File (Manager.getWorkDirPath ());
URL[] urls = new URL [layers.length];
int i, k = urls.length;
for (i = 0; i < k; i++)
urls [i] = classLoader.getResource (layers [i]);
// 1) create repository
XMLFileSystem systemFS = new XMLFileSystem ();
lfs = FileUtil.createMemoryFileSystem();
try {
systemFS.setXmlUrls (urls);
} catch (Exception ex) {
ex.printStackTrace ();
}
MyFileSystem myFileSystem = new MyFileSystem (
new FileSystem [] {lfs, systemFS}
);
Repository repository = new Repository (myFileSystem);
Object[] lookupContent = new Object [instances.length + 1];
lookupContent [0] = repository;
System.arraycopy (instances, 0, lookupContent, 1, instances.length);
DEFAULT_LOOKUP.setLookups (new Lookup[] {
Lookups.fixed (lookupContent),
Lookups.metaInfServices (classLoader),
Lookups.singleton (classLoader),
});
Assert.assertTrue (myFileSystem.isDefault());
}
示例13: testDuplicateRandomTest
import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public void testDuplicateRandomTest() throws IOException {
if (!RUN_RANDOM_TESTS) {
return;
}
final FileSystem fs = FileUtil.createMemoryFileSystem();
String[] paths = generateRandomTree(TREE_DEPTH,TREE_CHILD_COUNT);
FileObject root = fs.getRoot();
populateFolderStructure(root, paths);
Random r = new Random(System.currentTimeMillis());
for (int runCount=0; runCount<TEST_COUNT; runCount++) {
System.out.println("Run: " + runCount);
final Set<FileObject> testSet = new HashSet<FileObject>();
while (testSet.size() < SINGLE_TEST_SET_SIZE) {
final String s = paths[r.nextInt(paths.length)];
FileObject fo = root.getFileObject(s);
final int shift = r.nextInt(TREE_DEPTH);
for (int i = 0; i<shift; i++) {
fo = fo.getParent();
}
testSet.add(fo);
}
FileObjectCrawler crawler = new FileObjectCrawler(
root,
testSet.toArray(new FileObject[testSet.size()]),
EnumSet.<Crawler.TimeStampAction>of(Crawler.TimeStampAction.UPDATE),
null,
CR,
SuspendSupport.NOP);
assertCollectedFiles(
"Wrong files collected for: " + testSet,
crawler.getResources(),
crawl(testSet, root));
}
}
示例14: testFindsAllDirectories
import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public void testFindsAllDirectories() throws IOException {
FileSystem fs = FileUtil.createMemoryFileSystem();
FileUtil.createData(fs.getRoot(), "MyPrj/pom.xml");
FileUtil.createData(fs.getRoot(), "MyPrj/a/pom.xml");
FileUtil.createData(fs.getRoot(), "MyPrj/a/b/pom.xml");
FileUtil.createData(fs.getRoot(), "MyPrj/a/b/c/pom.xml");
FileObject root = fs.findResource("MyPrj");
Set<FileObject> res = ArchetypeWizardUtils.openProjects(root, null);
assertEquals("Four projects found: " + res, 4, res.size());
}
示例15: setUp
import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
@Override
protected void setUp() throws IOException {
FileSystem ms = FileUtil.createMemoryFileSystem();
fo = ms.getRoot().createData("my.wsmode");
OutputStream os = fo.getOutputStream();
FileUtil.copy(DesignSupportTest.class.getResourceAsStream("testWsmode.xml"), os);
os.close();
}