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

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

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

Path.getParent介绍

暂无

代码示例

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

private List<String> loadWorkItemImages( final Path resourcePath ) {
  final Path projectRoot = projectService.resolveProject( resourcePath );
  final org.kie.commons.java.nio.file.Path nioProjectPath = paths.convert( projectRoot );
  final org.kie.commons.java.nio.file.Path nioResourceParent = paths.convert( resourcePath ).getParent();
  final Collection<org.kie.commons.java.nio.file.Path> imagePaths = fileDiscoveryService.discoverFiles( nioProjectPath,
                                                     imageFilter,
                                                     true );
  final List<String> images = new ArrayList<String>();
  for ( org.kie.commons.java.nio.file.Path imagePath : imagePaths ) {
    final org.kie.commons.java.nio.file.Path relativePath = nioResourceParent.relativize( imagePath );
    images.add( relativePath.toString() );
  }
  return images;
}

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

@Override
public Path pathToRelatedKModuleFileIfAny( final Path pathToPomXML ) {
  final org.kie.commons.java.nio.file.Path directory = paths.convert( pathToPomXML ).getParent();
  final org.kie.commons.java.nio.file.Path pathToKModuleXML = directory.resolve( "src/main/resources/META-INF/kmodule.xml" );
  if ( ioService.exists( pathToKModuleXML ) ) {
    return paths.convert( pathToKModuleXML );
  } else {
    return null;
  }
}

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

public List<BreadCrumb> makeBreadCrumbs( final Path path,
                     final List<org.kie.commons.java.nio.file.Path> exclusions,
                     final Map<org.kie.commons.java.nio.file.Path, String> captionSubstitutions ) {
  final List<BreadCrumb> breadCrumbs = new ArrayList<BreadCrumb>();
  org.kie.commons.java.nio.file.Path nioPath = paths.convert( path );
  org.kie.commons.java.nio.file.Path nioFileName = nioPath.getFileName();
  while ( nioFileName != null ) {
    if ( includePath( nioPath,
             exclusions ) ) {
      String caption = nioFileName.toString();
      if ( captionSubstitutions.containsKey( nioPath ) ) {
        caption = captionSubstitutions.get( nioPath );
      }
      final BreadCrumb breadCrumb = new BreadCrumb( paths.convert( nioPath ),
                             caption );
      breadCrumbs.add( 0,
               breadCrumb );
    }
    nioPath = nioPath.getParent();
    nioFileName = nioPath.getFileName();
  }
  breadCrumbs.add( 0, new BreadCrumb( paths.convert( nioPath ),
                    getRootDirectory( nioPath ) ) );
  return breadCrumbs;
}

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

@Test
public void testParent() throws URISyntaxException {
  final URL parentUrl = this.getClass().getResource( "/" );
  final org.kie.commons.java.nio.file.Path parentNioPath = fs.getPath( parentUrl.toURI() );
  final URL childUrl = this.getClass().getResource( "/ExplorerBackendTestProjectStructureValid" );
  final org.kie.commons.java.nio.file.Path childNioPath = fs.getPath( childUrl.toURI() );
  final org.kie.commons.java.nio.file.Path childParentNioPath = childNioPath.getParent();
  assertEquals( parentNioPath,
         childParentNioPath );
}

代码示例来源:origin: org.jbpm/droolsjbpm-knowledge-services

