org.aspectj.org.eclipse.jdt.internal.core.util
Class Util

java.lang.Object
  extended by org.aspectj.org.eclipse.jdt.internal.core.util.Util

public class Util
extends java.lang.Object

Provides convenient utility methods to other types in this package.


Nested Class Summary
static interface Util.BindingsToNodesMap
           
static interface Util.Comparable
           
static interface Util.Comparer
           
 
Method Summary
static java.lang.String[] arrayConcat(java.lang.String[] first, java.lang.String second)
          Returns a new array adding the second array at the end of first array.
static int combineHashCodes(int hashCode1, int hashCode2)
          Combines two hash codes to make a new one.
static int compare(byte[] a, byte[] b)
          Compares two byte arrays.
static int compare(char[] str1, char[] str2)
          Compares two strings lexicographically.
static char[] concatCompoundNameToCharArray(java.lang.String[] compoundName)
          Concatenate a String[] compound name to a continuous char[].
static java.lang.String concatenateName(java.lang.String name1, java.lang.String name2, char separator)
           
static java.lang.String concatWith(java.lang.String[] array, char separator)
          Returns the concatenation of the given array parts using the given separator between each part.
static java.lang.String concatWith(java.lang.String[] array, java.lang.String name, char separator)
          Returns the concatenation of the given array parts using the given separator between each part and appending the given name at the end.
static java.lang.String convertTypeSignature(char[] sig, int start, int length)
          Converts a type signature from the IBinaryType representation to the DC representation.
static java.lang.String defaultJavaExtension()
           
static java.lang.String editedString(java.lang.String original, TextEdit edit)
          Apply the given edit on the given string and return the updated string.
static boolean endsWithIgnoreCase(java.lang.String str, java.lang.String end)
          Returns true iff str.toLowerCase().endsWith(end.toLowerCase()) implementation is not creating extra strings.
static boolean equalArrays(java.lang.Object[] a, java.lang.Object[] b, int len)
          Compares two arrays using equals() on the elements.
static boolean equalArraysOrNull(int[] a, int[] b)
          Compares two arrays using equals() on the elements.
static boolean equalArraysOrNull(java.lang.Object[] a, java.lang.Object[] b)
          Compares two arrays using equals() on the elements.
static boolean equalArraysOrNullSortFirst(java.lang.String[] a, java.lang.String[] b)
          Compares two String arrays using equals() on the elements.
static boolean equalArraysOrNullSortFirst(Util.Comparable[] a, Util.Comparable[] b)
          Compares two arrays using equals() on the elements.
static boolean equalOrNull(java.lang.Object a, java.lang.Object b)
          Compares two objects using equals().
static boolean equalsIgnoreJavaLikeExtension(java.lang.String fileName, java.lang.String string)
           
static java.lang.String extractLastName(java.lang.String qualifiedName)
          Given a qualified name, extract the last component.
static java.lang.String[] extractParameterTypes(char[] sig)
          Extracts the parameter types from a method signature.
static java.lang.String extractReturnType(java.lang.String sig)
          Extracts the return type from a method signature.
static java.lang.String findLineSeparator(char[] text)
          Finds the first line separator used by the given text.
static IMethod findMethod(IType type, char[] selector, java.lang.String[] paramTypeSignatures, boolean isConstructor)
          Finds the IMethod element corresponding to the given selector, without creating a new dummy instance of a binary method.
static void fixTaskTags(java.util.Map defaultOptionsMap)
           
static char[][][] getAllTypeArguments(char[][] typeSignatures)
          Get all type arguments from an array of signatures.
static IAnnotation getAnnotation(JavaElement parent, IBinaryAnnotation binaryAnnotation, java.lang.String memberValuePairName)
           
static java.lang.Object getAnnotationMemberValue(JavaElement parent, MemberValuePair memberValuePair, java.lang.Object binaryValue)
           
static java.lang.Object getAnnotationMemberValue(MemberValuePair memberValuePair, Constant constant)
           
static IClassFileAttribute getAttribute(IClassFileReader classFileReader, char[] attributeName)
           
static IClassFileAttribute getAttribute(ICodeAttribute codeAttribute, char[] attributeName)
           
static IClassFileAttribute getAttribute(IFieldInfo fieldInfo, char[] attributeName)
           
static IClassFileAttribute getAttribute(IMethodInfo methodInfo, char[] attributeName)
           
static java.lang.String getDeclaringTypeSignature(java.lang.String key)
           
static char[][] getJavaLikeExtensions()
          Returns the registered Java like extensions.
static long getJdkLevel(java.lang.Object targetLibrary)
          Get the jdk level of this root.
