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


Java FileObject.move方法代码示例

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


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

示例1: testMoveWithAttributes

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void testMoveWithAttributes() throws Exception {
    final FileObject workDirFo = FileBasedFileSystem.getFileObject(getWorkDir());
    FileObject target = workDirFo.createFolder("target");
    FileObject folder = workDirFo.createFolder("a");
    folder.createData("non.empty");
    folder.setAttribute("name", "jmeno");
    assertEquals("jmeno", folder.getAttribute("name"));
    FileLock lock = folder.lock();
    FileObject newF = folder.move(lock, target, "b", null);
    assertFalse("Invalidated", folder.isValid());
    lock.releaseLock();
    assertEquals("Name is not b", "b", newF.getNameExt());
    WeakReference<?> ref = new WeakReference<FileObject>(newF);
    newF = null;
    assertGC("Folder can disappear", ref);
    folder = target.getFileObject("b");
    assertNotNull("Folder b found", folder);
    assertEquals("The attribute remains even after rename", "jmeno", folder.getAttribute("name"));
    assertEquals("One children", 1, folder.getChildren().length);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:FolderObjTest.java

示例2: testRenameProjectFolder

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void testRenameProjectFolder() throws Exception { // #194046
    FileObject p1 = scratch.createFolder("p1");
    p1.createFolder("testproject");
    Project project1 = pm.findProject(p1);
    FileObject p2;
    FileLock lock = p1.lock();
    try {
        p2 = p1.move(lock, scratch, "p2", null);
    } finally {
        lock.releaseLock();
    }
    assertEquals(p1, p2);
    Project project2 = pm.findProject(p2);
    TestUtil.notifyDeleted(project1);
    assertEquals(project2, pm.findProject(p2));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:ProjectManagerTest.java

示例3: testMoveClassLivingElseWhere

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void testMoveClassLivingElseWhere() throws Exception {
    FileObject testFile = FileUtil.createData(src, "test/Test.java");
    TestUtilities.copyStringToFile(testFile, "package test2; public class Test {}");
    SourceUtilsTestUtil.compileRecursively(src);
    FileObject test2Package = FileUtil.createFolder(src, "test2");
    FileLock lock = testFile.lock();
    testFile.move(lock, test2Package, "Test", "java");
    lock.releaseLock();
    SourceUtilsTestUtil.compileRecursively(src);
    assertFalse(ErrorsCache.isInError(src, true));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:JavaCustomIndexerTest.java

示例4: testDisableIBInFSEvents

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void testDisableIBInFSEvents () throws Exception {
    File file = new File(repositoryLocation, "aaa");
    file.createNewFile();
    final GitClient client = Git.getInstance().getClient(repositoryLocation);
    client.add(new File[] { file }, GitUtils.NULL_PROGRESS_MONITOR);
    client.commit(new File[] { file }, "msg", null, null, GitUtils.NULL_PROGRESS_MONITOR);

    FileObject fo = FileUtil.toFileObject(file);
    Git.LOG.setLevel(Level.ALL);
    LogHandler handler = new LogHandler();
    Git.LOG.addHandler(handler);

    assertTrue(client.getStatus(new File[] { file }, GitUtils.NULL_PROGRESS_MONITOR).get(file).getStatusHeadIndex() == GitStatus.Status.STATUS_NORMAL);
    fo.delete();
    assertTrue(client.getStatus(new File[] { file }, GitUtils.NULL_PROGRESS_MONITOR).get(file).getStatusHeadIndex() == GitStatus.Status.STATUS_REMOVED);
    assertFalse(handler.indexingBridgeCalled);

    fo.getParent().createData(file.getName());
    assertTrue(client.getStatus(new File[] { file }, GitUtils.NULL_PROGRESS_MONITOR).get(file).getStatusHeadIndex() == GitStatus.Status.STATUS_NORMAL);
    assertFalse(handler.indexingBridgeCalled);

    File copy = new File(repositoryLocation, "copy");
    fo.copy(fo.getParent(), copy.getName(), "");
    assertTrue(client.getStatus(new File[] { copy }, GitUtils.NULL_PROGRESS_MONITOR).get(copy).getStatusHeadIndex() == GitStatus.Status.STATUS_ADDED);
    assertFalse(handler.indexingBridgeCalled);

    File renamed = new File(repositoryLocation, "renamed");
    FileLock lock = fo.lock();
    fo.move(lock, fo.getParent(), renamed.getName(), "");
    lock.releaseLock();
    assertTrue(client.getStatus(new File[] { file }, GitUtils.NULL_PROGRESS_MONITOR).get(file).getStatusHeadIndex() == GitStatus.Status.STATUS_REMOVED);
    assertTrue(client.getStatus(new File[] { renamed }, GitUtils.NULL_PROGRESS_MONITOR).get(renamed).getStatusHeadIndex() == GitStatus.Status.STATUS_ADDED);
    assertFalse(handler.indexingBridgeCalled);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:35,代码来源:GitClientTest.java

示例5: moveFO

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private void moveFO(File from, File to) throws DataObjectNotFoundException, IOException {
    FileObject foFrom = FileUtil.toFileObject(from);
    assertNotNull(foFrom);
    FileObject foTarget = FileUtil.toFileObject(to.getParentFile());
    assertNotNull(foTarget);
    FileLock lock = foFrom.lock();
    try {
        foFrom.move(lock, foTarget, to.getName(), null);
    } finally {
        lock.releaseLock();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:FilesystemInterceptorTest.java

示例6: moveFO

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private void moveFO(File from, File to) throws DataObjectNotFoundException, IOException {
    FileObject foFrom = FileUtil.toFileObject(from);
    assertNotNull(foFrom);
    FileObject foTarget = FileUtil.toFileObject(to.getParentFile());
    assertNotNull(foTarget);
    FileLock lock = foFrom.lock();
    try {
        foFrom.move(lock, foTarget, to.getName(), null);
    } finally {
        lock.releaseLock();
    }        
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:InteceptorTest.java

示例7: testMoveOfAFolderDoesNotTouchSubhierarchy

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void testMoveOfAFolderDoesNotTouchSubhierarchy() throws Exception {
    FileObjectFactory fs = FileObjectFactory.getInstance(getWorkDir());
    assertNotNull(fs);
    FileObject root1 = fs.getValidFileObject(getWorkDir(), FileObjectFactory.Caller.Others);

    FileObject where = root1.createFolder("else").createFolder("sub").createFolder("subsub");
    FileObject fo = root1.createFolder("something");
    FileObject kidTxt = fo.createData("kid.txt");
    FileObject kid = fo.createFolder("kid");
    File kidFile = FileUtil.toFile(kid);
    File kidTxtFile = FileUtil.toFile(kidTxt);

    accessMonitor = new StatFiles();
    FileLock lock = fo.lock();
    FileObject newFolder;
    try {
        newFolder = fo.move(lock, where, fo.getNameExt(), null);
    } finally {
        lock.releaseLock();
    }
    assertEquals("Subfolder", where, newFolder.getParent());

    assertNotNull("Folder found", newFolder.getFileObject("kid"));
    assertNotNull("File found", newFolder.getFileObject("kid.txt"));
    assertFalse("No longer valid file", kidTxt.isValid());
    assertFalse("No longer valid dir", kid.isValid());

    String msg = 
        accessMonitor.getResults().statResultStack(kidFile, StatFiles.ALL) + "\n" +
        accessMonitor.getResults().statResultStack(kidTxtFile, StatFiles.ALL) + "\n";
    final Set<File> files = accessMonitor.getResults().getFiles();
    if (files.contains(kidFile) || files.contains(kidTxtFile)) {
        fail(msg);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:36,代码来源:BaseFileObjectTestHid.java

示例8: testDeadLock

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void testDeadLock() throws Exception {
    assertNotNull(folder);
    assertTrue(folder instanceof BaseFileObj);
    FileObject data = FileUtil.createData(folder, "/a/b/c/data.txt");
    assertNotNull(data);
    FileLock lock = data.lock();
    try {
        data.move(lock,folder, data.getName(), data.getExt());
    } finally {
        lock.releaseLock();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:Deadlock73332Test.java

示例9: testMovedUnlocks

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void testMovedUnlocks() throws IOException {
    FileObject fo = FileUtil.toFileObject(getWorkDir());
    FileObject fromFile = fo.createData("move.txt");
    FileObject toFolder = fo.createFolder("toFolder");
    
    FileObject toFile = fromFile.move(fromFile.lock(), toFolder, fromFile.getName(), fromFile.getExt());

    assertFalse("Not locked anymore: " + fo, Watcher.isLocked(fo));
    assertFalse("Not locked anymore: " + fromFile, Watcher.isLocked(fromFile));
    assertFalse("Not locked anymore: " + toFolder, Watcher.isLocked(toFolder));
    assertFalse("Not locked anymore: " + toFile, Watcher.isLocked(toFile));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:MoveUnlocksWatcherTest.java

示例10: testMove_BeforeSuccessFailure

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void testMove_BeforeSuccessFailure() throws IOException {
    FileObject fromFolder = FileUtil.toFileObject(getWorkDir()).createFolder("moveFrom");
    FileObject toFolder = FileUtil.toFileObject(getWorkDir()).createFolder("moveTo");
    assertNotNull(fromFolder);
    assertNotNull(toFolder);
    FileObject toMove = fromFolder.createData("aa");
    assertNotNull(toMove);
    iListener.clear();

    assertNotNull(iListener);
    assertEquals(0,iListener.beforeMoveCalls);
    assertEquals(0,iListener.moveSuccessCalls);
    assertEquals(0,iListener.moveFailureCalls);

    // move
    FileLock lock = toMove.lock();
    toMove.move(lock, toFolder, toMove.getName(), toMove.getExt());
    assertFalse(toMove.isValid());
    assertEquals(1,iListener.beforeMoveCalls);
    assertEquals(1,iListener.moveSuccessCalls);

    iListener.clear();
    try {
        // success
        assertEquals(0,iListener.moveSuccessCalls);
        assertEquals(0,iListener.moveFailureCalls);

        // move to itself => failure
        toMove.move(lock, toFolder, toMove.getName(), toMove.getExt());
        fail();
    } catch (IOException ex) {
        // failure
        assertEquals(0,iListener.moveSuccessCalls);
        assertEquals(1,iListener.moveFailureCalls);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:37,代码来源:ProvidedExtensionsTest.java

示例11: testFileMoved

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void testFileMoved() throws IOException {
    inteceptor.moveHandler = moveHandler;
    FileObject fo = getVersionedFolder();
    FileObject fromFile = fo.createData("move.txt");
    FileObject toFolder = fo.createFolder("toFolder");
    VCSFileProxy fromProxy = VCSFileProxy.createFileProxy(fromFile);
    
    logHandler.clear();
    logHandler.ignoredMessages.add(createdExternalyFormat);
    logHandler.ignoredMessages.add(deletedExternalyFormat);
    
    FileObject toFile = fromFile.move(fromFile.lock(), toFolder, fromFile.getName(), fromFile.getExt());
    VCSFileProxy toProxy = VCSFileProxy.createFileProxy(toFile);

    assertTrue(inteceptor.getBeforeMoveFiles().contains(fromProxy));
    assertTrue(inteceptor.getBeforeMoveFiles().contains(toProxy));
    assertTrue(inteceptor.getDoMoveFiles().contains(fromProxy));
    assertTrue(inteceptor.getDoMoveFiles().contains(toProxy));
    assertTrue(inteceptor.getAfterMoveFiles().contains(fromProxy));
    assertTrue(inteceptor.getAfterMoveFiles().contains(toProxy));
    
    assertInterceptedCalls(
        f(fileLockedFormat, fromProxy),
        f(getMoveHandlerFormat, fromProxy, toProxy),
        f(moveHandleFormat, fromProxy, toProxy),
//        f(deletedExternalyFormat, toProxy); // XXX can we avoid this? sometimes deleted or created externaly 
        f(afterMoveFormat, fromProxy, toProxy)
    );

}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:VCSInterceptorTestCase.java

示例12: testFolderTreeMoved

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void testFolderTreeMoved() throws IOException {
    inteceptor.moveHandler = moveHandler;
    FileObject fo = getVersionedFolder();
    FileObject fromFolder = fo.createFolder("fromFolder");
    FileObject movedChild = fromFolder.createData("movedChild");
    FileObject targetFolder = fo.createFolder("targetFolder");
    VCSFileProxy fromProxy = VCSFileProxy.createFileProxy(fromFolder);
    
    logHandler.clear();
    logHandler.ignoredMessages.add(createdExternalyFormat);
    logHandler.ignoredMessages.add(deletedExternalyFormat);
    FileObject toFile = fromFolder.move(fromFolder.lock(), targetFolder, fromFolder.getName(), fromFolder.getExt());
    VCSFileProxy toProxy = VCSFileProxy.createFileProxy(toFile);

    assertTrue(inteceptor.getBeforeMoveFiles().contains(fromProxy));
    assertTrue(inteceptor.getBeforeMoveFiles().contains(toProxy));
    assertTrue(inteceptor.getDoMoveFiles().contains(fromProxy));
    assertTrue(inteceptor.getDoMoveFiles().contains(toProxy));
    assertTrue(inteceptor.getAfterMoveFiles().contains(fromProxy));
    assertTrue(inteceptor.getAfterMoveFiles().contains(toProxy));
    
    assertInterceptedCalls(
//        f(fileLockedFormat, fromProxy); // no lock on folder
        f(getMoveHandlerFormat, fromProxy, toProxy),
        f(moveHandleFormat, fromProxy, toProxy),
//        f(deletedExternalyFormat, toProxy); // XXX can we avoid this? sometimes deleted or created externaly 
        f(afterMoveFormat, fromProxy, toProxy)
    );
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:VCSInterceptorTestCase.java

示例13: testExternalyMoved

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void testExternalyMoved() throws IOException {
    FileObject fo = getVersionedFolder();
    FileObject fromFile = fo.createData("move.txt");
    FileObject toFolder = fo.createFolder("toFolder");
    
    fo.addFileChangeListener(new FileChangeAdapter());
    inteceptor.startAcceptingEvents = true;
    FileObject toFile = fromFile.move(fromFile.lock(), toFolder, fromFile.getName(), fromFile.getExt());
    
    VCSFileProxy fromProxy = VCSFileProxy.createFileProxy(fromFile);
    VCSFileProxy toProxy = VCSFileProxy.createFileProxy(toFile);
    assertEquals(ExternalyMovedInterceptor.DO_MOVE  + " from " + fromProxy + " " + toProxy, inteceptor.events.get(0));
    assertEquals(ExternalyMovedInterceptor.TIMEDOUT + " from " + fromProxy + " " + toProxy, inteceptor.events.get(1));
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:AfterDeleteAfterMoveEndsTest.java

示例14: move

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
/** Moves entry to folder. Overrides superclass method. 
 * @param folder folder where copy
 * @param suffix suffix to use 
 * @exception IOException when error happens */
@Override
public FileObject move(FileObject folder, String suffix) throws IOException {
    if (LOG.isLoggable(FINER)) {
        LOG.finer("move("                                           //NOI18N
                  + FileUtil.getFileDisplayName(folder) + ", "      //NOI18N
                  + (suffix != null ? '"' + suffix + '"' : "<null>")//NOI18N
                  + ')');
    }
    String pasteSuffix = ((PropertiesDataObject)getDataObject()).getPasteSuffix();

    if(pasteSuffix == null)
        return super.move(folder, suffix);

    boolean wasLocked = isLocked();

    FileObject fileObject = getFile();
    FileLock lock = takeLock ();

    try {
        String basicName = getDataObject().getPrimaryFile().getName();
        String newName = basicName + pasteSuffix + Util.getLocaleSuffix(this);

        detachListener();
        FileObject fo = fileObject.move (lock, folder, newName, fileObject.getExt());
        attachListener(fo);
        return fo;
    } finally {
        if (!wasLocked) {
            lock.releaseLock ();
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:37,代码来源:PropertiesFileEntry.java

示例15: testDisableIBInFSEvents

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void testDisableIBInFSEvents () throws Exception {
    CommandHandler handler = new CommandHandler();
    Mercurial.LOG.addHandler(handler);
    Mercurial.LOG.setLevel(Level.ALL);
    File file = createFile(getWorkTreeDir(), "aaa");
    commit(file);

    FileObject fo = FileUtil.toFileObject(file);

    fo.delete();
    assertEquals(FileInformation.STATUS_VERSIONED_REMOVEDLOCALLY, HgCommand.getStatus(getWorkTreeDir(), Collections.<File>singletonList(file), null, null).get(file).getStatus());
    assertFalse(handler.commandInvoked);

    fo.getParent().createData(file.getName());
    assertNull(HgCommand.getStatus(getWorkTreeDir(), Collections.<File>singletonList(file), null, null).get(file));
    assertFalse(handler.commandInvoked);

    File copy = new File(file.getParentFile(), "copy");
    fo.copy(fo.getParent(), copy.getName(), "");
    assertEquals(FileInformation.STATUS_VERSIONED_ADDEDLOCALLY, HgCommand.getStatus(getWorkTreeDir(), Collections.<File>singletonList(copy), null, null).get(copy).getStatus());
    assertFalse(handler.commandInvoked);

    File renamed = new File(file.getParentFile(), "renamed");
    FileLock lock = fo.lock();
    fo.move(lock, fo.getParent(), renamed.getName(), "");
    lock.releaseLock();
    assertEquals(FileInformation.STATUS_VERSIONED_ADDEDLOCALLY, HgCommand.getStatus(getWorkTreeDir(), Collections.<File>singletonList(renamed), null, null).get(renamed).getStatus());
    assertEquals(FileInformation.STATUS_VERSIONED_REMOVEDLOCALLY, HgCommand.getStatus(getWorkTreeDir(), Collections.<File>singletonList(file), null, null).get(file).getStatus());
    assertFalse(handler.commandInvoked);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:HgCommandTest.java


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