org.eclipse.jst.ws.jaxws.core.utils
Class JDTUtils

java.lang.Object
  extended by org.eclipse.jst.ws.jaxws.core.utils.JDTUtils

public final class JDTUtils
extends java.lang.Object

JDT Utility class.

Provisional API: This class/interface is part of an interim API that is still under development and expected to change significantly before reaching stability. It is being made available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.


Method Summary
static void addToClasspath(org.eclipse.jdt.core.IJavaProject javaProject, org.eclipse.jdt.core.IClasspathEntry classpathEntry)
          Add a IClasspathEntry to a IJavaProject
static org.eclipse.jdt.core.IType findType(org.eclipse.jdt.core.IJavaProject javaProject, java.lang.String fullyQualifiedClassName)
          Returns the first type found following the given java project's classpath with the given fully qualified name or null if none is found.
static org.eclipse.jdt.core.IType findType(java.lang.String projectName, java.lang.String fullyQualifiedClassName)
          Returns the first type found with the given fully qualified name following the classpath of the java project with the give project name or null if none is found.
static org.eclipse.jdt.core.IJavaProject getJavaProject(java.lang.String projectName)
          Returns the Java project corresponding to the given project name.
static org.eclipse.core.runtime.IPath getJavaProjectOutputDirectoryPath(org.eclipse.jdt.core.IJavaProject javaProject)
          Returns the absolute path in the local file system of the default output location for the given java project.
static org.eclipse.core.runtime.IPath getJavaProjectOutputDirectoryPath(java.lang.String projectName)
          Returns the absolute path in the local file system of the default output location for the given java project name.
static org.eclipse.core.runtime.IPath getJavaProjectSourceDirectoryPath(org.eclipse.jdt.core.IJavaProject javaProject)
          Returns the full, absolute path relative to the workspace of the first source folder found in the given java project.
static org.eclipse.core.runtime.IPath getJavaProjectSourceDirectoryPath(org.eclipse.jdt.core.IType type)
          Returns the full, absolute path relative to the workspace of the source folder that contains the given type.
static org.eclipse.core.runtime.IPath getJavaProjectSourceDirectoryPath(java.lang.String projectName)
          Returns the full, absolute path relative to the workspace of the first source folder found in the java project with the given name.
static org.eclipse.jdt.core.IMethod[] getPublicMethods(org.eclipse.jdt.core.IType type)
          If the given IType is an interface all methods declared in that interface are returned.
static java.lang.String getTargetNamespaceFromPackageName(java.lang.String packageName)
          Constructs a target namespace string from the given package name by splitting the dot '.' separated package name, reversing the order of the package name segments followed by prefixing the string with 'http://' and appending a forward slash '/' to the end.
static boolean isJavaProject(org.eclipse.core.resources.IProject project)
          Returns whether the given project has the java nature.
static boolean isPublicMethod(org.eclipse.jdt.core.IMethod method)
          Returns true if the given method isn't a main method or constructor and if it has the public modifier.
static void removeFromClasspath(org.eclipse.jdt.core.IJavaProject javaProject, org.eclipse.jdt.core.IClasspathEntry classpathEntry)
          Remove a IClasspathEntry from a IJavaProject
static org.eclipse.core.runtime.IStatus validateIdentifier(java.lang.String id)
          Validates the given Java identifier with the workspace source and compliance levels.
static org.eclipse.core.runtime.IStatus validateJavaTypeName(java.lang.String name)
          Validates the given Java type name, either simple or qualified, using the workspace source and compliance levels.
static org.eclipse.core.runtime.IStatus validateJavaTypeName(java.lang.String projectName, java.lang.String name)
          Validates the given Java type name, either simple or qualified, using the given projects source and compliance levels.
static org.eclipse.core.runtime.IStatus validatePackageName(java.lang.String projectName, java.lang.String packageName)
          Validate the given package name using the given projects source and compliance levels.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

addToClasspath

public static void addToClasspath(org.eclipse.jdt.core.IJavaProject javaProject,
                                  org.eclipse.jdt.core.IClasspathEntry classpathEntry)
Add a IClasspathEntry to a IJavaProject

Parameters:
javaProject - the IJavaProject to add the classpath entry to
classpathEntry - the IClasspathEntry to add

removeFromClasspath

public static void removeFromClasspath(org.eclipse.jdt.core.IJavaProject javaProject,
                                       org.eclipse.jdt.core.IClasspathEntry classpathEntry)
Remove a IClasspathEntry from a IJavaProject

Parameters:
javaProject - the IJavaProject to remove the classpath entry from
classpathEntry - the IClasspathEntry to remove

getJavaProject

public static org.eclipse.jdt.core.IJavaProject getJavaProject(java.lang.String projectName)
Returns the Java project corresponding to the given project name.

Parameters:
projectName - the project name
Returns:
the Java project corresponding to the given project name

getJavaProjectOutputDirectoryPath

public static org.eclipse.core.runtime.IPath getJavaProjectOutputDirectoryPath(org.eclipse.jdt.core.IJavaProject javaProject)
Returns the absolute path in the local file system of the default output location for the given java project.

Parameters:
javaProject - the java project
Returns:
the absolute path of the default output folder for the given java project

getJavaProjectOutputDirectoryPath