static java.lang.String getLineSeparator(java.lang.String text, IJavaProject project)
          Returns the line separator found in the given text.
static java.lang.String getNameWithoutJavaLikeExtension(java.lang.String fileName)
          Returns the substring of the given file name, ending at the start of a Java like extension.
static java.lang.Object getNegativeAnnotationMemberValue(MemberValuePair memberValuePair, Constant constant)
           
static int getParameterCount(char[] sig)
          Returns the number of parameter types in a method signature.
static java.lang.String getProblemArgumentsForMarker(java.lang.String[] arguments)
          Put all the arguments in one String.
static java.lang.String[] getProblemArgumentsFromMarker(java.lang.String argumentsString)
          Separate all the arguments of a String made by getProblemArgumentsForMarker
static byte[] getResourceContentsAsByteArray(IFile file)
          Returns the given file's contents as a byte array.
static char[] getResourceContentsAsCharArray(IFile file)
          Returns the given file's contents as a character array.
static char[] getResourceContentsAsCharArray(IFile file, java.lang.String encoding)
           
static java.lang.String getSignature(Type type)
           
static java.lang.String getSourceAttachmentProperty(IPath path)
           
static java.lang.String[] getTrimmedSimpleNames(java.lang.String name)
          Returns a trimmed version the simples names returned by Signature.
static JavaElement getUnresolvedJavaElement(FieldBinding binding, WorkingCopyOwner workingCopyOwner, Util.BindingsToNodesMap bindingsToNodes)
          Return the java element corresponding to the given compiler binding.
static JavaElement getUnresolvedJavaElement(int localSourceStart, int localSourceEnd, JavaElement type)
          Returns the IInitializer that contains the given local variable in the given type
static JavaElement getUnresolvedJavaElement(MethodBinding methodBinding, WorkingCopyOwner workingCopyOwner, Util.BindingsToNodesMap bindingsToNodes)
          Return the java element corresponding to the given compiler binding.
static JavaElement getUnresolvedJavaElement(TypeBinding typeBinding, WorkingCopyOwner workingCopyOwner, Util.BindingsToNodesMap bindingsToNodes)
          Return the java element corresponding to the given compiler binding.
static int indexOfEnclosingPath(IPath checkedPath, IPath[] paths, int pathCount)
           
static int indexOfJavaLikeExtension(java.lang.String fileName)
           
static int indexOfMatchingPath(IPath checkedPath, IPath[] paths, int pathCount)
           
static int indexOfNestedPath(IPath checkedPath, IPath[] paths, int pathCount)
           
protected static boolean isAttributeSupported(int attribute)
          Returns whether the local file system supports accessing and modifying the given attribute.
static boolean isExcluded(IJavaElement element)
           
static boolean isExcluded(IPath resourcePath, char[][] inclusionPatterns, char[][] exclusionPatterns, boolean isFolderPath)
           
static boolean isExcluded(IResource resource, char[][] inclusionPatterns, char[][] exclusionPatterns)
           
static boolean isJavaLikeFileName(char[] fileName)
          Returns true if the given name ends with one of the known java like extension.
static boolean isJavaLikeFileName(java.lang.String name)
          Returns true if the given name ends with one of the known java like extension.
static boolean isReadOnly(IResource resource)
          Returns whether the given resource is read-only or not.
static boolean isReadOnlySupported()
          Returns whether the local file system supports accessing and modifying the read only flag.
static boolean isValidClassFileName(java.lang.String name, java.lang.String sourceLevel, java.lang.String complianceLevel)
          Validate the given .class file name.
static boolean isValidCompilationUnitName(java.lang.String name, java.lang.String sourceLevel, java.lang.String complianceLevel)
          Validate the given compilation unit name.
static boolean isValidFolderNameForPackage(java.lang.String folderName, java.lang.String sourceLevel, java.lang.String complianceLevel)
          Returns true if the given folder name is valid for a package, false if it is not.
static boolean isValidMethodSignature(java.lang.String sig)
          Returns true if the given method signature is valid, false if it is not.
static boolean isValidTypeSignature(java.lang.String sig, boolean allowVoid)
          Returns true if the given type signature is valid, false if it is not.
static java.lang.String localTypeName(java.lang.String binaryTypeName, int lastDollar, int end)
           
static void log(int statusErrorID, java.lang.String message)
           
static void log(IStatus status)
           
static void log(java.lang.Throwable e, java.lang.String message)
           
static void logRepeatedMessage(java.lang.String key, java.lang.Exception e)
          Log a message that is potentially repeated in the same session.
static void logRepeatedMessage(java.lang.String key, int statusErrorID, java.lang.String message)
           
