org.eclipse.jdt.internal.core.util.Util.concatWith()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(10.6k)|赞(0)|评价(0)|浏览(222)

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

Util.concatWith介绍

[英]Returns the concatenation of the given array parts using the given separator between each part.

For example:

  1. array = {"a", "b"}
  2. separator = '.'
  3. => result = "a.b"
  1. array = {}
  2. separator = '.'
  3. => result = ""

[中]使用每个部分之间的给定分隔符返回给定数组部分的串联。
例如:
1.

  1. array = {"a", "b"}
  2. separator = '.'
  3. => result = "a.b"
  1. array = {}
  2. separator = '.'
  3. => result = ""

代码示例

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.core

  1. @Override
  2. public String getElementName() {
  3. if (this.names.length == 0)
  4. return DEFAULT_PACKAGE_NAME;
  5. return Util.concatWith(this.names, '.');
  6. }
  7. /**

代码示例来源:origin: com.google.code.maven-play-plugin.org.eclipse.jdt/org.eclipse.jdt.core

  1. public String getElementName() {
  2. if (this.names.length == 0)
  3. return DEFAULT_PACKAGE_NAME;
  4. return Util.concatWith(this.names, '.');
  5. }
  6. /**

代码示例来源:origin: org.eclipse.tycho/org.eclipse.jdt.core

  1. public String getElementName() {
  2. if (this.names.length == 0)
  3. return DEFAULT_PACKAGE_NAME;
  4. return Util.concatWith(this.names, '.');
  5. }
  6. /**

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.core

  1. public String getElementName() {
  2. if (this.names.length == 0)
  3. return DEFAULT_PACKAGE_NAME;
  4. return Util.concatWith(this.names, '.');
  5. }
  6. /**

代码示例来源:origin: trylimits/Eclipse-Postfix-Code-Completion

  1. public String getElementName() {
  2. if (this.names.length == 0)
  3. return DEFAULT_PACKAGE_NAME;
  4. return Util.concatWith(this.names, '.');
  5. }
  6. /**

代码示例来源:origin: org.jibx.config.3rdparty.org.eclipse/org.eclipse.jdt.core

  1. public String getElementName() {
  2. if (this.names.length == 0)
  3. return DEFAULT_PACKAGE_NAME;
  4. return Util.concatWith(this.names, '.');
  5. }
  6. /**

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.core

  1. private void seekModuleAwarePartialPackageFragments(String name, IJavaElementRequestor requestor, IPackageFragmentRoot[] moduleContext) {
  2. boolean allPrefixMatch = CharOperation.equals(name.toCharArray(), CharOperation.ALL_PREFIX);
  3. String lName = name.toLowerCase();
  4. Arrays.stream(this.packageFragments.keyTable)
  5. .filter(k -> k != null)
  6. .filter(k -> allPrefixMatch || Util.concatWith((String[])k, '.').toLowerCase().startsWith(lName))
  7. .forEach(k -> {
  8. checkModulePackages(requestor, moduleContext, this.packageFragments.getIndex(k));
  9. });
  10. }

代码示例来源:origin: org.eclipse.tycho/org.eclipse.jdt.core

  1. private void seekModuleAwarePartialPackageFragments(String name, IJavaElementRequestor requestor, IPackageFragmentRoot[] moduleContext) {
  2. boolean allPrefixMatch = CharOperation.equals(name.toCharArray(), CharOperation.ALL_PREFIX);
  3. Arrays.stream(this.packageFragments.keyTable)
  4. .filter(k -> k != null)
  5. .filter(k -> allPrefixMatch || Util.concatWith((String[])k, '.').startsWith(name))
  6. .forEach(k -> {
  7. checkModulePackages(requestor, moduleContext, this.packageFragments.getIndex(k));
  8. });
  9. }

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.core

  1. /**
  2. * Locates and returns source code for the given (binary) type, in this
  3. * SourceMapper's ZIP file, or returns <code>null</code> if source
  4. * code cannot be found.
  5. * The given simpleSourceFileName is the .java file name (without the enclosing
  6. * folder) used to create the given type (e.g. "A.java" for x/y/A$Inner.class)
  7. */
  8. public char[] findSource(IType type, String simpleSourceFileName) {
  9. PackageFragment pkgFrag = (PackageFragment) type.getPackageFragment();
  10. String name = org.eclipse.jdt.internal.core.util.Util.concatWith(pkgFrag.names, simpleSourceFileName, '/');
  11. return internalFindSource((NamedMember) type, name);
  12. }

