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

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

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

Path.toRealPath介绍

暂无

代码示例

代码示例来源: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.guvnor/guvnor-core-services-backend

@Override
public Metadata getMetadata( final Path resource ) {
  final org.kie.commons.java.nio.file.Path path = paths.convert( resource );
  final DublinCoreView dcoreView = ioService.getFileAttributeView( path, DublinCoreView.class );
  final DiscussionView discussView = ioService.getFileAttributeView( path, DiscussionView.class );
  final OtherMetaView otherMetaView = ioService.getFileAttributeView( path, OtherMetaView.class );
  final VersionAttributeView versionAttributeView = ioService.getFileAttributeView( path, VersionAttributeView.class );
  return newMetadata()
      .withPath( paths.convert( path.toRealPath() ) )
      .withCheckinComment( versionAttributeView.readAttributes().history().records().size() > 0 ? versionAttributeView.readAttributes().history().records().get( versionAttributeView.readAttributes().history().records().size() - 1 ).comment() : null )
      .withLastContributor( versionAttributeView.readAttributes().history().records().size() > 0 ? versionAttributeView.readAttributes().history().records().get( versionAttributeView.readAttributes().history().records().size() - 1 ).author() : null )
      .withCreator( versionAttributeView.readAttributes().history().records().size() > 0 ? versionAttributeView.readAttributes().history().records().get( 0 ).author() : null )
      .withLastModified( new Date( versionAttributeView.readAttributes().lastModifiedTime().toMillis() ) )
      .withDateCreated( new Date( versionAttributeView.readAttributes().creationTime().toMillis() ) )
      .withSubject( dcoreView.readAttributes().subjects().size() > 0 ? dcoreView.readAttributes().subjects().get( 0 ) : null )
      .withType( dcoreView.readAttributes().types().size() > 0 ? dcoreView.readAttributes().types().get( 0 ) : null )
      .withExternalRelation( dcoreView.readAttributes().relations().size() > 0 ? dcoreView.readAttributes().relations().get( 0 ) : null )
      .withExternalSource( dcoreView.readAttributes().sources().size() > 0 ? dcoreView.readAttributes().sources().get( 0 ) : null )
      .withDescription( dcoreView.readAttributes().descriptions().size() > 0 ? dcoreView.readAttributes().descriptions().get( 0 ) : null )
      .withCategories( otherMetaView.readAttributes().categories() )
      .withDiscussion( discussView.readAttributes().discussion() )
      .withVersion( new ArrayList<VersionRecord>( versionAttributeView.readAttributes().history().records().size() ) {{
        for ( final VersionRecord record : versionAttributeView.readAttributes().history().records() ) {
          add( new PortableVersionRecord( record.id(), record.author(), record.comment(), record.date(), record.uri() ) );
        }
      }} )
      .build();
}

相关文章