static ClassFileReader newClassFileReader(IResource resource)
           
static char[] normalizeCRs(char[] text, char[] buffer)
          Normalizes the cariage returns in the given text.
static java.lang.String normalizeCRs(java.lang.String text, java.lang.String buffer)
          Normalizes the carriage returns in the given text.
static java.lang.String packageName(IPath pkgPath, java.lang.String sourceLevel, java.lang.String complianceLevel)
          Converts the given relative path into a package name.
static int prefixLength(char[] s1, char[] s2)
          Returns the length of the common prefix between s1 and s2.
static int prefixLength(java.lang.String s1, java.lang.String s2)
          Returns the length of the common prefix between s1 and s2.
static java.lang.String relativePath(IPath fullPath, int skipSegmentCount)
          Returns the toString() of the given full path minus the first given number of segments.
static void resetJavaLikeExtensions()
           
static int scanTypeSignature(char[] string, int start)
          Scans the given string for a type signature starting at the given index and returns the index of the last character.
static void setReadOnly(IResource resource, boolean readOnly)
          Sets or unsets the given resource as read-only in the file system.
static void setSourceAttachmentProperty(IPath path, java.lang.String property)
           
static void sort(char[][] list)
           
static void sort(int[] list)
           
static void sort(java.lang.Object[] objects, Util.Comparer comparer)
          Sorts an array of objects in place.
static void sort(java.lang.String[] strings)
          Sorts an array of strings in place using quicksort.
static void sort(Util.Comparable[] objects)
          Sorts an array of Comparable objects in place.
static IJavaElement[] sortCopy(IJavaElement[] elements)
          Sorts an array of Java elements based on their toStringWithAncestors(), returning a new array with the sorted items.
static java.lang.Object[] sortCopy(java.lang.Object[] objects, Util.Comparer comparer)
          Sorts an array of Strings, returning a new array with the sorted items.
static java.lang.String[] sortCopy(java.lang.String[] objects)
          Sorts an array of Strings, returning a new array with the sorted items.
static Util.Comparable[] sortCopy(Util.Comparable[] objects)
          Sorts an array of Comparable objects, returning a new array with the sorted items.
static java.lang.String[] splitOn(char divider, java.lang.String string, int start, int end)
          Return a new array which is the split of the given string using the given divider.
static char[][] splitTypeLevelsSignature(java.lang.String typeSignature)
          Split signatures of all levels from a type unique key.
static boolean startsWithIgnoreCase(java.lang.String[] compoundName, java.lang.String[] prefix, boolean partialMatch)
           
static char[] toAnchor(int startingIndex, char[] methodSignature, char[] methodName, boolean isVargArgs)
           
static java.lang.String toAnchor(int startingIndex, char[] methodSignature, java.lang.String methodName, boolean isVarArgs)
           
static char[][] toCharArrays(java.lang.String[] a)
          Converts a String[] to char[][].
static char[][] toCompoundChars(java.lang.String s)
          Converts a String to char[][], where segments are separate by '.'.
static java.io.File toLocalFile(java.net.URI uri, IProgressMonitor monitor)
           
static java.lang.String toString(char[][] c)
          Converts a char[][] to String, where segments are separated by '.'.
static java.lang.String toString(char[][] c, char[] d)
          Converts a char[][] and a char[] to String, where segments are separated by '.'.
static java.lang.String toString(char[] declaringClass, char[] methodName, char[] methodSignature, boolean includeReturnType, boolean compact)
           
static java.lang.String[] toStrings(char[][] a)
           
static java.lang.String[] typeParameterSignatures(AbstractMethodDeclaration method)
           
static java.lang.String typeSignature(TypeReference type)
           
static void validateMethodSignature(java.lang.String sig)
          Asserts that the given method signature is valid.
static void validateTypeSignature(java.lang.String sig, boolean allowVoid)
          Asserts that the given type signature is valid.
static void verbose(java.lang.String log)
           
static void verbose(java.lang.String log, java.io.PrintStream printStream)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

arrayConcat

public static final java.lang.String[] arrayConcat(java.lang.String[] first,
                                                   java.lang.String second)
Returns a new array adding the second array at the end of first array. It answers null if the first and second are null. If the first array is null or if it is empty, then a new array is created with second. If the second array is null, then the first array is returned.

For example:
  1.     first = null
        second = "a"
        => result = {"a"}
     
  2.     first = {"a"}
        second = null
        => result = {"a"}
     
  3.     first = {"a"}
        second = {"b"}
        => result = {"a", "b"}
     

