JavaUtil Class

com.bea.ide.lang.java
JavaUtil Class

public class JavaUtil

    extends Object

This class contains utilities related to the Java language itself.


Hierarchy
Object
  JavaUtil

Nested Class Summary

public static classJavaUtil.NameParts
           Breaks a fully qualified class name into it's package and name parts.

Field Summary

public static final String
KEYWORDS
An array containing java keywords.
public static final String
TYPE_KEYWORDS
An array containing java primitive type names.
 

Constructor Summary

JavaUtil()

 

Method Summary

public static String
argsToString(JavaElement el)
public static void
copy(List source, Object[] dest)
Copy from the given list into the given array.
public static String[]
getCallStack()
Return an array containing the call stack of the calling function.
public static String
getClassName(URI uri)
Returns the name of the class defined in the given IDocument.
public static String
getClassName(IProject proj, URI uri)
Determines a fully-qualified type name based on a project and file URI.
public static DocumentFilter
getJavaIdentifierDocumentFilter()
Java Identifier Document Filter, useful for validating JTextFields
public static DocumentFilter
getJavaTypeDocumentFilter()
Java Type Document Filter, useful for validating JTextFields
public static JavaUtil.NameParts
getNameParts(String fullName)
Returns a NameParts for the given name.
public static boolean
isAllowableFilename(String baseName)
Determines whether the given string is suitable for a Java filename.
public static boolean
isIdentifier(String str)
Determines whether the given string is a Java identifier.
public static boolean
isKeyword(String str)
Determines whether the given string is a Java keyword.
public static boolean
isPrimitiveType(String str)
Determines whether the given string is a Java primitive type name.
public static boolean
isType(String str)
Determines whether the given string is a Java type name.
public static boolean
isValidRuntime(String[] classpath)
public static String
makeName(String pkg, String clazz)
Returns a fully qualified name with the given parts.
 
Methods from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
   

Field Detail

KEYWORDS

public static final String KEYWORDS
An array containing java keywords.


TYPE_KEYWORDS

public static final String TYPE_KEYWORDS
An array containing java primitive type names.

 

Constructor Detail

JavaUtil

public JavaUtil()
 

Method Detail

argsToString(JavaElement) Method

public static String argsToString(JavaElement el)

copy(List, Object[]) Method

public static void copy(List source, 
                        Object[] dest)
Copy from the given list into the given array.


getCallStack() Method

public static String[] getCallStack()
Return an array containing the call stack of the calling function. Element zero in the array will be the calling function. Each element on the stack is the fully qualified name of a method inside of a class.

Note that this routine is tightly bound to the way the stack is printed. However, this trick is done commonly in Java, so if they do change the format, I would expect them to provide a new function that does what we are doing here.


getClassName(URI) Method

public static String getClassName(URI uri)
Returns the name of the class defined in the given IDocument.


getClassName(IProject, URI) Method

public static String getClassName(IProject proj, 
                                  URI uri)
Determines a fully-qualified type name based on a project and file URI. This method assumes that all types contain file names and packages appropriate to their location within the project's source paths.

Parameters

proj
The file's project. This is used to determine the project's source paths.
uri
The URI of a file that defines a class.

Returns

The fully-qualified type name, based on the URI and source path information provided.

getJavaIdentifierDocumentFilter() Method

public static DocumentFilter getJavaIdentifierDocumentFilter()
Java Identifier Document Filter, useful for validating JTextFields


getJavaTypeDocumentFilter() Method

DEPRECATED This method is provided for alpha-compatibility, and should never be used by current extensions.

public static DocumentFilter getJavaTypeDocumentFilter()
Java Type Document Filter, useful for validating JTextFields


getNameParts(String) Method

public static JavaUtil.NameParts getNameParts(String fullName)
Returns a NameParts for the given name.


isAllowableFilename(String) Method

public static boolean isAllowableFilename(String baseName)
Determines whether the given string is suitable for a Java filename. It differs from isIdentifier in the following ways: $ is disallowed. keywords and primitive types are disallowed.

Parameters

baseName
the base filename (without path or extension) to test.

Returns

true if this is a usable java identifier for a new file.

isIdentifier(String) Method

public static boolean isIdentifier(String str)
Determines whether the given string is a Java identifier.


isKeyword(String) Method

public static boolean isKeyword(String str)
Determines whether the given string is a Java keyword.


isPrimitiveType(String) Method

public static boolean isPrimitiveType(String str)
Determines whether the given string is a Java primitive type name.


isType(String) Method

public static boolean isType(String str)
Determines whether the given string is a Java type name.


isValidRuntime(String[]) Method

DEPRECATED This method used out-dated methods of determining a valid classpath. It should no longer be necessary for clients to verify classpath integrity.

public static boolean isValidRuntime(String[] classpath)

makeName(String, String) Method

public static String makeName(String pkg, 
                              String clazz)
Returns a fully qualified name with the given parts.