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


Java Path.equals方法代码示例

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


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

示例1: map

import java.nio.file.Path; //导入方法依赖的package包/类
/**
 * Converts the class file dependency graph into the source file dependency graph, by
 * consolidating classes from the same source file. Given as input:
 *
 * <p>ul>
 * <li>a directed graph where the nodes are classes (both inner and outer) and edges are
 *     dependencies between said classes
 * <li>a mapping between outer class files and source files.
 * </ul>
 *
 * This function outputs a directed graph where the nodes are source files and the edges are
 * dependencies between said source files.
 */
// TODO(bazel-team): Migrate this function into Guava graph library
public static ImmutableGraph<Path> map(
    Graph<String> classGraph, Map<String, Path> classToSourceFileMap) {
  MutableGraph<Path> graph = GraphBuilder.directed().allowsSelfLoops(false).build();
  for (String sourceNode : classGraph.nodes()) {
    if (isInnerClass(sourceNode)) {
      throw new GraphProcessorException(
          String.format("Found inner class %s when mapping classes to source files", sourceNode));
    }
    Path sourcePath = classToSourceFileMap.get(sourceNode);
    graph.addNode(sourcePath);
    for (String successorNode : classGraph.successors(sourceNode)) {
      Path successorPath = classToSourceFileMap.get(successorNode);
      if (!sourcePath.equals(successorPath)) {
        graph.putEdge(sourcePath, successorPath);
      }
    }
  }
  return ImmutableGraph.copyOf(graph);
}
 
开发者ID:bazelbuild,项目名称:BUILD_file_generator,代码行数:34,代码来源:ClassToSourceGraphConsolidator.java

示例2: processChangedFile

import java.nio.file.Path; //导入方法依赖的package包/类
/**
 * Handle a changed file.
 *
 * @param event the event
 */