Parameters:
first - the first array to concatenate
second - the array to add at the end of the first array
Returns:
a new array adding the second array at the end of first array, or null if the two arrays are null.

combineHashCodes

public static int combineHashCodes(int hashCode1,
                                   int hashCode2)
Combines two hash codes to make a new one.


compare

public static int compare(byte[] a,
                          byte[] b)
Compares two byte arrays. Returns <0 if a byte in a is less than the corresponding byte in b, or if a is shorter, or if a is null. Returns >0 if a byte in a is greater than the corresponding byte in b, or if a is longer, or if b is null. Returns 0 if they are equal or both null.


compare

public static int compare(char[] str1,
                          char[] str2)
Compares two strings lexicographically. The comparison is based on the Unicode value of each character in the strings.

Returns:
the value 0 if the str1 is equal to str2; a value less than 0 if str1 is lexicographically less than str2; and a value greater than 0 if str1 is lexicographically greater than str2.

concatCompoundNameToCharArray

public static char[] concatCompoundNameToCharArray(java.lang.String[] compoundName)
Concatenate a String[] compound name to a continuous char[].


concatenateName

public static java.lang.String concatenateName(java.lang.String name1,
                                               java.lang.String name2,
                                               char separator)

concatWith

public static final java.lang.String concatWith(java.lang.String[] array,
                                                char separator)
Returns the concatenation of the given array parts using the given separator between each part.

For example:
  1.     array = {"a", "b"}
        separator = '.'
        => result = "a.b"
     
  2.     array = {}
        separator = '.'
        => result = ""
     

Parameters:
array - the given array
separator - the given separator
Returns:
the concatenation of the given array parts using the given separator between each part

concatWith

public static final java.lang.String concatWith(java.lang.String[] array,
                                                java.lang.String name,
                                                char separator)
Returns the concatenation of the given array parts using the given separator between each part and appending the given name at the end.

For example:
  1.     name = "c"
        array = { "a", "b" }
        separator = '.'
        => result = "a.b.c"
     
  2.     name = null
        array = { "a", "b" }
        separator = '.'
        => result = "a.b"
     
  3.     name = " c"
        array = null
        separator = '.'
        => result = "c"
     

Parameters:
array - the given array
name - the given name
separator - the given separator
Returns:
the concatenation of the given array parts using the given separator between each part and appending the given name at the end

convertTypeSignature

public static java.lang.String convertTypeSignature(char[] sig,
                                                    int start,
                                                    int length)
Converts a type signature from the IBinaryType representation to the DC representation.


defaultJavaExtension

public static java.lang.String defaultJavaExtension()

editedString

public static final java.lang.String editedString(java.lang.String original,
                                                  TextEdit edit)
Apply the given edit on the given string and return the updated string. Return the given string if anything wrong happen while applying the edit.

Parameters:
original - the given string
edit - the given edit
Returns:
the updated string

endsWithIgnoreCase

public static final boolean endsWithIgnoreCase(java.lang.String str,
                                               java.lang.String end)
Returns true iff str.toLowerCase().endsWith(end.toLowerCase()) implementation is not creating extra strings.


equalArrays

public static boolean equalArrays(java.lang.Object[] a,
                                  java.lang.Object[] b,
                                  int len)
Compares two arrays using equals() on the elements. Neither can be null. Only the first len elements are compared. Return false if either array is shorter than len.


equalArraysOrNull

public static boolean equalArraysOrNull(int[] a,
                                        int[] b)
Compares two arrays using equals() on the elements. Either or both arrays may be null. Returns true if both are null. Returns false if only one is null. If both are arrays, returns true iff they have the same length and all elements are equal.


equalArraysOrNull

public static boolean equalArraysOrNull(java.lang.Object[] a,
                                        java.lang.Object[] b)
Compares two arrays using equals() on the elements. Either or both arrays may be null. Returns true if both are null. Returns false if only one is null. If both are arrays, returns true iff they have the same length and all elements compare true with equals.


equalArraysOrNullSortFirst

public static boolean equalArraysOrNullSortFirst(Util.Comparable[] a,
                                                 Util.Comparable[] b)
Compares two arrays using equals() on the elements. The arrays are first sorted. Either or both arrays may be null. Returns true if both are null. Returns false if only one is null. If both are arrays, returns true iff they have the same length and iff, after sorting both arrays, all elements compare true with equals. The original arrays are left untouched.


equalArraysOrNullSortFirst

public static boolean equalArraysOrNullSortFirst(java.lang.String[] a,
                                                 java.lang.String[] b)