代码示例来源:origin: org.eclipse.tycho/org.eclipse.jdt.core

  1. /**
  2. * Locates and returns source code for the given (binary) type, in this
  3. * SourceMapper's ZIP file, or returns <code>null</code> if source
  4. * code cannot be found.
  5. * The given simpleSourceFileName is the .java file name (without the enclosing
  6. * folder) used to create the given type (e.g. "A.java" for x/y/A$Inner.class)
  7. */
  8. public char[] findSource(IType type, String simpleSourceFileName) {
  9. PackageFragment pkgFrag = (PackageFragment) type.getPackageFragment();
  10. String name = org.eclipse.jdt.internal.core.util.Util.concatWith(pkgFrag.names, simpleSourceFileName, '/');
  11. return internalFindSource((NamedMember) type, name);
  12. }

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.core

  1. @Override
  2. public void close() throws JavaModelException {
  3. if (this.externalAnnotationBase != null) {
  4. String entryName = Util.concatWith(((PackageFragment) getParent()).names, this.name, '/');
  5. ExternalAnnotationTracker.unregisterClassFile(this.externalAnnotationBase, new Path(entryName));
  6. }
  7. super.close();
  8. }
  9. /**

代码示例来源:origin: org.eclipse.tycho/org.eclipse.jdt.core

  1. @Override
  2. public void close() throws JavaModelException {
  3. if (this.externalAnnotationBase != null) {
  4. String entryName = Util.concatWith(((PackageFragment) getParent()).names, this.name, '/');
  5. ExternalAnnotationTracker.unregisterClassFile(this.externalAnnotationBase, new Path(entryName));
  6. }
  7. super.close();
  8. }
  9. /**

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.core

  1. @Override
  2. public void close() throws JavaModelException {
  3. if (this.externalAnnotationBase != null) {
  4. String entryName = Util.concatWith(((PackageFragment) getParent()).names, this.name, '/');
  5. ExternalAnnotationTracker.unregisterClassFile(this.externalAnnotationBase, new Path(entryName));
  6. }
  7. super.close();
  8. }
  9. public IBuffer getBuffer() throws JavaModelException {

代码示例来源:origin: org.jibx.config.3rdparty.org.eclipse/org.eclipse.jdt.core

  1. private IBinaryType getJarBinaryTypeInfo(PackageFragment pkg, boolean fullyInitialize) throws CoreException, IOException, ClassFormatException {
  2. JarPackageFragmentRoot root = (JarPackageFragmentRoot) pkg.getParent();
  3. ZipFile zip = null;
  4. try {
  5. zip = root.getJar();
  6. String entryName = Util.concatWith(pkg.names, getElementName(), '/');
  7. ZipEntry ze = zip.getEntry(entryName);
  8. if (ze != null) {
  9. byte contents[] = org.eclipse.jdt.internal.compiler.util.Util.getZipEntryByteContent(ze, zip);
  10. String fileName = root.getHandleIdentifier() + IDependent.JAR_FILE_ENTRY_SEPARATOR + entryName;
  11. return new ClassFileReader(contents, fileName.toCharArray(), fullyInitialize);
  12. }
  13. } finally {
  14. JavaModelManager.getJavaModelManager().closeZipFile(zip);
  15. }
  16. return null;
  17. }
  18. public IBuffer getBuffer() throws JavaModelException {

代码示例来源:origin: trylimits/Eclipse-Postfix-Code-Completion

  1. private IBinaryType getJarBinaryTypeInfo(PackageFragment pkg, boolean fullyInitialize) throws CoreException, IOException, ClassFormatException {
  2. JarPackageFragmentRoot root = (JarPackageFragmentRoot) pkg.getParent();
  3. ZipFile zip = null;
  4. try {
  5. zip = root.getJar();
  6. String entryName = Util.concatWith(pkg.names, getElementName(), '/');
  7. ZipEntry ze = zip.getEntry(entryName);
  8. if (ze != null) {
  9. byte contents[] = org.eclipse.jdt.internal.compiler.util.Util.getZipEntryByteContent(ze, zip);
  10. String fileName = root.getHandleIdentifier() + IDependent.JAR_FILE_ENTRY_SEPARATOR + entryName;
  11. return new ClassFileReader(contents, fileName.toCharArray(), fullyInitialize);
  12. }
  13. } finally {
  14. JavaModelManager.getJavaModelManager().closeZipFile(zip);
  15. }
  16. return null;
  17. }
  18. public IBuffer getBuffer() throws JavaModelException {

代码示例来源:origin: com.google.code.maven-play-plugin.org.eclipse.jdt/org.eclipse.jdt.core

  1. private IBinaryType getJarBinaryTypeInfo(PackageFragment pkg, boolean fullyInitialize) throws CoreException, IOException, ClassFormatException {
  2. JarPackageFragmentRoot root = (JarPackageFragmentRoot) pkg.getParent();
  3. ZipFile zip = null;
  4. try {
  5. zip = root.getJar();
  6. String entryName = Util.concatWith(pkg.names, getElementName(), '/');
  7. ZipEntry ze = zip.getEntry(entryName);
  8. if (ze != null) {
  9. byte contents[] = org.eclipse.jdt.internal.compiler.util.Util.getZipEntryByteContent(ze, zip);
  10. String fileName = root.getHandleIdentifier() + IDependent.JAR_FILE_ENTRY_SEPARATOR + entryName;
  11. return new ClassFileReader(contents, fileName.toCharArray(), fullyInitialize);
  12. }
  13. } finally {
  14. JavaModelManager.getJavaModelManager().closeZipFile(zip);
  15. }
  16. return null;
  17. }
  18. public IBuffer getBuffer() throws JavaModelException {

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.core

  1. /**
  2. * Create a type info from the given class file in a jar and adds it to the given list of infos.
  3. *
  4. * @throws CoreException
  5. */
  6. protected static IBinaryType createInfoFromClassFileInJar(Openable classFile) throws CoreException {
  7. PackageFragment pkg = (PackageFragment) classFile.getParent();
  8. String classFilePath = Util.concatWith(pkg.names, classFile.getElementName(), '/');
  9. IBinaryType info = null;
  10. java.util.zip.ZipFile zipFile = null;
  11. try {
  12. zipFile = ((JarPackageFragmentRoot) pkg.getParent()).getJar();
  13. info = org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader.read(zipFile, classFilePath);
  14. } catch (Exception e) {
  15. throw new CoreException(Package.createStatus("Unable to parse JAR file", e)); //$NON-NLS-1$
  16. } finally {
  17. JavaModelManager.getJavaModelManager().closeZipFile(zipFile);
  18. }
  19. return info;
  20. }

