本文整理匯總了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();
}