Compares two String arrays using equals() on the elements. The arrays are first sorted. Either or both arrays may be null. Returns true if both are null. Returns false if only one is null. If both are arrays, returns true iff they have the same length and iff, after sorting both arrays, all elements compare true with equals. The original arrays are left untouched.


equalOrNull

public static boolean equalOrNull(java.lang.Object a,
                                  java.lang.Object b)
Compares two objects using equals(). Either or both array may be null. Returns true if both are null. Returns false if only one is null. Otherwise, return the result of comparing with equals().


equalsIgnoreJavaLikeExtension

public static boolean equalsIgnoreJavaLikeExtension(java.lang.String fileName,
                                                    java.lang.String string)

extractLastName

public static java.lang.String extractLastName(java.lang.String qualifiedName)
Given a qualified name, extract the last component. If the input is not qualified, the same string is answered.


extractParameterTypes

public static java.lang.String[] extractParameterTypes(char[] sig)
Extracts the parameter types from a method signature.


extractReturnType

public static java.lang.String extractReturnType(java.lang.String sig)
Extracts the return type from a method signature.


findLineSeparator

public static java.lang.String findLineSeparator(char[] text)
Finds the first line separator used by the given text.

Returns:
"\n" or "\r" or "\r\n", or null if none found

getAttribute

public static IClassFileAttribute getAttribute(IClassFileReader classFileReader,
                                               char[] attributeName)

getAttribute

public static IClassFileAttribute getAttribute(ICodeAttribute codeAttribute,
                                               char[] attributeName)

getAttribute

public static IClassFileAttribute getAttribute(IFieldInfo fieldInfo,
                                               char[] attributeName)

getAttribute

public static IClassFileAttribute getAttribute(IMethodInfo methodInfo,
                                               char[] attributeName)

getJavaLikeExtensions

public static char[][] getJavaLikeExtensions()
Returns the registered Java like extensions.


getJdkLevel

public static long getJdkLevel(java.lang.Object targetLibrary)
Get the jdk level of this root. The value can be: Returns the jdk level


getNameWithoutJavaLikeExtension

public static java.lang.String getNameWithoutJavaLikeExtension(java.lang.String fileName)
Returns the substring of the given file name, ending at the start of a Java like extension. The entire file name is returned if it doesn't end with a Java like extension.


getLineSeparator

public static java.lang.String getLineSeparator(java.lang.String text,
                                                IJavaProject project)
Returns the line separator found in the given text. If it is null, or not found return the line delimiter for the given project. If the project is null, returns the line separator for the workspace. If still null, return the system line separator.


getParameterCount

public static int getParameterCount(char[] sig)
Returns the number of parameter types in a method signature.


getProblemArgumentsForMarker

public static java.lang.String getProblemArgumentsForMarker(java.lang.String[] arguments)
Put all the arguments in one String.


getProblemArgumentsFromMarker

public static java.lang.String[] getProblemArgumentsFromMarker(java.lang.String argumentsString)
Separate all the arguments of a String made by getProblemArgumentsForMarker


getResourceContentsAsByteArray

public static byte[] getResourceContentsAsByteArray(IFile file)
                                             throws JavaModelException
Returns the given file's contents as a byte array.

Throws:
JavaModelException

getResourceContentsAsCharArray

public static char[] getResourceContentsAsCharArray(IFile file)
                                             throws JavaModelException
Returns the given file's contents as a character array.

Throws:
JavaModelException

getResourceContentsAsCharArray

public static char[] getResourceContentsAsCharArray(IFile file,
                                                    java.lang.String encoding)
                                             throws JavaModelException
Throws:
JavaModelException

getSignature

public static java.lang.String getSignature(Type type)

getSourceAttachmentProperty

public static java.lang.String getSourceAttachmentProperty(IPath path)
                                                    throws JavaModelException
Throws:
JavaModelException

setSourceAttachmentProperty

public static void setSourceAttachmentProperty(IPath path,
                                               java.lang.String property)

getDeclaringTypeSignature

public static java.lang.String getDeclaringTypeSignature(java.lang.String key)

getTrimmedSimpleNames

public static java.lang.String[] getTrimmedSimpleNames(java.lang.String name)
Returns a trimmed version the simples names returned by Signature.


getUnresolvedJavaElement

public static JavaElement getUnresolvedJavaElement(FieldBinding binding,
                                                   WorkingCopyOwner workingCopyOwner,
                                                   Util.BindingsToNodesMap bindingsToNodes)
Return the java element corresponding to the given compiler binding.


getUnresolvedJavaElement

public static JavaElement getUnresolvedJavaElement(int localSourceStart,
                                                   int localSourceEnd,
                                                   JavaElement type)
Returns the IInitializer that contains the given local variable in the given type