代码示例来源:origin: org.eclipse.tycho/org.eclipse.jdt.core

  1. private IPath getPath(IJavaElement element, boolean relativeToRoot) {
  2. switch (element.getElementType()) {
  3. case IJavaElement.JAVA_MODEL:
  4. return Path.EMPTY;
  5. case IJavaElement.JAVA_PROJECT:
  6. return element.getPath();
  7. case IJavaElement.PACKAGE_FRAGMENT_ROOT:
  8. if (relativeToRoot)
  9. return Path.EMPTY;
  10. return element.getPath();
  11. case IJavaElement.PACKAGE_FRAGMENT:
  12. String relativePath = Util.concatWith(((PackageFragment) element).names, '/');
  13. return getPath(element.getParent(), relativeToRoot).append(new Path(relativePath));
  14. case IJavaElement.COMPILATION_UNIT:
  15. case IJavaElement.CLASS_FILE:
  16. return getPath(element.getParent(), relativeToRoot).append(new Path(element.getElementName()));
  17. default:
  18. return getPath(element.getParent(), relativeToRoot);
  19. }
  20. }

代码示例来源:origin: com.google.code.maven-play-plugin.org.eclipse.jdt/org.eclipse.jdt.core

  1. private IPath getPath(IJavaElement element, boolean relativeToRoot) {
  2. switch (element.getElementType()) {
  3. case IJavaElement.JAVA_MODEL:
  4. return Path.EMPTY;
  5. case IJavaElement.JAVA_PROJECT:
  6. return element.getPath();
  7. case IJavaElement.PACKAGE_FRAGMENT_ROOT:
  8. if (relativeToRoot)
  9. return Path.EMPTY;
  10. return element.getPath();
  11. case IJavaElement.PACKAGE_FRAGMENT:
  12. String relativePath = Util.concatWith(((PackageFragment) element).names, '/');
  13. return getPath(element.getParent(), relativeToRoot).append(new Path(relativePath));
  14. case IJavaElement.COMPILATION_UNIT:
  15. case IJavaElement.CLASS_FILE:
  16. return getPath(element.getParent(), relativeToRoot).append(new Path(element.getElementName()));
  17. default:
  18. return getPath(element.getParent(), relativeToRoot);
  19. }
  20. }

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.core

  1. private IPath getPath(IJavaElement element, boolean relativeToRoot) {
  2. switch (element.getElementType()) {
  3. case IJavaElement.JAVA_MODEL:
  4. return Path.EMPTY;
  5. case IJavaElement.JAVA_PROJECT:
  6. return element.getPath();
  7. case IJavaElement.PACKAGE_FRAGMENT_ROOT:
  8. if (relativeToRoot)
  9. return Path.EMPTY;
  10. return element.getPath();
  11. case IJavaElement.PACKAGE_FRAGMENT:
  12. String relativePath = Util.concatWith(((PackageFragment) element).names, '/');
  13. return getPath(element.getParent(), relativeToRoot).append(new Path(relativePath));
  14. case IJavaElement.COMPILATION_UNIT:
  15. case IJavaElement.CLASS_FILE:
  16. return getPath(element.getParent(), relativeToRoot).append(new Path(element.getElementName()));
  17. default:
  18. return getPath(element.getParent(), relativeToRoot);
  19. }
  20. }

相关文章

Util类方法