Iterable<Path> availableForms = null;
Path processPath = fileService.getPath(processAssetPath);
Path formsPath = fileService.getPath(processPath.getParent().toUri().toString() + "/forms/");
try {

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

path = path.getParent();
  path = path.getParent();
path = path.getParent();
if ( path.getNameCount() == 0 || path == null ) {
  return null;

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

path = path.getParent();
  path = path.getParent();
path = path.getParent();
if ( path.getNameCount() == 0 || path == null ) {
  return null;

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

@Override
public List<Item> load( final Path path,
            final Path projectRoot ) {
  //Check Path exists
  final List<Item> items = new ArrayList<Item>();
  if ( !Files.exists( paths.convert( path ) ) ) {
    return items;
  }
  //Ensure Path represents a Folder
  org.kie.commons.java.nio.file.Path pPath = paths.convert( path );
  if ( !Files.isDirectory( pPath ) ) {
    pPath = pPath.getParent();
  }
  //Get list of immediate children
  final DirectoryStream<org.kie.commons.java.nio.file.Path> directoryStream = ioService.newDirectoryStream( pPath );
  for ( final org.kie.commons.java.nio.file.Path p : directoryStream ) {
    if ( filter.accept( p ) ) {
      if ( Files.isRegularFile( p ) ) {
        items.add( new FileItem( paths.convert( p ) ) );
      } else if ( Files.isDirectory( p ) ) {
        items.add( new PackageItem( paths.convert( p ) ) );
      }
    }
  }
  //Add ability to move up one level in the hierarchy
  items.add( new ParentPackageItem( paths.convert( pPath.getParent() ),
                   ".." ) );
  return items;
}

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

@Test
public void simpleRootTests() throws URISyntaxException {
  final SimpleFileSystemProvider fs = new SimpleFileSystemProvider();
  final FileSystem fileSystem = new SimpleUnixFileSystem( fsProvider, "/" );
  assertThat( fileSystem.getPath( "/" ) ).isEqualTo( fileSystem.getPath( "/path" ).getParent() );
  final URL parentUrl = this.getClass().getResource( "/" );
  final Path parentNioPath = fs.getPath( parentUrl.toURI() );
  final URL childUrl = this.getClass().getResource( "/Folder" );
  final Path childNioPath = fs.getPath( childUrl.toURI() );
  final Path childParentNioPath = childNioPath.getParent();
  System.out.println( parentNioPath );
  assertThat( parentNioPath ).isEqualTo( childParentNioPath );
}

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

public static Path createDirectories( final Path dir,
                   final FileAttribute<?>... attrs )
    throws UnsupportedOperationException, FileAlreadyExistsException, IOException, SecurityException {
  checkNotNull( "dir", dir );
  final Path absoluteDir = dir.toAbsolutePath();
  if ( !notExists( absoluteDir ) ) {
    throw new FileAlreadyExistsException( absoluteDir.toString() );
  }
  Path parent = absoluteDir.getParent();
  while ( parent != null ) {
    try {
      providerOf( parent ).checkAccess( parent );
      break;
    } catch ( NoSuchFileException x ) {
    }
    parent = parent.getParent();
  }
  if ( parent == null ) {
    throw new IOException( "Root directory does not exist" );
  }
  // create directories
  Path child = parent;
  for ( final Path name : parent.relativize( dir ) ) {
    child = child.resolve( name );
    providerOf( child ).createDirectory( child, attrs );
  }
  return dir;
}

代码示例来源:origin: org.jbpm/droolsjbpm-knowledge-services

if(processAssetPath != null && !processAssetPath.equals("")){
  processPath = fileService.getPath(processAssetPath);
  Path formsPath = fileService.getPath(processPath.getParent().toUri().toString() + "/forms/");
  if(fileService.exists(formsPath)){
    availableForms = fileService.loadFilesByType(formsPath, "ftl");

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

pPath = pPath.getParent();
items.add( new ParentFolderItem( paths.convert( pPath.getParent() ),
                 ".." ) );

代码示例来源:origin: org.kie.guvnor/guvnor-test-scenario-editor-backend

public List<Path> loadScenarioPaths(final Path path) {
  // Check Path exists
  final List<Path> items = new ArrayList<Path>();
  if (!Files.exists(paths.convert(path))) {
    return items;
  }
  // Ensure Path represents a Folder
  org.kie.commons.java.nio.file.Path pPath = paths.convert(path);
  if (!Files.isDirectory(pPath)) {
    pPath = pPath.getParent();
  }
  LinkedFilter filter =  new LinkedDotFileFilter();
  filter.setNextFilter( new LinkedMetaInfFolderFilter() );
  
  // Get list of immediate children
  final DirectoryStream<org.kie.commons.java.nio.file.Path> directoryStream = ioService
      .newDirectoryStream(pPath);
  for (final org.kie.commons.java.nio.file.Path p : directoryStream) {
    if (filter.accept(p)) {
      if (Files.isRegularFile(p)) {
        items.add(paths.convert(p));
      } else if (Files.isDirectory(p)) {
        items.add(paths.convert(p));
      }
    }
  }
  // Add ability to move up one level in the hierarchy
  //items.add(new ParentPackageItem(paths.convert(pPath.getParent()), ".."));
  return items;
}

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

items.add( new ParentFolderItem( paths.convert( pRoot.getParent() ),
                 ".." ) );

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

nioResource = nioResource.getParent();

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

private Path doResolveTestPackage( final Path resource,
                  final Path projectRoot ) {
  //The pom.xml and kmodule.xml files are not within a package
  if ( isPom( resource ) || isKModule( resource ) ) {
    return null;
  }
  //The Path must be within a Project's src/test/java or src/test/resources path
  boolean resolved = false;
  org.kie.commons.java.nio.file.Path path = paths.convert( resource ).normalize();
  final org.kie.commons.java.nio.file.Path testJavaPath = paths.convert( projectRoot ).resolve( TEST_JAVA_PATH );
  final org.kie.commons.java.nio.file.Path testResourcesPath = paths.convert( projectRoot ).resolve( TEST_RESOURCES_PATH );
  //Check if path resides within a Java or Resources path
  if ( path.startsWith( testJavaPath ) ) {
    resolved = true;
  } else if ( path.startsWith( testResourcesPath ) ) {
    resolved = true;
  }
  if ( !resolved ) {
    return null;
  }
  //If the Path is already a folder simply return it
  if ( Files.isDirectory( path ) ) {
    return resource;
  }
  path = path.getParent();
  return paths.convert( path );
}

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

private Path doResolveSrcPackage( final Path resource,
                 final Path projectRoot ) {
  //The pom.xml and kmodule.xml files are not within a package
  if ( isPom( resource ) || isKModule( resource ) ) {
    return null;
  }
  //The Path must be within a Project's src/main/java or src/main/resources path
  boolean resolved = false;
  org.kie.commons.java.nio.file.Path path = paths.convert( resource ).normalize();
  final org.kie.commons.java.nio.file.Path srcJavaPath = paths.convert( projectRoot ).resolve( SOURCE_JAVA_PATH );
  final org.kie.commons.java.nio.file.Path srcResourcesPath = paths.convert( projectRoot ).resolve( SOURCE_RESOURCES_PATH );
  //Check if path resides within a Java or Resources path
  if ( path.startsWith( srcJavaPath ) ) {
    resolved = true;
  } else if ( path.startsWith( srcResourcesPath ) ) {
    resolved = true;
  }
  if ( !resolved ) {
    return null;
  }
  //If the Path is already a folder simply return it
  if ( Files.isDirectory( path ) ) {
    return resource;
  }
  path = path.getParent();
  return paths.convert( path );
}

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

@Test
public void createDirectories() {
  final Path dir = getComposedDirectoryPath();
  assertFalse( ioService().exists( dir ) );
  ioService().createDirectories( dir, new FileAttribute<Object>() {
    @Override
    public String name() {
      return "custom";
    }
    @Override
    public Object value() {
      return dateValue;
    }
  } );
  assertTrue( ioService().exists( dir ) );
  assertTrue( ioService().exists( dir.getParent() ) );
  assertNotNull( ioService().exists( dir.getParent().getFileName() ) );
  Map<String, Object> attrs = ioService().readAttributes( dir );
  assertEquals( createDirectoriesAttrSize(), attrs.size() );
  ioService().delete( dir );
  ioService().exists( dir.getParent() );
}

相关文章