getUnresolvedJavaElement

public static JavaElement getUnresolvedJavaElement(MethodBinding methodBinding,
                                                   WorkingCopyOwner workingCopyOwner,
                                                   Util.BindingsToNodesMap bindingsToNodes)
Return the java element corresponding to the given compiler binding.


getUnresolvedJavaElement

public static JavaElement getUnresolvedJavaElement(TypeBinding typeBinding,
                                                   WorkingCopyOwner workingCopyOwner,
                                                   Util.BindingsToNodesMap bindingsToNodes)
Return the java element corresponding to the given compiler binding.


indexOfEnclosingPath

public static int indexOfEnclosingPath(IPath checkedPath,
                                       IPath[] paths,
                                       int pathCount)

indexOfJavaLikeExtension

public static int indexOfJavaLikeExtension(java.lang.String fileName)

indexOfMatchingPath

public static int indexOfMatchingPath(IPath checkedPath,
                                      IPath[] paths,
                                      int pathCount)

indexOfNestedPath

public static int indexOfNestedPath(IPath checkedPath,
                                    IPath[] paths,
                                    int pathCount)

isAttributeSupported

protected static boolean isAttributeSupported(int attribute)
Returns whether the local file system supports accessing and modifying the given attribute.


isReadOnly

public static boolean isReadOnly(IResource resource)
Returns whether the given resource is read-only or not.

Parameters:
resource -
Returns:
true if the resource is read-only, false if it is not or if the file system does not support the read-only attribute.

isReadOnlySupported

public static boolean isReadOnlySupported()
Returns whether the local file system supports accessing and modifying the read only flag.


isExcluded

public static final boolean isExcluded(IJavaElement element)

isExcluded

public static final boolean isExcluded(IPath resourcePath,
                                       char[][] inclusionPatterns,
                                       char[][] exclusionPatterns,
                                       boolean isFolderPath)

isExcluded

public static final boolean isExcluded(IResource resource,
                                       char[][] inclusionPatterns,
                                       char[][] exclusionPatterns)

isValidClassFileName

public static boolean isValidClassFileName(java.lang.String name,
                                           java.lang.String sourceLevel,
                                           java.lang.String complianceLevel)
Validate the given .class file name. A .class file name must obey the following rules:
  • it must not be null
  • it must include the ".class" suffix
  • its prefix must be a valid identifier

Parameters:
name - the name of a .class file
sourceLevel - the source level
complianceLevel - the compliance level
Returns:
a status object with code IStatus.OK if the given name is valid as a .class file name, otherwise a status object indicating what is wrong with the name

isValidCompilationUnitName

public static boolean isValidCompilationUnitName(java.lang.String name,
                                                 java.lang.String sourceLevel,
                                                 java.lang.String complianceLevel)
Validate the given compilation unit name. A compilation unit name must obey the following rules:
  • it must not be null
  • it must include the ".java" suffix
  • its prefix must be a valid identifier

Parameters:
name - the name of a compilation unit
sourceLevel - the source level
complianceLevel - the compliance level
Returns:
a status object with code IStatus.OK if the given name is valid as a compilation unit name, otherwise a status object indicating what is wrong with the name

isValidFolderNameForPackage

public static boolean isValidFolderNameForPackage(java.lang.String folderName,
                                                  java.lang.String sourceLevel,
                                                  java.lang.String complianceLevel)
Returns true if the given folder name is valid for a package, false if it is not.

Parameters:
folderName - the name of the folder
sourceLevel - the source level
complianceLevel - the compliance level

isValidMethodSignature

public static boolean isValidMethodSignature(java.lang.String sig)
Returns true if the given method signature is valid, false if it is not.


isValidTypeSignature

public static boolean isValidTypeSignature(java.lang.String sig,
                                           boolean allowVoid)
Returns true if the given type signature is valid, false if it is not.


localTypeName

public static java.lang.String localTypeName(java.lang.String binaryTypeName,
                                             int lastDollar,
                                             int end)

log

public static void log(java.lang.Throwable e,
                       java.lang.String message)

logRepeatedMessage

public static void logRepeatedMessage(java.lang.String key,
                                      java.lang.Exception e)
Log a message that is potentially repeated in the same session. The first time this method is called with a given exception, the exception stack trace is written to the log.

Only intended for use in debug statements.

Parameters:
key - the given key
e - the given exception
Throws:
java.lang.IllegalArgumentException - if the given key is null

logRepeatedMessage

public static void logRepeatedMessage(java.lang.String key,
                                      int statusErrorID,
                                      java.lang.String message)

log

public static void log(int statusErrorID,
                       java.lang.String message)

