org.kie.commons.java.nio.file.Path.toUri()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(9.8k)|赞(0)|评价(0)|浏览(124)

本文整理了Java中org.kie.commons.java.nio.file.Path.toUri()方法的一些代码示例,展示了Path.toUri()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Path.toUri()方法的具体详情如下:
包路径:org.kie.commons.java.nio.file.Path
类名称:Path
方法名:toUri

Path.toUri介绍

暂无

代码示例

代码示例来源:origin: org.kie.guvnor/guvnor-commons-services-api

@Override
public boolean accepts( final Path path ) {
  final String pattern = getPattern();
  final String suffix = "." + pattern;
  final String uri = path.toUri().toString();
  return uri.substring( uri.length() - suffix.length() ).equals( suffix );
}

代码示例来源:origin: org.kie.guvnor/guvnor-core-services-backend

@Override
public boolean accept( final org.kie.commons.java.nio.file.Path path ) {
  boolean accept = super.accept( path );
  if ( !accept ) {
    return accept;
  }
  if ( !Files.isRegularFile( path ) ) {
    return false;
  }
  final String uri = path.toUri().toString();
  if ( uri.substring( uri.length() - extension.length() ).equals( extension ) ) {
    return true;
  }
  return false;
}

代码示例来源:origin: org.kie.commons/kie-commons-io

@Override
  public Object value() {
    return file.toUri().toString();
  }
} );

代码示例来源:origin: org.kie.commons/kie-nio2-jgit

@Override
  public String uri() {
    return fs.getPath( commit.name(), path ).toUri().toString();
  }
} );

代码示例来源:origin: org.kie.commons/kie-nio2-api

/**
 * @throws IllegalArgumentException
 * @throws ProviderNotFoundException
 * @throws ServiceConfigurationError
 * @throws IOException
 * @throws SecurityException
 * @see <a href="http://docs.oracle.com/javase/7/docs/api/java/nio/file/FileSystems.html#newFileSystem(java.nio.file.Path, java.lang.ClassLoader)">Original JavaDoc</a>
 */
public static FileSystem newFileSystem(final Path path, final ClassLoader loader)
    throws IllegalArgumentException, ProviderNotFoundException, ServiceConfigurationError, IOException, SecurityException {
  checkNotNull("path", path);
  final Map<String, ?> env = emptyMap();
  return newFileSystem(path.toUri(), env, null);
}

代码示例来源:origin: org.kie.guvnor/guvnor-commons-builder

@Override
public boolean accepts(final Path path) {
  final String uri = path.toUri().toString();
  return uri.substring(uri.length() - extension.length()).equals(extension);
}

代码示例来源:origin: org.kie.commons/kie-commons-io

@Override
  public Map<String, String> buildContent() {
    return new HashMap<String, String>() {{
      put( "fs_scheme", fileSystem.getRootDirectories().iterator().next().toUri().getScheme() );
      put( "fs_id", ( (FileSystemId) fileSystem ).id() );
      put( "fs_uri", fileSystem.toString() );
    }};
  }
}

代码示例来源:origin: org.kie.workbench.services/kie-wb-common-builder

private Path makePath(final String prefix,
           final String suffix) throws URISyntaxException {
  Path path = mock(Path.class);
  when(
      path.toUri()
  ).thenReturn(
      new URI(prefix + suffix)
  );
  return path;
}

代码示例来源:origin: org.kie.guvnor/guvnor-commons-builder

private Path makePath(final String prefix,
           final String suffix) throws URISyntaxException {
  Path path = mock(Path.class);
  when(
      path.toUri()
  ).thenReturn(
      new URI(prefix + suffix)
  );
  return path;
}

代码示例来源:origin: org.kie.workbench.services/kie-wb-common-builder

@Override
public boolean accepts(final Path path) {
  final String uri = path.toUri().toString();
  return uri.substring(uri.length() - extension.length()).equals(extension);
}

代码示例来源:origin: org.kie.guvnor/guvnor-commons-builder

