本文整理了Java中org.uberfire.java.nio.file.Path.startsWith()
方法的一些代码示例,展示了Path.startsWith()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Path.startsWith()
方法的具体详情如下:
包路径:org.uberfire.java.nio.file.Path
类名称:Path
方法名:startsWith
暂无
代码示例来源:origin: org.kie.workbench.screens/kie-wb-common-library-backend
protected boolean isHidden(Path path) {
return path.getFileName().startsWith(".");
}
代码示例来源:origin: org.uberfire/uberfire-project-backend
private String getPackagePathSuffix(final org.uberfire.java.nio.file.Path nioModuleRootPath,
final org.uberfire.java.nio.file.Path nioPackagePath) {
final org.uberfire.java.nio.file.Path nioMainSrcPath = nioModuleRootPath.resolve(MAIN_SRC_PATH);
final org.uberfire.java.nio.file.Path nioTestSrcPath = nioModuleRootPath.resolve(TEST_SRC_PATH);
final org.uberfire.java.nio.file.Path nioMainResourcesPath = nioModuleRootPath.resolve(MAIN_RESOURCES_PATH);
final org.uberfire.java.nio.file.Path nioTestResourcesPath = nioModuleRootPath.resolve(TEST_RESOURCES_PATH);
String packageName = null;
org.uberfire.java.nio.file.Path packagePath = null;
if (nioPackagePath.startsWith(nioMainSrcPath)) {
packagePath = nioMainSrcPath.relativize(nioPackagePath);
packageName = packagePath.toString();
} else if (nioPackagePath.startsWith(nioTestSrcPath)) {
packagePath = nioTestSrcPath.relativize(nioPackagePath);
packageName = packagePath.toString();
} else if (nioPackagePath.startsWith(nioMainResourcesPath)) {
packagePath = nioMainResourcesPath.relativize(nioPackagePath);
packageName = packagePath.toString();
} else if (nioPackagePath.startsWith(nioTestResourcesPath)) {
packagePath = nioTestResourcesPath.relativize(nioPackagePath);
packageName = packagePath.toString();
}
return packageName;
}
代码示例来源:origin: org.guvnor/guvnor-project-backend
private String getPackagePathSuffix(final org.uberfire.java.nio.file.Path nioProjectRootPath,
final org.uberfire.java.nio.file.Path nioPackagePath) {
final org.uberfire.java.nio.file.Path nioMainSrcPath = nioProjectRootPath.resolve(MAIN_SRC_PATH);
final org.uberfire.java.nio.file.Path nioTestSrcPath = nioProjectRootPath.resolve(TEST_SRC_PATH);
final org.uberfire.java.nio.file.Path nioMainResourcesPath = nioProjectRootPath.resolve(MAIN_RESOURCES_PATH);
final org.uberfire.java.nio.file.Path nioTestResourcesPath = nioProjectRootPath.resolve(TEST_RESOURCES_PATH);
String packageName = null;
org.uberfire.java.nio.file.Path packagePath = null;
if (nioPackagePath.startsWith(nioMainSrcPath)) {
packagePath = nioMainSrcPath.relativize(nioPackagePath);
packageName = packagePath.toString();
} else if (nioPackagePath.startsWith(nioTestSrcPath)) {
packagePath = nioTestSrcPath.relativize(nioPackagePath);
packageName = packagePath.toString();
} else if (nioPackagePath.startsWith(nioMainResourcesPath)) {
packagePath = nioMainResourcesPath.relativize(nioPackagePath);
packageName = packagePath.toString();
} else if (nioPackagePath.startsWith(nioTestResourcesPath)) {
packagePath = nioTestResourcesPath.relativize(nioPackagePath);
packageName = packagePath.toString();
}
return packageName;
}
代码示例来源:origin: kiegroup/appformer
private String getPackagePathSuffix(final org.uberfire.java.nio.file.Path nioModuleRootPath,
final org.uberfire.java.nio.file.Path nioPackagePath) {
final org.uberfire.java.nio.file.Path nioMainSrcPath = nioModuleRootPath.resolve(MAIN_SRC_PATH);
final org.uberfire.java.nio.file.Path nioTestSrcPath = nioModuleRootPath.resolve(TEST_SRC_PATH);
final org.uberfire.java.nio.file.Path nioMainResourcesPath = nioModuleRootPath.resolve(MAIN_RESOURCES_PATH);
final org.uberfire.java.nio.file.Path nioTestResourcesPath = nioModuleRootPath.resolve(TEST_RESOURCES_PATH);
String packageName = null;
org.uberfire.java.nio.file.Path packagePath = null;
if (nioPackagePath.startsWith(nioMainSrcPath)) {
packagePath = nioMainSrcPath.relativize(nioPackagePath);
packageName = packagePath.toString();
} else if (nioPackagePath.startsWith(nioTestSrcPath)) {
packagePath = nioTestSrcPath.relativize(nioPackagePath);
packageName = packagePath.toString();
} else if (nioPackagePath.startsWith(nioMainResourcesPath)) {
packagePath = nioMainResourcesPath.relativize(nioPackagePath);
packageName = packagePath.toString();
} else if (nioPackagePath.startsWith(nioTestResourcesPath)) {
packagePath = nioTestResourcesPath.relativize(nioPackagePath);
packageName = packagePath.toString();
}
return packageName;
}
代码示例来源:origin: kiegroup/appformer
@Test
public void startsWithPath() {
final Path path = GeneralPathImpl.create(fs,
"/path/to/file.txt",
false);
assertThatThrownBy(() -> path.startsWith((Path) null))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Parameter named 'other' should be not null!");
}
代码示例来源:origin: kiegroup/appformer
@Test
public void startsWith() {
final Path path = GeneralPathImpl.create(fs,
"/path/to/file.txt",
false);
assertThatThrownBy(() -> path.startsWith((String) null))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Parameter named 'other' should be not null!");
}
代码示例来源:origin: org.kie.workbench.screens/kie-wb-common-data-modeller-backend
/**
* Given a path within a module calculates the expected class name for the given class.
*/
public String calculateClassName(final Module module,
final org.uberfire.backend.vfs.Path path) {
PortablePreconditions.checkNotNull("module", module);
if (path == null) {
return null;
}
final Package defaultPackage = moduleService.resolveDefaultPackage(module);
if (defaultPackage == null) {
return null;
}
final Path mainSrcNioPath = Paths.convert(defaultPackage.getPackageMainSrcPath());
final Path testSrcNioPath = Paths.convert(defaultPackage.getPackageTestSrcPath());
final Path nioPath = Paths.convert(path);
Path relativePath = null;
if (mainSrcNioPath != null && nioPath.startsWith(mainSrcNioPath)) {
relativePath = mainSrcNioPath.relativize(nioPath);
} else if (testSrcNioPath != null && nioPath.startsWith(testSrcNioPath)) {
relativePath = testSrcNioPath.relativize(nioPath);
}
if (relativePath != null) {
String className = relativePath.toString().replace("/", ".");
return className.substring(0, className.lastIndexOf(".java"));
}
return null;
}
代码示例来源:origin: kiegroup/appformer
/**
* Substring the second path from the first. This can be used to for example to substring the repository prefix from a Path.
* @param wholePath What we want to substring from the first Path
* @param prefixToRemove The Path we want to substring
* @return The result. For example the File URI from the Repository root or from a submodule root.
* @throws IllegalStateException When the the prefix is longer than the URI where it is removed from.
*/
public static String removePrefix(final Path wholePath,
final Path prefixToRemove) {
PortablePreconditions.checkNotNull("prefixToRemove", prefixToRemove);
PortablePreconditions.checkNotNull("wholePath", wholePath);
if (prefixToRemove.toURI().length() > wholePath.toURI().length()) {
throw new IllegalArgumentException("Prefix is longer than the URI where it is being removed from.");
}
final org.uberfire.java.nio.file.Path nioWholePath = convert(wholePath);
final org.uberfire.java.nio.file.Path nioPrefixToRemove = convert(prefixToRemove);
if (!nioWholePath.startsWith(nioPrefixToRemove)) {
throw new IllegalArgumentException("The beginning of the whole Path " + nioWholePath + " does not match the prefix path " + nioPrefixToRemove + ".");
}
return nioPrefixToRemove.relativize(nioWholePath).toString();
}
代码示例来源:origin: kiegroup/appformer
if (nioResource.startsWith(nioMainSrcPath)) {
packagePath = nioMainSrcPath.relativize(nioResource);
packageName = packagePath.toString().replaceAll("/",
".");
} else if (nioResource.startsWith(nioTestSrcPath)) {
packagePath = nioTestSrcPath.relativize(nioResource);
packageName = packagePath.toString().replaceAll("/",
".");
} else if (nioResource.startsWith(nioMainResourcesPath)) {
packagePath = nioMainResourcesPath.relativize(nioResource);
packageName = packagePath.toString().replaceAll("/",
".");
} else if (nioResource.startsWith(nioTestResourcesPath)) {
packagePath = nioTestResourcesPath.relativize(nioResource);
packageName = packagePath.toString().replaceAll("/",
代码示例来源:origin: org.uberfire/uberfire-project-backend
if (nioResource.startsWith(nioMainSrcPath)) {
packagePath = nioMainSrcPath.relativize(nioResource);
packageName = packagePath.toString().replaceAll("/",
".");
} else if (nioResource.startsWith(nioTestSrcPath)) {
packagePath = nioTestSrcPath.relativize(nioResource);
packageName = packagePath.toString().replaceAll("/",
".");
} else if (nioResource.startsWith(nioMainResourcesPath)) {
packagePath = nioMainResourcesPath.relativize(nioResource);
packageName = packagePath.toString().replaceAll("/",
".");
} else if (nioResource.startsWith(nioTestResourcesPath)) {
packagePath = nioTestResourcesPath.relativize(nioResource);
packageName = packagePath.toString().replaceAll("/",
代码示例来源:origin: org.guvnor/guvnor-project-backend
if (nioResource.startsWith(nioMainSrcPath)) {
packagePath = nioMainSrcPath.relativize(nioResource);
packageName = packagePath.toString().replaceAll("/",
".");
} else if (nioResource.startsWith(nioTestSrcPath)) {
packagePath = nioTestSrcPath.relativize(nioResource);
packageName = packagePath.toString().replaceAll("/",
".");
} else if (nioResource.startsWith(nioMainResourcesPath)) {
packagePath = nioMainResourcesPath.relativize(nioResource);
packageName = packagePath.toString().replaceAll("/",
".");
} else if (nioResource.startsWith(nioTestResourcesPath)) {
packagePath = nioTestResourcesPath.relativize(nioResource);
packageName = packagePath.toString().replaceAll("/",
代码示例来源:origin: org.guvnor/guvnor-project-backend
@Override
public boolean isPom(final Path resource) {
try {
//Null resource paths cannot resolve to a Project
if (resource == null) {
return false;
}
//Check if path equals pom.xml
final Project project = resolveProject(resource);
//It's possible that the Incremental Build attempts to act on a Project file before the project has been fully created.
//This should be a short-term issue that will be resolved when saving a project batches pom.xml, kmodule.xml and project.imports
//etc into a single git-batch. At present they are saved individually leading to multiple Incremental Build requests.
if (project == null) {
return false;
}
final org.uberfire.java.nio.file.Path path = Paths.convert(resource).normalize();
final org.uberfire.java.nio.file.Path pomFilePath = Paths.convert(project.getPomXMLPath());
return path.startsWith(pomFilePath);
} catch (Exception e) {
throw ExceptionUtilities.handleException(e);
}
}
代码示例来源:origin: kiegroup/appformer
@Override
public boolean isPom(final Path resource) {
try {
//Null resource paths cannot resolve to a Module
if (resource == null) {
return false;
}
//Check if path equals pom.xml
final Module module = resolveModule(resource);
//It's possible that the Incremental Build attempts to act on a Module file before the module has been fully created.
//This should be a short-term issue that will be resolved when saving a module batches pom.xml, kmodule.xml and project.imports
//etc into a single git-batch. At present they are saved individually leading to multiple Incremental Build requests.
if (module == null) {
return false;
}
final org.uberfire.java.nio.file.Path path = Paths.convert(resource).normalize();
final org.uberfire.java.nio.file.Path pomFilePath = Paths.convert(module.getPomXMLPath());
return path.startsWith(pomFilePath);
} catch (Exception e) {
throw ExceptionUtilities.handleException(e);
}
}
代码示例来源:origin: org.kie.workbench.services/kie-wb-common-services-backend
@Override
public boolean isKModule(final Path resource) {
try {
//Null resource paths cannot resolve to a Module
if (resource == null) {
return false;
}
//Check if path equals kmodule.xml
final KieModule module = moduleService.resolveModule(resource, false);
//It's possible that the Incremental Build attempts to act on a Module file before the module has been fully created.
//This should be a short-term issue that will be resolved when saving a module batches pom.xml, kmodule.xml and project.imports
//etc into a single git-batch. At present they are saved individually leading to multiple Incremental Build requests.
if (module == null) {
return false;
}
final org.uberfire.java.nio.file.Path path = Paths.convert(resource).normalize();
final org.uberfire.java.nio.file.Path kmoduleFilePath = Paths.convert(module.getKModuleXMLPath());
return path.startsWith(kmoduleFilePath);
} catch (Exception e) {
throw ExceptionUtilities.handleException(e);
}
}
代码示例来源:origin: org.uberfire/uberfire-project-backend
@Override
public boolean isPom(final Path resource) {
try {
//Null resource paths cannot resolve to a Module
if (resource == null) {
return false;
}
//Check if path equals pom.xml
final Module module = resolveModule(resource);
//It's possible that the Incremental Build attempts to act on a Module file before the module has been fully created.
//This should be a short-term issue that will be resolved when saving a module batches pom.xml, kmodule.xml and project.imports
//etc into a single git-batch. At present they are saved individually leading to multiple Incremental Build requests.
if (module == null) {
return false;
}
final org.uberfire.java.nio.file.Path path = Paths.convert(resource).normalize();
final org.uberfire.java.nio.file.Path pomFilePath = Paths.convert(module.getPomXMLPath());
return path.startsWith(pomFilePath);
} catch (Exception e) {
throw ExceptionUtilities.handleException(e);
}
}
代码示例来源:origin: kiegroup/appformer
assertTrue(path.startsWith(create(fs,
"c:\\",
false)));
assertTrue(path.startsWith(create(fs,
"c:\\path",
false)));
assertTrue(path.startsWith(create(fs,
"c:\\path\\to\\",
false)));
assertTrue(path.startsWith(create(fs,
"c:\\path\\to\\file.txt",
false)));
assertFalse(path.startsWith(create(fs,
"c:\\to\\file.txt",
false)));
assertFalse(path.startsWith(create(fs,
"d:\\",
false)));
assertFalse(path.startsWith(create(fs,
"/d:/",
false)));
assertFalse(path.startsWith(create(fs,
"d:\\path\\to\\file.txt",
false)));
assertTrue(path.startsWith(create(fs,
"/c:/",
false)));
assertTrue(path.startsWith(create(fs,
"/c:/path/",
代码示例来源:origin: kiegroup/appformer
false);
assertTrue(path.startsWith(create(fs,
"/path",
false)));
assertTrue(path.startsWith(create(fs,
"/path/to",
false)));
assertTrue(path.startsWith(create(fs,
"/path/to/file.txt",
false)));
assertFalse(path.startsWith(create(fs,
"/p/th/to/file.txt",
false)));
assertFalse(path.startsWith(create(fs,
"/some/other/path/to/file.txt",
false)));
assertFalse(path.startsWith(create(fs,
"path/to/file.txt",
false)));
assertFalse(path.startsWith(create(fs,
"path/to",
false)));
assertFalse(path.startsWith(create(fs,
"to",
false)));
内容来源于网络,如有侵权,请联系作者删除!