log

public static void log(IStatus status)

newClassFileReader

public static ClassFileReader newClassFileReader(IResource resource)
                                          throws CoreException,
                                                 ClassFormatException,
                                                 java.io.IOException
Throws:
CoreException
ClassFormatException
java.io.IOException

normalizeCRs

public static char[] normalizeCRs(char[] text,
                                  char[] buffer)
Normalizes the cariage returns in the given text. They are all changed to use the given buffer's line separator.


normalizeCRs

public static java.lang.String normalizeCRs(java.lang.String text,
                                            java.lang.String buffer)
Normalizes the carriage returns in the given text. They are all changed to use given buffer's line separator.


packageName

public static java.lang.String packageName(IPath pkgPath,
                                           java.lang.String sourceLevel,
                                           java.lang.String complianceLevel)
Converts the given relative path into a package name. Returns null if the path is not a valid package name.

Parameters:
pkgPath - the package path
sourceLevel - the source level
complianceLevel - the compliance level

prefixLength

public static int prefixLength(char[] s1,
                               char[] s2)
Returns the length of the common prefix between s1 and s2.


prefixLength

public static int prefixLength(java.lang.String s1,
                               java.lang.String s2)
Returns the length of the common prefix between s1 and s2.


relativePath

public static java.lang.String relativePath(IPath fullPath,
                                            int skipSegmentCount)
Returns the toString() of the given full path minus the first given number of segments. The returned string is always a relative path (it has no leading slash)


resetJavaLikeExtensions

public static void resetJavaLikeExtensions()

scanTypeSignature

public static int scanTypeSignature(char[] string,
                                    int start)
Scans the given string for a type signature starting at the given index and returns the index of the last character.
 TypeSignature:
  |  BaseTypeSignature
  |  ArrayTypeSignature
  |  ClassTypeSignature
  |  TypeVariableSignature
 

Parameters:
string - the signature string
start - the 0-based character index of the first character
Returns:
the 0-based character index of the last character
Throws:
java.lang.IllegalArgumentException - if this is not a type signature

splitOn

public static final java.lang.String[] splitOn(char divider,
                                               java.lang.String string,
                                               int start,
                                               int end)
Return a new array which is the split of the given string using the given divider. The given end is exclusive and the given start is inclusive.

For example:
  1.     divider = 'b'
        string = "abbaba"
        start = 2
        end = 5
        result => { "", "a", "" }
     

Parameters:
divider - the given divider
string - the given string
start - the given starting index
end - the given ending index
Returns:
a new array which is the split of the given string using the given divider
Throws:
java.lang.ArrayIndexOutOfBoundsException - if start is lower than 0 or end is greater than the array length

setReadOnly

public static void setReadOnly(IResource resource,
                               boolean readOnly)
Sets or unsets the given resource as read-only in the file system. It's a no-op if the file system does not support the read-only attribute.

Parameters:
resource - The resource to set as read-only
readOnly - true to set it to read-only, false to unset

sort

public static void sort(char[][] list)

sort

public static void sort(Util.Comparable[] objects)
Sorts an array of Comparable objects in place.


sort

public static void sort(int[] list)

sort

public static void sort(java.lang.Object[] objects,
                        Util.Comparer comparer)
Sorts an array of objects in place. The given comparer compares pairs of items.


sort

public static void sort(java.lang.String[] strings)
Sorts an array of strings in place using quicksort.


sortCopy

public static Util.Comparable[] sortCopy(Util.Comparable[] objects)
Sorts an array of Comparable objects, returning a new array with the sorted items. The original array is left untouched.


sortCopy

public static IJavaElement[] sortCopy(IJavaElement[] elements)
Sorts an array of Java elements based on their toStringWithAncestors(), returning a new array with the sorted items. The original array is left untouched.


sortCopy

public static java.lang.Object[] sortCopy(java.lang.Object[] objects,
                                          Util.Comparer comparer)
Sorts an array of Strings, returning a new array with the sorted items. The original array is left untouched.


sortCopy

public static java.lang.String[] sortCopy(java.lang.String[] objects)
Sorts an array of Strings, returning a new array with the sorted items. The original array is left untouched.


startsWithIgnoreCase

public static boolean startsWithIgnoreCase(java.lang.String[] compoundName,
                                           java.lang.String[] prefix,
                                           boolean partialMatch)

toCharArrays

public static char[][] toCharArrays(java.lang.String[] a)
Converts a String[] to char[][].


toCompoundChars

public static char[][] toCompoundChars(java.lang.String s)
Converts a String to char[][], where segments are separate by '.'.


toLocalFile