private void visitPaths( final DirectoryStream<org.kie.commons.java.nio.file.Path> directoryStream ) {
  for ( final org.kie.commons.java.nio.file.Path path : directoryStream ) {
    if ( Files.isDirectory( path ) ) {
      visitPaths( Files.newDirectoryStream( path ) );
    } else if ( filter.accept( path ) ) {
      final String destinationPath = path.toUri().toString().substring( projectPrefix.length() + 1 );
      final InputStream is = ioService.newInputStream( path );
      final BufferedInputStream bis = new BufferedInputStream( is );
      kieFileSystem.write( destinationPath,
                 KieServices.Factory.get().getResources().newInputStreamResource( bis ) );
      handles.put( destinationPath,
             paths.convert( path ) );
    }
  }
}

代码示例来源:origin: org.kie.commons/kie-nio2-jgit

@Test
public void testGetPath() {
  final URI newRepo = URI.create( "git://new-get-repo-name" );
  PROVIDER.newFileSystem( newRepo, EMPTY_ENV );
  final Path path = PROVIDER.getPath( URI.create( "git://master@new-get-repo-name/home" ) );
  assertThat( path ).isNotNull();
  assertThat( path.getRoot().toString() ).isEqualTo( "/" );
  assertThat( path.getRoot().toRealPath().toUri().toString() ).isEqualTo( "git://master@new-get-repo-name/" );
  assertThat( path.toString() ).isEqualTo( "/home" );
  final Path pathRelative = PROVIDER.getPath( URI.create( "git://master@new-get-repo-name/:home" ) );
  assertThat( pathRelative ).isNotNull();
  assertThat( pathRelative.toRealPath().toUri().toString() ).isEqualTo( "git://master@new-get-repo-name/:home" );
  assertThat( pathRelative.getRoot().toString() ).isEqualTo( "" );
  assertThat( pathRelative.toString() ).isEqualTo( "home" );
}

代码示例来源:origin: org.kie.commons/kie-nio2-jgit

@Test
public void testSimpleBranchedGitRoot() {
  when(fs.getSeparator()).thenReturn("/");
  final Path path = JGitPathImpl.create(fs, "/", "master@my-host", false);
  assertThat(path).isNotNull();
  assertThat(path.isAbsolute()).isTrue();
  assertThat(path.toString()).isEqualTo("/");
  assertThat(path.toUri().toString()).isEqualTo("git://master@my-host/");
  assertThat(path.getRoot().toString()).isEqualTo("/");
  assertThat(path.getNameCount()).isEqualTo(0);
}

代码示例来源:origin: org.kie.commons/kie-nio2-jgit

@Test
public void testSimpleBranchedGitRelative() {
  when(fs.getSeparator()).thenReturn("/");
  final Path path = JGitPathImpl.create(fs, "home", "master@my-host", false);
  assertThat(path).isNotNull();
  assertThat(path.isAbsolute()).isFalse();
  assertThat(path.toString()).isEqualTo("home");
  assertThat(path.toUri().toString()).isEqualTo("git://master@my-host/:home");
  assertThat(path.getRoot().toString()).isEqualTo("");
  assertThat(path.getNameCount()).isEqualTo(1);
}

代码示例来源:origin: org.kie.commons/kie-nio2-jgit

@Test
public void testPathBranchRooted2() throws IOException, GitAPIException {
  final JGitFileSystemProvider fsProvider = mock( JGitFileSystemProvider.class );
  when( fsProvider.isDefault() ).thenReturn( false );
  when( fsProvider.getScheme() ).thenReturn( "git" );
  final Git git = setupGit();
  final JGitFileSystem fileSystem = new JGitFileSystem( fsProvider, null, git, "my-repo", CredentialsProvider.getDefault() );
  final Path path = fileSystem.getPath( "test-branch", "/path/to", "some/place.txt" );
  assertThat( path ).isNotNull();
  assertThat( path.isAbsolute() ).isTrue();
  assertThat( path.toString() ).isEqualTo( "/path/to/some/place.txt" );
  assertThat( path.toUri().toString() ).isEqualTo( "git://test-branch@my-repo/path/to/some/place.txt" );
  assertThat( path.getNameCount() ).isEqualTo( 4 );
  assertThat( path.getName( 0 ).toString() ).isNotNull().isEqualTo( "path" );
  assertThat( path.getRoot().toString() ).isNotNull().isEqualTo( "/" );
}