public static org.eclipse.core.runtime.IPath getJavaProjectOutputDirectoryPath(java.lang.String projectName)
Returns the absolute path in the local file system of the default output location for the given java project name.

Parameters:
projectName - the name of the java project
Returns:
the absolute path of the default output folder for the given java project name

getJavaProjectSourceDirectoryPath

public static org.eclipse.core.runtime.IPath getJavaProjectSourceDirectoryPath(org.eclipse.jdt.core.IType type)
Returns the full, absolute path relative to the workspace of the source folder that contains the given type.

Parameters:
type - the IType
Returns:
the absolute path of the given IType source folder

getJavaProjectSourceDirectoryPath

public static org.eclipse.core.runtime.IPath getJavaProjectSourceDirectoryPath(java.lang.String projectName)
Returns the full, absolute path relative to the workspace of the first source folder found in the java project with the given name.

Parameters:
projectName - the name of the java project
Returns:
the absolute path of the first source folder found in the java project with the given name.

getJavaProjectSourceDirectoryPath

public static org.eclipse.core.runtime.IPath getJavaProjectSourceDirectoryPath(org.eclipse.jdt.core.IJavaProject javaProject)
Returns the full, absolute path relative to the workspace of the first source folder found in the given java project.

Parameters:
javaProject - the IJavaProject
Returns:
the absolute path of the first source folder found in the given java project.

getPublicMethods

public static org.eclipse.jdt.core.IMethod[] getPublicMethods(org.eclipse.jdt.core.IType type)
If the given IType is an interface all methods declared in that interface are returned.

Alternatively if the given given IType is a class, only methods that are explicitly marked public are returned.

Parameters:
type - the IType
Returns:
the public methods declared in this type

getTargetNamespaceFromPackageName

public static java.lang.String getTargetNamespaceFromPackageName(java.lang.String packageName)
Constructs a target namespace string from the given package name by splitting the dot '.' separated package name, reversing the order of the package name segments followed by prefixing the string with 'http://' and appending a forward slash '/' to the end.

E.g., the Java package Òcom.example.wsÓ would return the target namespace Òhttp://ws.example.com/Ó.

If the package name is null or is of zero length "http://default_package/" is returned.

Parameters:
packageName - the package name
Returns:
the derived target namespace

findType

public static org.eclipse.jdt.core.IType findType(org.eclipse.jdt.core.IJavaProject javaProject,
                                                  java.lang.String fullyQualifiedClassName)
Returns the first type found following the given java project's classpath with the given fully qualified name or null if none is found.

Parameters:
javaProject - the given IJavaProject
fullyQualifiedClassName - the given fully qualified name
Returns:
the first type found following the java project's classpath with the given fully qualified name or null if none is found

findType

public static org.eclipse.jdt.core.IType findType(java.lang.String projectName,
                                                  java.lang.String fullyQualifiedClassName)
Returns the first type found with the given fully qualified name following the classpath of the java project with the give project name or null if none is found.

Parameters:
projectName - the name of the java project
fullyQualifiedClassName - the given fully qualified name
Returns:
the first type found following the java project's classpath with the given fully qualified name or null if none is found

isJavaProject

public static boolean isJavaProject(org.eclipse.core.resources.IProject project)
Returns whether the given project has the java nature.

Parameters:
project - the given project
Returns:
true if the project has the java nature

isPublicMethod

public static boolean isPublicMethod(org.eclipse.jdt.core.IMethod method)
Returns true if the given method isn't a main method or constructor and if it has the public modifier.

Parameters:
method - the given method
Returns:
true if the given method is public

validateJavaTypeName

public static org.eclipse.core.runtime.IStatus validateJavaTypeName(java.lang.String name)
Validates the given Java type name, either simple or qualified, using the workspace source and compliance levels.

Parameters:
name - the name of a type
Returns:
a status object with code IStatus.OK if the given name is valid as a Java type name, a status with code IStatus.WARNING indicating why the given name is discouraged, otherwise a status object indicating what is wrong with the name

validateJavaTypeName

public static org.eclipse.core.runtime.IStatus validateJavaTypeName(java.lang.String projectName,
                                                                    java.lang.String name)
Validates the given Java type name, either simple or qualified, using the given projects source and compliance levels.

Parameters:
projectName - the name of the java project
name - the name of a type
Returns:
a status object with code IStatus.OK if the given name is valid as a Java type name, a status with code IStatus.WARNING indicating why the given name is discouraged, otherwise a status object indicating what is wrong with the name

validatePackageName

public static org.eclipse.core.runtime.IStatus validatePackageName(java.lang.String projectName,
                                                                   java.lang.String packageName)
Validate the given package name using the given projects source and compliance levels.

Parameters:
projectName - the name of the java project
packageName - the name of a package
Returns:
a status object with code IStatus.OK if the given name is valid as a package name, otherwise a status object indicating what is wrong with the name

validateIdentifier

public static org.eclipse.core.runtime.IStatus validateIdentifier(java.lang.String id)
Validates the given Java identifier with the workspace source and compliance levels.

Parameters:
id - the Java identifier
Returns:
a status object with code IStatus.OK if the given identifier is a valid Java identifier, otherwise a status object indicating what is wrong with the identifier