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

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

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

Path.getNameCount介绍

暂无

代码示例

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

return makeProject( path );
while ( path.getNameCount() > 0 && !path.getFileName().toString().equals( SOURCE_FILENAME ) ) {
  path = path.getParent();
if ( path.getNameCount() == 0 ) {
  return null;
if ( path.getNameCount() == 0 || path == null ) {
  return null;

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

return paths.convert( path );
while ( path.getNameCount() > 0 && !path.getFileName().toString().equals( SOURCE_FILENAME ) ) {
  path = path.getParent();
if ( path.getNameCount() == 0 ) {
  return null;
if ( path.getNameCount() == 0 || path == null ) {
  return null;

代码示例来源: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 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 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 testPathBranchNonRooted2() 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() ).isFalse();
  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 testPathBranchRooted() 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 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 testPathNonBranchRooted() 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( "/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://master@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 testPathNonBranchNonRooted() 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( "path/to/some/place.txt" );
  assertThat( path ).isNotNull();
  assertThat( path.isAbsolute() ).isFalse();
  assertThat( path.toString() ).isEqualTo( "path/to/some/place.txt" );
  assertThat( path.toUri().toString() ).isEqualTo( "git://master@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 testPathBranchNonRooted() 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() ).isFalse();
  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 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-jgit

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

代码示例来源: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);
}

相关文章