代码示例来源:origin: org.kie.commons/kie-nio2-jgit

@Test
public void testSimpleImplicitBranchGit() {
  when(fs.getSeparator()).thenReturn("/");
  final Path path = JGitPathImpl.create(fs, "/path/to/some/place.txt", "my-host", false);
  assertThat(path).isNotNull();
  assertThat(path.isAbsolute()).isTrue();
  assertThat(path.toString()).isEqualTo("/path/to/some/place.txt");
  assertThat(path.toUri().toString()).isEqualTo("git://master@my-host/path/to/some/place.txt");
  assertThat(path.getNameCount()).isEqualTo(4);
  assertThat(path.getName(0).toString()).isNotNull().isEqualTo("path");
  assertThat(path.getRoot().toString()).isNotNull().isEqualTo("/");
}

代码示例来源:origin: org.kie.commons/kie-nio2-jgit

@Test
public void testSimpleBranchedGitRoot2() {
  when(fs.getSeparator()).thenReturn("/");
  final Path path = JGitPathImpl.create(fs, "/path/to/some/place.txt", "master@my-host", false);
  assertThat(path).isNotNull();
  assertThat(path.isAbsolute()).isTrue();
  assertThat(path.toString()).isEqualTo("/path/to/some/place.txt");
  assertThat(path.toUri().toString()).isEqualTo("git://master@my-host/path/to/some/place.txt");
  assertThat(path.getNameCount()).isEqualTo(4);
  assertThat(path.getName(0).toString()).isNotNull().isEqualTo("path");
  assertThat(path.getRoot().toString()).isNotNull().isEqualTo("/");
}

代码示例来源:origin: org.kie.commons/kie-nio2-jgit

@Test
public void testSimpleBranchedGitRoot2Spaced() throws URIException {
  when(fs.getSeparator()).thenReturn("/");
  final Path path = JGitPathImpl.create(fs, URIUtil.decode("/path/to/some/some%20place.txt"), "master@my-host", false);
  assertThat(path).isNotNull();
  assertThat(path.isAbsolute()).isTrue();
  assertThat(path.toString()).isEqualTo("/path/to/some/some place.txt");
  assertThat(path.toUri().toString()).isEqualTo("git://master@my-host/path/to/some/some%20place.txt");
  assertThat(path.getNameCount()).isEqualTo(4);
  assertThat(path.getName(0).toString()).isNotNull().isEqualTo("path");
  assertThat(path.getRoot().toString()).isNotNull().isEqualTo("/");
}

代码示例来源:origin: org.kie.commons/kie-nio2-fs

@Test
public void checkGetFileStore() {
  final SimpleFileSystemProvider fsProvider = new SimpleFileSystemProvider();
  final Path path = GeneralPathImpl.create( fsProvider.getFileSystem( URI.create( "file:///" ) ), "/path/to/file.txt", false );
  assertThat( fsProvider.getFileStore( path ) ).isNotNull();
  assertThat( fsProvider.getFileSystem( path.toUri() ).getFileStores() ).isNotNull().contains( fsProvider.getFileStore( path ) );
}

代码示例来源:origin: org.kie.commons/kie-nio2-jgit

@Test
public void testSimpleBranchedGit() {
  final Path path = JGitPathImpl.create(fs, "", "master@my-host", false);
  assertThat(path).isNotNull();
  assertThat(path.isAbsolute()).isTrue();
  assertThat(path.toString()).isEqualTo("/");
  assertThat(path.toUri().toString()).isEqualTo("git://master@my-host/");
  assertThat(path.getRoot()).isEqualTo(path);
  assertThat(path.getNameCount()).isEqualTo(0);
  assertThat(path.getRoot()).isNotNull().isEqualTo(path);
}

相关文章