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

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

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

Path.normalize介绍

暂无

代码示例

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

@Override
public boolean isKModule( final Path resource ) {
  //Null resource paths cannot resolve to a Project
  if ( resource == null ) {
    return false;
  }
  //Check if path equals kmodule.xml
  final Project project = resolveProject( resource );
  final org.kie.commons.java.nio.file.Path path = paths.convert( resource ).normalize();
  final org.kie.commons.java.nio.file.Path kmoduleFilePath = paths.convert( project.getKModuleXMLPath() );
  return path.startsWith( kmoduleFilePath );
}

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

@Override
public boolean isPom( final Path resource ) {
  //Null resource paths cannot resolve to a Project
  if ( resource == null ) {
    return false;
  }
  //Check if path equals pom.xml
  final Project project = resolveProject( resource );
  final org.kie.commons.java.nio.file.Path path = paths.convert( resource ).normalize();
  final org.kie.commons.java.nio.file.Path pomFilePath = paths.convert( project.getPomXMLPath() );
  return path.startsWith( pomFilePath );
}

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

@Override
public boolean isPom( final Path resource ) {
  //Null resource paths cannot resolve to a Project
  if ( resource == null ) {
    return false;
  }
  //Check if path equals pom.xml
  final Path projectRoot = resolveProject( resource );
  final org.kie.commons.java.nio.file.Path path = paths.convert( resource ).normalize();
  final org.kie.commons.java.nio.file.Path pomFilePath = paths.convert( projectRoot ).resolve( POM_PATH );
  return path.startsWith( pomFilePath );
}

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

@Override
public boolean isKModule( final Path resource ) {
  //Null resource paths cannot resolve to a Project
  if ( resource == null ) {
    return false;
  }
  //Check if path equals kmodule.xml
  final Path projectRoot = resolveProject( resource );
  final org.kie.commons.java.nio.file.Path path = paths.convert( resource ).normalize();
  final org.kie.commons.java.nio.file.Path kmoduleFilePath = paths.convert( projectRoot ).resolve( KMODULE_PATH );
  return path.startsWith( kmoduleFilePath );
}

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

org.kie.commons.java.nio.file.Path path = paths.convert( resource ).normalize();

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

org.kie.commons.java.nio.file.Path path = paths.convert( resource ).normalize();

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

相关文章