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

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

本文整理了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:

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

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

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

代码示例

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

@Override
public String getElementName() {
  if (this.names.length == 0)
    return DEFAULT_PACKAGE_NAME;
  return Util.concatWith(this.names, '.');
}
/**

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

public String getElementName() {
  if (this.names.length == 0)
    return DEFAULT_PACKAGE_NAME;
  return Util.concatWith(this.names, '.');
}
/**

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

public String getElementName() {
  if (this.names.length == 0)
    return DEFAULT_PACKAGE_NAME;
  return Util.concatWith(this.names, '.');
}
/**

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

public String getElementName() {
  if (this.names.length == 0)
    return DEFAULT_PACKAGE_NAME;
  return Util.concatWith(this.names, '.');
}
/**

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

public String getElementName() {
  if (this.names.length == 0)
    return DEFAULT_PACKAGE_NAME;
  return Util.concatWith(this.names, '.');
}
/**

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

public String getElementName() {
  if (this.names.length == 0)
    return DEFAULT_PACKAGE_NAME;
  return Util.concatWith(this.names, '.');
}
/**

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

private IBinaryType getJarBinaryTypeInfo(PackageFragment pkg, boolean fullyInitialize) throws CoreException, IOException, ClassFormatException {
  JarPackageFragmentRoot root = (JarPackageFragmentRoot) pkg.getParent();
  ZipFile zip = null;
  try {
    zip = root.getJar();
    String entryName = Util.concatWith(pkg.names, getElementName(), '/');
    ZipEntry ze = zip.getEntry(entryName);
    if (ze != null) {
      byte contents[] = org.eclipse.jdt.internal.compiler.util.Util.getZipEntryByteContent(ze, zip);
      String fileName = root.getHandleIdentifier() + IDependent.JAR_FILE_ENTRY_SEPARATOR + entryName;
      return new ClassFileReader(contents, fileName.toCharArray(), fullyInitialize);
    }
  } finally {
    JavaModelManager.getJavaModelManager().closeZipFile(zip);
  }
  return null;
}
public IBuffer getBuffer() throws JavaModelException {

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

private IBinaryType getJarBinaryTypeInfo(PackageFragment pkg, boolean fullyInitialize) throws CoreException, IOException, ClassFormatException {
  JarPackageFragmentRoot root = (JarPackageFragmentRoot) pkg.getParent();
  ZipFile zip = null;
  try {
    zip = root.getJar();
    String entryName = Util.concatWith(pkg.names, getElementName(), '/');
    ZipEntry ze = zip.getEntry(entryName);
    if (ze != null) {
      byte contents[] = org.eclipse.jdt.internal.compiler.util.Util.getZipEntryByteContent(ze, zip);
      String fileName = root.getHandleIdentifier() + IDependent.JAR_FILE_ENTRY_SEPARATOR + entryName;
      return new ClassFileReader(contents, fileName.toCharArray(), fullyInitialize);
    }
  } finally {
    JavaModelManager.getJavaModelManager().closeZipFile(zip);
  }
  return null;
}
public IBuffer getBuffer() throws JavaModelException {

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

private IBinaryType getJarBinaryTypeInfo(PackageFragment pkg, boolean fullyInitialize) throws CoreException, IOException, ClassFormatException {
  JarPackageFragmentRoot root = (JarPackageFragmentRoot) pkg.getParent();
  ZipFile zip = null;
  try {
    zip = root.getJar();
    String entryName = Util.concatWith(pkg.names, getElementName(), '/');
    ZipEntry ze = zip.getEntry(entryName);
    if (ze != null) {
      byte contents[] = org.eclipse.jdt.internal.compiler.util.Util.getZipEntryByteContent(ze, zip);
      String fileName = root.getHandleIdentifier() + IDependent.JAR_FILE_ENTRY_SEPARATOR + entryName;
      return new ClassFileReader(contents, fileName.toCharArray(), fullyInitialize);
    }
  } finally {
    JavaModelManager.getJavaModelManager().closeZipFile(zip);
  }
  return null;
}
public IBuffer getBuffer() throws JavaModelException {

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

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

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

private IPath getPath(IJavaElement element, boolean relativeToRoot) {
  switch (element.getElementType()) {
    case IJavaElement.JAVA_MODEL:
      return Path.EMPTY;
    case IJavaElement.JAVA_PROJECT:
      return element.getPath();
    case IJavaElement.PACKAGE_FRAGMENT_ROOT:
      if (relativeToRoot)
        return Path.EMPTY;
      return element.getPath();
    case IJavaElement.PACKAGE_FRAGMENT:
      String relativePath = Util.concatWith(((PackageFragment) element).names, '/');
      return getPath(element.getParent(), relativeToRoot).append(new Path(relativePath));
    case IJavaElement.COMPILATION_UNIT:
    case IJavaElement.CLASS_FILE:
      return getPath(element.getParent(), relativeToRoot).append(new Path(element.getElementName()));
    default:
      return getPath(element.getParent(), relativeToRoot);
  }
}

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

private IPath getPath(IJavaElement element, boolean relativeToRoot) {
  switch (element.getElementType()) {
    case IJavaElement.JAVA_MODEL:
      return Path.EMPTY;
    case IJavaElement.JAVA_PROJECT:
      return element.getPath();
    case IJavaElement.PACKAGE_FRAGMENT_ROOT:
      if (relativeToRoot)
        return Path.EMPTY;
      return element.getPath();
    case IJavaElement.PACKAGE_FRAGMENT:
      String relativePath = Util.concatWith(((PackageFragment) element).names, '/');
      return getPath(element.getParent(), relativeToRoot).append(new Path(relativePath));
    case IJavaElement.COMPILATION_UNIT:
    case IJavaElement.CLASS_FILE:
      return getPath(element.getParent(), relativeToRoot).append(new Path(element.getElementName()));
    default:
      return getPath(element.getParent(), relativeToRoot);
  }
}

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

private IPath getPath(IJavaElement element, boolean relativeToRoot) {
  switch (element.getElementType()) {
    case IJavaElement.JAVA_MODEL:
      return Path.EMPTY;
    case IJavaElement.JAVA_PROJECT:
      return element.getPath();
    case IJavaElement.PACKAGE_FRAGMENT_ROOT:
      if (relativeToRoot)
        return Path.EMPTY;
      return element.getPath();
    case IJavaElement.PACKAGE_FRAGMENT:
      String relativePath = Util.concatWith(((PackageFragment) element).names, '/');
      return getPath(element.getParent(), relativeToRoot).append(new Path(relativePath));
    case IJavaElement.COMPILATION_UNIT:
    case IJavaElement.CLASS_FILE:
      return getPath(element.getParent(), relativeToRoot).append(new Path(element.getElementName()));
    default:
      return getPath(element.getParent(), relativeToRoot);
  }
}

相关文章

Util类方法