@FXThread
protected void processChangedFile(@NotNull final FileChangedEvent event) {

    final Path file = event.getFile();
    final Path editFile = getEditFile();

    if (!file.equals(editFile)) {
        return;
    }

    if (isSaving()) {
        notifyFinishSaving();
        return;
    }

    handleExternalChanges();
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:23,代码来源:AbstractFileEditor.java

示例3: main

import java.nio.file.Path; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    FileSystem fs = FileSystems.getDefault();
    if (fs.getClass().getModule() == Object.class.getModule())
        throw new RuntimeException("FileSystemProvider not overridden");

    // exercise the file system
    Path dir = Files.createTempDirectory("tmp");
    if (dir.getFileSystem() != fs)
        throw new RuntimeException("'dir' not in default file system");
    System.out.println("created: " + dir);

    Path foo = Files.createFile(dir.resolve("foo"));
    if (foo.getFileSystem() != fs)
        throw new RuntimeException("'foo' not in default file system");
    System.out.println("created: " + foo);

    // exercise interop with java.io.File
    File file = foo.toFile();
    Path path = file.toPath();
    if (path.getFileSystem() != fs)
        throw new RuntimeException("'path' not in default file system");
    if (!path.equals(foo))
        throw new RuntimeException(path + " not equal to " + foo);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:Main.java

示例4: preVisitDirectory

import java.nio.file.Path; //导入方法依赖的package包/类
@Override
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
	
	// --- Check if the current folder is in the skipList ------
	if(this.skipList != null){
 	for(Path pathToSkip : skipList){
 		if(pathToSkip.equals(dir)){
 			return FileVisitResult.SKIP_SUBTREE;
 		}
 	}
	}
	
	// --- If not, create a corresponding folder in the target path ---------------
    Path targetPath = toPath.resolve(fromPath.relativize(dir));
    if(!Files.exists(targetPath)){
        Files.createDirectory(targetPath);
    }
    
    return FileVisitResult.CONTINUE;
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:21,代码来源:RecursiveFolderCopier.java

示例5: notifyChangedEditedFile

import java.nio.file.Path; //导入方法依赖的package包/类
/**
 * Notify about changed the edited file.
 *
 * @param prevFile the prev file.
 * @param newFile  the new file.
 */
@FXThread
private void notifyChangedEditedFile(final @NotNull Path prevFile, final @NotNull Path newFile) {

    final Path editFile = getEditFile();

    if (editFile.equals(prevFile)) {
        setEditFile(newFile);
        return;
    }

    if (!editFile.startsWith(prevFile)) return;

    final Path relativeFile = editFile.subpath(prevFile.getNameCount(), editFile.getNameCount());
    final Path resultFile = newFile.resolve(relativeFile);

    setEditFile(resultFile);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:24,代码来源:AbstractFileEditor.java

示例6: checkClass

import java.nio.file.Path; //导入方法依赖的package包/类
static void checkClass(Map<String,Path> clazzes, String clazz, Path jarpath) {
    Path previous = clazzes.put(clazz, jarpath);
    if (previous != null) {
        if (previous.equals(jarpath)) {
            if (clazz.startsWith("org.apache.xmlbeans")) {
                return; // https://issues.apache.org/jira/browse/XMLBEANS-499
            }
            // throw a better exception in this ridiculous case.
            // unfortunately the zip file format allows this buggy possibility
            // UweSays: It can, but should be considered as bug :-)
            throw new IllegalStateException("jar hell!" + System.lineSeparator() +
                    "class: " + clazz + System.lineSeparator() +
                    "exists multiple times in jar: " + jarpath + " !!!!!!!!!");
        } else {
            throw new IllegalStateException("jar hell!" + System.lineSeparator() +
                    "class: " + clazz + System.lineSeparator() +
                    "jar1: " + previous + System.lineSeparator() +
                    "jar2: " + jarpath);
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:JarHell.java

示例7: getItem

import java.nio.file.Path; //导入方法依赖的package包/类
public static TreeItem<Path> getItem(TreeItem<Path> root, Path path) {
    if (root.getValue().equals(path))
        return root;

    for (TreeItem<Path> child : root.getChildren()) {
        if (!path.equals(child.getValue())) {
            if (!child.getChildren().isEmpty()) {
                TreeItem<Path> item = getItem(child, path);
                if (item != null)
                    return item;
            }
        } else
            return child;
    }

    return null;
}
 
开发者ID:MrChebik,项目名称:Coconut-IDE,代码行数:18,代码来源:TreeUpdater.java

示例8: longestCommonPrefixLength

import java.nio.file.Path; //导入方法依赖的package包/类
/**
 * Computes the length of the longest common path prefix. This value is computed in O(nm) time and
 * O(1) space where n is the number of string array and m is the size of the longest prefix.
 */
@VisibleForTesting
static int longestCommonPrefixLength(ImmutableList<ImmutableList<Path>> pathList) {
  int prefixLenUpperBound = pathList.stream().min(comparingInt(ImmutableList::size)).get().size();

  for (int prefixIdx = 0; prefixIdx < prefixLenUpperBound; prefixIdx++) {
    Path curr = pathList.get(0).get(prefixIdx);
    for (ImmutableList<Path> path : pathList) {
      if (!curr.equals(path.get(prefixIdx))) {
        return prefixIdx;
      }
    }
  }
  return prefixLenUpperBound;
}
 
开发者ID:bazelbuild,项目名称:BUILD_file_generator,代码行数:19,代码来源:ProjectBuildRuleUtilities.java

示例9: validate

import java.nio.file.Path; //导入方法依赖的package包/类
@Override
@FXThread
protected boolean validate(@NotNull final VarTable vars) {

    final ImageView imageView = getImageView();

    if (!vars.has(PROP_FILE)) {
        imageView.setImage(null);
        return false;
    }

    final Path file = vars.get(PROP_FILE);

    if (!JMEFilePreviewManager.isModelFile(file)) {
        imageView.setImage(null);
        return false;
    }

    final Path renderedFile = getRenderedFile();
    if (renderedFile != null && file.equals(renderedFile)) {
        return super.validate(vars);
    }

    final int width = (int) imageView.getFitWidth();
    final int height = (int) imageView.getFitHeight();

    final JMEFilePreviewManager previewManager = JMEFilePreviewManager.getInstance();
    previewManager.showExternal(file, width, height);

    final ImageView sourceView = previewManager.getImageView();
    final ObjectProperty<Image> imageProperty = imageView.imageProperty();
    imageProperty.bind(sourceView.imageProperty());

    setRenderedFile(file);

    return super.validate(vars);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:38,代码来源:ModelImportDialog.java

示例10: findNodes

import java.nio.file.Path; //导入方法依赖的package包/类
@Override public List<Resource> findNodes(Resource resource, List<Resource> found) {
    Path filePath = getFilePath();
    if (filePath != null && filePath.equals(resource.getFilePath())) {
        found.add(this);
    }
    return found;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:8,代码来源:GroupEntryResource.java

示例11: copy

import java.nio.file.Path; //导入方法依赖的package包/类
public static Path copy(Path source, Path target, Operation operation) throws IOException {
    if (source.equals(target)) {
        return null;
    }
    Path dest = target.resolve(source.getFileName());
    if (operation == Operation.CUT && dest.equals(source)) {
        return null;
    }
    dest = getUnique(dest);
    // follow links when copying files
    EnumSet<FileVisitOption> opts = EnumSet.of(FileVisitOption.FOLLOW_LINKS);
    TreeCopier tc = new TreeCopier(source, dest, operation);
    Files.walkFileTree(source, opts, Integer.MAX_VALUE, tc);
    return dest;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:16,代码来源:Copy.java

示例12: updated

import java.nio.file.Path; //导入方法依赖的package包/类
@Override public void updated(Resource resource) {
    Path projectFilePath = super.getFilePath().resolve(ProjectFile.PROJECT_FILE);
    if (projectFilePath.equals(resource.getFilePath())) {
        setName();
        Event.fireEvent(this, new TreeModificationEvent<Resource>(valueChangedEvent(), this, this));
    }
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:8,代码来源:ProjectFolderResource.java

示例13: register

import java.nio.file.Path; //导入方法依赖的package包/类
/**
 * Register the given directory with the WatchService
 */
private void register(Path dir) throws IOException {
    WatchKey key = dir.register(watcher, ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY);
    if (trace) {
        Path prev = keys.get(key);
        if (prev == null) {
            System.out.format("register: %s\n", dir);
        } else {
            if (!dir.equals(prev)) {
                System.out.format("update: %s -> %s\n", prev, dir);
            }
        }
    }
    keys.put(key, dir);
}
 
开发者ID:robinhowlett,项目名称:handycapper,代码行数:18,代码来源:WatchDir.java

示例14: readImpl

import java.nio.file.Path; //导入方法依赖的package包/类
@Override
@BackgroundThread
protected void readImpl(@NotNull final ConnectionOwner owner, @NotNull final ByteBuffer buffer) {

    final Path assetPath = Paths.get(readString(buffer));
    final Path fileToOpen = Paths.get(readString(buffer));

    final EditorConfig editorConfig = EditorConfig.getInstance();
    final Path currentAsset = editorConfig.getCurrentAsset();

    if (currentAsset != null && assetPath.equals(currentAsset)) {
        EXECUTOR_MANAGER.addFXTask(() -> openFile(fileToOpen));
    } else {
        EXECUTOR_MANAGER.addFXTask(() -> {

            final OpenAssetAction action = new OpenAssetAction();
            action.openAssetFolder(assetPath);

            final EventHandler<Event> eventHandler = new EventHandler<Event>() {

                @Override
                public void handle(final Event event) {
                    FX_EVENT_MANAGER.removeEventHandler(AssetComponentLoadedEvent.EVENT_TYPE, this);
                    openFile(fileToOpen);
                }
            };

            FX_EVENT_MANAGER.addEventHandler(AssetComponentLoadedEvent.EVENT_TYPE, eventHandler);
        });

    }
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:33,代码来源:OpenFileClientCommand.java

示例15: ClassLoaderTest

import java.nio.file.Path; //导入方法依赖的package包/类
public ClassLoaderTest(Path policy, boolean useSCL) {
    this.useSCL = useSCL;

    List<String> argList = new LinkedList<>();
    argList.add("-Duser.language=en");
    argList.add("-Duser.region=US");

    boolean malformedPolicy = false;
    if (policy == null) {
        smMsg = "Without SecurityManager";
    } else {
        malformedPolicy = policy.equals(INVALID_POLICY);
        argList.add("-Djava.security.manager");
        argList.add("-Djava.security.policy=" +
                policy.toFile().getAbsolutePath());
        smMsg = "With SecurityManager";
    }

    if (useSCL) {
        autoAddModArg = "";
        addmodArg = "";
    } else {
        argList.add("-Djava.system.class.loader=cl.TestClassLoader");
        autoAddModArg = "--add-modules=cl";
        addmodArg = "--add-modules=mcl";
    }

    if (malformedPolicy) {
        expectedStatus = "FAIL";
        expectedMsg = POLICY_ERROR;
    } else if (useSCL) {
        expectedStatus = "PASS";
        expectedMsg = SYSTEM_CL_MSG;
    } else {
        expectedStatus = "PASS";
        expectedMsg = CUSTOM_CL_MSG;
    }
    commonArgs = Collections.unmodifiableList(argList);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:40,代码来源:ClassLoaderTest.java


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