当前位置: 首页>>代码示例>>Java>>正文


Java Util.sort方法代码示例

本文整理汇总了Java中org.eclipse.jdt.internal.core.util.Util.sort方法的典型用法代码示例。如果您正苦于以下问题:Java Util.sort方法的具体用法?Java Util.sort怎么用?Java Util.sort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jdt.internal.core.util.Util的用法示例。


在下文中一共展示了Util.sort方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: matchingNodes

import org.eclipse.jdt.internal.core.util.Util; //导入方法依赖的package包/类
/**
 * Returns the matching nodes that are in the given range in the source order.
 */
protected ASTNode[] matchingNodes(int start, int end) {
	ArrayList nodes = null;
	Object[] keyTable = this.matchingNodes.keyTable;
	for (int i = 0, l = keyTable.length; i < l; i++) {
		ASTNode node = (ASTNode) keyTable[i];
		if (node != null && start <= node.sourceStart && node.sourceEnd <= end) {
			if (nodes == null) nodes = new ArrayList();
			nodes.add(node);
		}
	}
	if (nodes == null) return null;

	ASTNode[] result = new ASTNode[nodes.size()];
	nodes.toArray(result);

	// sort nodes by source starts
	Util.Comparer comparer = new Util.Comparer() {
		public int compare(Object o1, Object o2) {
			return ((ASTNode) o1).sourceStart - ((ASTNode) o2).sourceStart;
		}
	};
	Util.sort(result, comparer);
	return result;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:28,代码来源:MatchingNodeSet.java

示例2: sortParticipants

import org.eclipse.jdt.internal.core.util.Util; //导入方法依赖的package包/类
private int sortParticipants(ArrayList group, IConfigurationElement[] configElements, int index) {
	int size = group.size();
	if (size == 0) return index;
	Object[] elements = group.toArray();
	Util.sort(elements, new Util.Comparer() {
		public int compare(Object a, Object b) {
			if (a == b) return 0;
			String id = ((IConfigurationElement) a).getAttribute("id"); //$NON-NLS-1$
			if (id == null) return -1;
			IConfigurationElement[] requiredElements = ((IConfigurationElement) b).getChildren("requires"); //$NON-NLS-1$
			for (int i = 0, length = requiredElements.length; i < length; i++) {
				IConfigurationElement required = requiredElements[i];
				if (id.equals(required.getAttribute("id"))) //$NON-NLS-1$
					return 1;
			}
			return -1;
		}
	});
	for (int i = 0; i < size; i++)
		configElements[index+i] = (IConfigurationElement) elements[i];
	return index + size;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:23,代码来源:JavaModelManager.java

示例3: hasJavaLikeNamesChanged

import org.eclipse.jdt.internal.core.util.Util; //导入方法依赖的package包/类
private boolean hasJavaLikeNamesChanged() {
  char[][] currentNames = org.eclipse.jdt.internal.core.util.Util.getJavaLikeExtensions();
  int current = currentNames.length;
  char[][] prevNames = readJavaLikeNamesFile();
  if (prevNames == null) {
    if (JobManager.VERBOSE && current != 1)
      Util.verbose(
          "No Java like names found and there is atleast one non-default javaLikeName",
          System.err); // $NON-NLS-1$
    return (current != 1); // Ignore if only java
  }
  int prev = prevNames.length;
  if (current != prev) {
    if (JobManager.VERBOSE)
      Util.verbose("Java like names have changed", System.err); // $NON-NLS-1$
    return true;
  }
  if (current > 1) {
    // Sort the current java like names.
    // Copy the array to avoid modifying the Util static variable
    System.arraycopy(currentNames, 0, currentNames = new char[current][], 0, current);
    Util.sort(currentNames);
  }

  // The JavaLikeNames would have been sorted before getting stored in the file,
  // hence just do a direct compare.
  for (int i = 0; i < current; i++) {
    if (!CharOperation.equals(currentNames[i], prevNames[i])) {
      if (JobManager.VERBOSE)
        Util.verbose("Java like names have changed", System.err); // $NON-NLS-1$
      return true;
    }
  }
  return false;
}
 
开发者ID:eclipse,项目名称:che,代码行数:36,代码来源:IndexManager.java

示例4: writeJavaLikeNamesFile

import org.eclipse.jdt.internal.core.util.Util; //导入方法依赖的package包/类
private void writeJavaLikeNamesFile() {
  BufferedWriter writer = null;
  String pathName = getJavaPluginWorkingLocation().toOSString();
  try {
    char[][] currentNames = org.eclipse.jdt.internal.core.util.Util.getJavaLikeExtensions();
    int length = currentNames.length;
    if (length > 1) {
      // Sort the current java like names.
      // Copy the array to avoid modifying the Util static variable
      System.arraycopy(currentNames, 0, currentNames = new char[length][], 0, length);
      Util.sort(currentNames);
    }
    File javaLikeNamesFile = new File(pathName, "javaLikeNames.txt"); // $NON-NLS-1$
    writer = new BufferedWriter(new FileWriter(javaLikeNamesFile));
    for (int i = 0; i < length - 1; i++) {
      writer.write(currentNames[i]);
      writer.write('\n');
    }
    if (length > 0) writer.write(currentNames[length - 1]);

  } catch (IOException ignored) {
    if (JobManager.VERBOSE)
      Util.verbose("Failed to write javaLikeNames file", System.err); // $NON-NLS-1$
  } finally {
    if (writer != null) {
      try {
        writer.close();
      } catch (IOException e) {
        // ignore
      }
    }
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:34,代码来源:IndexManager.java

示例5: hasJavaLikeNamesChanged

import org.eclipse.jdt.internal.core.util.Util; //导入方法依赖的package包/类
private boolean hasJavaLikeNamesChanged() {
	char[][] currentNames = Util.getJavaLikeExtensions();
	int current = currentNames.length;
	char[][] prevNames = readJavaLikeNamesFile();
	if (prevNames == null) {
		if (VERBOSE && current != 1)
			Util.verbose("No Java like names found and there is atleast one non-default javaLikeName", System.err); //$NON-NLS-1$
		return (current != 1); //Ignore if only java
	}
	int prev = prevNames.length;
	if (current != prev) {
		if (VERBOSE)
			Util.verbose("Java like names have changed", System.err); //$NON-NLS-1$
		return true;
	}
	if (current > 1) {
		// Sort the current java like names. 
		// Copy the array to avoid modifying the Util static variable
		System.arraycopy(currentNames, 0, currentNames = new char[current][], 0, current);
		Util.sort(currentNames);
	}
	
	// The JavaLikeNames would have been sorted before getting stored in the file,
	// hence just do a direct compare.
	for (int i = 0; i < current; i++) {
		if (!CharOperation.equals(currentNames[i],prevNames[i])) {
			if (VERBOSE)
				Util.verbose("Java like names have changed", System.err); //$NON-NLS-1$
			return true;
		}
	}
	return false;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:34,代码来源:IndexManager.java

示例6: writeJavaLikeNamesFile

import org.eclipse.jdt.internal.core.util.Util; //导入方法依赖的package包/类
private void writeJavaLikeNamesFile() {
	BufferedWriter writer = null;
	String pathName = getJavaPluginWorkingLocation().toOSString();
	try {		
		char[][] currentNames = Util.getJavaLikeExtensions();
		int length = currentNames.length;
		if (length > 1) {
			// Sort the current java like names. 
			// Copy the array to avoid modifying the Util static variable
			System.arraycopy(currentNames, 0, currentNames=new char[length][], 0, length);
			Util.sort(currentNames);
		}
		File javaLikeNamesFile = new File(pathName, "javaLikeNames.txt"); //$NON-NLS-1$
		writer = new BufferedWriter(new FileWriter(javaLikeNamesFile));
		for (int i = 0; i < length-1; i++) {
			writer.write(currentNames[i]);
			writer.write('\n');
		}
		if (length > 0) 
			writer.write(currentNames[length-1]);
		
	} catch (IOException ignored) {
		if (VERBOSE)
			Util.verbose("Failed to write javaLikeNames file", System.err); //$NON-NLS-1$
	} finally {
		if (writer != null) {
			try {
				writer.close();
			} catch (IOException e) {
				// ignore
			}
		}
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:35,代码来源:IndexManager.java

示例7: evaluateVariables

import org.eclipse.jdt.internal.core.util.Util; //导入方法依赖的package包/类
/**
 * @see org.eclipse.jdt.core.eval.IEvaluationContext
 * @exception org.eclipse.jdt.internal.eval.InstallException if the code snippet class files could not be deployed.
 */
public void evaluateVariables(INameEnvironment environment, Map options, IRequestor requestor, IProblemFactory problemFactory) throws InstallException {
	deployCodeSnippetClassIfNeeded(requestor);
	VariablesEvaluator evaluator = new VariablesEvaluator(this, environment, options, requestor, problemFactory);
	ClassFile[] classes = evaluator.getClasses();
	if (classes != null) {
		if (classes.length > 0) {
			// Sort classes so that enclosing types are cached before nested types
			// otherwise an AbortCompilation is thrown in 1.5 mode since the enclosing type
			// is needed to resolve a nested type
			Util.sort(classes, new Util.Comparer() {
				public int compare(Object a, Object b) {
					if (a == b) return 0;
					ClassFile enclosing = ((ClassFile) a).enclosingClassFile;
					while (enclosing != null) {
						if (enclosing == b)
							return 1;
						enclosing = enclosing.enclosingClassFile;
					}
					return -1;
				}
			});

			// Send classes
			if (!requestor.acceptClassFiles(classes, null)) {
				throw new InstallException();
			}

			// Remember that the variables have been installed
			int count = this.variableCount;
			GlobalVariable[] variablesCopy = new GlobalVariable[count];
			System.arraycopy(this.variables, 0, variablesCopy, 0, count);
			this.installedVars = new VariablesInfo(evaluator.getPackageName(), evaluator.getClassName(), classes, variablesCopy, count);
			VAR_CLASS_COUNTER++;
		}
		this.varsChanged = false;
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:42,代码来源:EvaluationContext.java

示例8: toString

import org.eclipse.jdt.internal.core.util.Util; //导入方法依赖的package包/类
public String toString() {
  StringBuffer result = new StringBuffer("JavaSearchScope on "); // $NON-NLS-1$
  if (this.elements != null) {
    result.append("["); // $NON-NLS-1$
    for (int i = 0, length = this.elements.size(); i < length; i++) {
      JavaElement element = (JavaElement) this.elements.get(i);
      result.append("\n\t"); // $NON-NLS-1$
      result.append(element.toStringWithAncestors());
    }
    result.append("\n]"); // $NON-NLS-1$
  } else {
    if (this.pathsCount == 0) {
      result.append("[empty scope]"); // $NON-NLS-1$
    } else {
      result.append("["); // $NON-NLS-1$
      String[] paths = new String[this.relativePaths.length];
      int index = 0;
      for (int i = 0; i < this.relativePaths.length; i++) {
        String path = this.relativePaths[i];
        if (path == null) continue;
        String containerPath;
        if (ExternalFoldersManager.isInternalPathForExternalFolder(
            new Path(this.containerPaths[i]))) {
          Object target = JavaModel.getWorkspaceTarget(new Path(this.containerPaths[i]));
          containerPath = ((IFolder) target).getLocation().toOSString();
        } else {
          containerPath = this.containerPaths[i];
        }
        if (path.length() > 0) {
          paths[index++] = containerPath + '/' + path;
        } else {
          paths[index++] = containerPath;
        }
      }
      System.arraycopy(paths, 0, paths = new String[index], 0, index);
      Util.sort(paths);
      for (int i = 0; i < index; i++) {
        result.append("\n\t"); // $NON-NLS-1$
        result.append(paths[i]);
      }
      result.append("\n]"); // $NON-NLS-1$
    }
  }
  return result.toString();
}
 
开发者ID:eclipse,项目名称:che,代码行数:46,代码来源:JavaSearchScope.java

示例9: toString

import org.eclipse.jdt.internal.core.util.Util; //导入方法依赖的package包/类
public String toString() {
	StringBuffer result = new StringBuffer("JavaSearchScope on "); //$NON-NLS-1$
	if (this.elements != null) {
		result.append("["); //$NON-NLS-1$
		for (int i = 0, length = this.elements.size(); i < length; i++) {
			JavaElement element = (JavaElement)this.elements.get(i);
			result.append("\n\t"); //$NON-NLS-1$
			result.append(element.toStringWithAncestors());
		}
		result.append("\n]"); //$NON-NLS-1$
	} else {
		if (this.pathsCount == 0) {
			result.append("[empty scope]"); //$NON-NLS-1$
		} else {
			result.append("["); //$NON-NLS-1$
			String[] paths = new String[this.relativePaths.length];
			int index = 0;
			for (int i = 0; i < this.relativePaths.length; i++) {
				String path = this.relativePaths[i];
				if (path == null) continue;
				String containerPath;
				if (ExternalFoldersManager.isInternalPathForExternalFolder(new Path(this.containerPaths[i]))) {
					Object target = JavaModel.getWorkspaceTarget(new Path(this.containerPaths[i]));
					containerPath = ((IFolder) target).getLocation().toOSString();
				} else {
					containerPath = this.containerPaths[i];
				}
				if (path.length() > 0) {
					paths[index++] = containerPath + '/' + path;
				} else {
					paths[index++] = containerPath;
				}
			}
			System.arraycopy(paths, 0, paths = new String[index], 0, index);
			Util.sort(paths);
			for (int i = 0; i < index; i++) {
				result.append("\n\t"); //$NON-NLS-1$
				result.append(paths[i]);
			}
			result.append("\n]"); //$NON-NLS-1$
		}
	}
	return result.toString();
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:45,代码来源:JavaSearchScope.java


注:本文中的org.eclipse.jdt.internal.core.util.Util.sort方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。