public static java.io.File toLocalFile(java.net.URI uri,
                                       IProgressMonitor monitor)
                                throws CoreException
Throws:
CoreException

toString

public static java.lang.String toString(char[][] c)
Converts a char[][] to String, where segments are separated by '.'.


toString

public static java.lang.String toString(char[][] c,
                                        char[] d)
Converts a char[][] and a char[] to String, where segments are separated by '.'.


toStrings

public static java.lang.String[] toStrings(char[][] a)

toString

public static java.lang.String toString(char[] declaringClass,
                                        char[] methodName,
                                        char[] methodSignature,
                                        boolean includeReturnType,
                                        boolean compact)

typeParameterSignatures

public static java.lang.String[] typeParameterSignatures(AbstractMethodDeclaration method)

typeSignature

public static java.lang.String typeSignature(TypeReference type)

validateMethodSignature

public static void validateMethodSignature(java.lang.String sig)
Asserts that the given method signature is valid.


validateTypeSignature

public static void validateTypeSignature(java.lang.String sig,
                                         boolean allowVoid)
Asserts that the given type signature is valid.


verbose

public static void verbose(java.lang.String log)

verbose

public static void verbose(java.lang.String log,
                           java.io.PrintStream printStream)

isJavaLikeFileName

public static final boolean isJavaLikeFileName(java.lang.String name)
Returns true if the given name ends with one of the known java like extension. (implementation is not creating extra strings)


isJavaLikeFileName

public static final boolean isJavaLikeFileName(char[] fileName)
Returns true if the given name ends with one of the known java like extension. (implementation is not creating extra strings)


getAllTypeArguments

public static final char[][][] getAllTypeArguments(char[][] typeSignatures)
Get all type arguments from an array of signatures. Example: For following type X,V,U>.A signatures is: [ ['L','X','<','L','Y','<','L','Z',';'>',';','L','V','<','L','W',';'>',';','L','U',';',>',';'], ['L','A','<','L','B',';','>',';'] ]

Parameters:
typeSignatures - Array of signatures (one per each type levels)
Returns:
char[][][] Array of type arguments for each signature
Throws:
java.lang.IllegalArgumentException - If one of provided signature is malformed
See Also:
Then, this method returns: [ [ ['L','Y','<','L','Z',';'>',';'], ['L','V','<','L','W',';'>',';'], ['L','U',';'] ], [ ['L','B',';'] ] ]

getAnnotation

public static IAnnotation getAnnotation(JavaElement parent,
                                        IBinaryAnnotation binaryAnnotation,
                                        java.lang.String memberValuePairName)

getAnnotationMemberValue

public static java.lang.Object getAnnotationMemberValue(JavaElement parent,
                                                        MemberValuePair memberValuePair,
                                                        java.lang.Object binaryValue)

getAnnotationMemberValue

public static java.lang.Object getAnnotationMemberValue(MemberValuePair memberValuePair,
                                                        Constant constant)

getNegativeAnnotationMemberValue

public static java.lang.Object getNegativeAnnotationMemberValue(MemberValuePair memberValuePair,
                                                                Constant constant)

splitTypeLevelsSignature

public static final char[][] splitTypeLevelsSignature(java.lang.String typeSignature)
Split signatures of all levels from a type unique key. Example: For following type X,V,U>.A, unique key is: "LX;LV;LU;>.LA;" The return splitted signatures array is: [ ['L','X','<','L','Y','<','L','Z',';'>',';','L','V','<','L','W',';'>',';','L','U','>',';'], ['L','A','<','L','B',';','>',';']

Parameters:
typeSignature - ParameterizedSourceType type signature
Returns:
char[][] Array of signatures for each level of given unique key

toAnchor

public static java.lang.String toAnchor(int startingIndex,
                                        char[] methodSignature,
                                        java.lang.String methodName,
                                        boolean isVarArgs)

toAnchor

public static char[] toAnchor(int startingIndex,
                              char[] methodSignature,
                              char[] methodName,
                              boolean isVargArgs)

fixTaskTags

public static void fixTaskTags(java.util.Map defaultOptionsMap)

findMethod

public static IMethod findMethod(IType type,
                                 char[] selector,
                                 java.lang.String[] paramTypeSignatures,
                                 boolean isConstructor)
                          throws JavaModelException
Finds the IMethod element corresponding to the given selector, without creating a new dummy instance of a binary method.

Parameters:
type - the type in which the method is declared
selector - the method name
paramTypeSignatures - the type signatures of the method arguments
isConstructor - whether we're looking for a constructor
Returns:
an IMethod if found, otherwise null
Throws:
JavaModelException