|
Eclipse JDT 2.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.eclipse.jdt.core.JavaConventions
Provides methods for checking Java-specific conventions such as name syntax.
This class provides static methods and constants only; it is not intended to be instantiated or subclassed by clients.
Method Summary | |
static boolean |
isOverlappingRoots(IPath rootPath1,
IPath rootPath2)
Returns whether the given package fragment root paths are considered to overlap. |
static IStatus |
validateClassFileName(String name)
Validate the given .class file name. |
static IJavaModelStatus |
validateClasspath(IJavaProject javaProject,
IClasspathEntry[] classpath,
IPath outputLocation)
Validate the given classpath and output location, using the following rules: No duplicate path amongst classpath entries. |
static IJavaModelStatus |
validateClasspathEntry(IJavaProject javaProject,
IClasspathEntry entry,
boolean checkSourceAttachment)
Returns a java model status describing the problem related to this classpath entry if any, a status object with code IStatus.OK if the entry is fine. |
static IStatus |
validateCompilationUnitName(String name)
Validate the given compilation unit name. |
static IStatus |
validateFieldName(String name)
Validate the given field name. |
static IStatus |
validateIdentifier(String id)
Validate the given Java identifier. |
static IStatus |
validateImportDeclaration(String name)
Validate the given import declaration name. |
static IStatus |
validateJavaTypeName(String name)
Validate the given Java type name, either simple or qualified. |
static IStatus |
validateMethodName(String name)
Validate the given method name. |
static IStatus |
validatePackageName(String name)
Validate the given package name. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static boolean isOverlappingRoots(IPath rootPath1, IPath rootPath2)
Two root paths overlap if one is a prefix of the other, or they point to the same location. However, a JAR is allowed to be nested in a root.
rootPath1
- the first root pathrootPath2
- the second root path
public static IStatus validateCompilationUnitName(String name)
".java"
suffix
name
- the name of a compilation unit
IStatus.OK
if
the given name is valid as a compilation unit name, otherwise a status
object indicating what is wrong with the namepublic static IStatus validateClassFileName(String name)
".class"
suffix
name
- the name of a .class file
IStatus.OK
if
the given name is valid as a .class file name, otherwise a status
object indicating what is wrong with the namepublic static IStatus validateFieldName(String name)
Syntax of a field name corresponds to VariableDeclaratorId (JLS2 8.3).
For example, "x"
.
name
- the name of a field
IStatus.OK
if
the given name is valid as a field name, otherwise a status
object indicating what is wrong with the namepublic static IStatus validateIdentifier(String id)
"true"
, "false"
), or null literal ("null"
).
See section 3.8 of the Java Language Specification, Second Edition (JLS2).
A valid identifier can act as a simple type name, method name or field name.
id
- the Java identifier
IStatus.OK
if
the given identifier is a valid Java identifier, otherwise a status
object indicating what is wrong with the identifierpublic static IStatus validateImportDeclaration(String name)
The name of an import corresponds to a fully qualified type name
or an on-demand package name as defined by ImportDeclaration (JLS2 7.5).
For example, "java.util.*"
or "java.util.Hashtable"
.
name
- the import declaration
IStatus.OK
if
the given name is valid as an import declaration, otherwise a status
object indicating what is wrong with the namepublic static IStatus validateJavaTypeName(String name)
"java.lang.Object"
, or "Object"
.
name
- the name of a type
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 namepublic static IStatus validateMethodName(String name)
The syntax for a method name is defined by Identifier of MethodDeclarator (JLS2 8.4). For example "println".
name
- the name of a method
IStatus.OK
if
the given name is valid as a method name, otherwise a status
object indicating what is wrong with the namepublic static IStatus validatePackageName(String name)
The syntax of a package name corresponds to PackageName as
defined by PackageDeclaration (JLS2 7.4). For example, "java.lang"
.
Note that the given name must be a non-empty package name (ie. attempting to validate the default package will return an error status.) Also it must not contain any characters or substrings that are not valid on the file system on which workspace root is located.
name
- the name of a package
IStatus.OK
if
the given name is valid as a package name, otherwise a status
object indicating what is wrong with the namepublic static IJavaModelStatus validateClasspath(IJavaProject javaProject, IClasspathEntry[] classpath, IPath outputLocation)
javaProject
- the given java projectclasspath
- a given classpathoutputLocation
- a given output location
IStatus.OK
if
the given classpath and output location are compatible, otherwise a status
object indicating what is wrong with the classpath or output locationpublic static IJavaModelStatus validateClasspathEntry(IJavaProject javaProject, IClasspathEntry entry, boolean checkSourceAttachment)
IStatus.OK
if the entry is fine.
(i.e. if the given classpath entry denotes a valid element to be referenced onto a classpath).
javaProject
- the given java projectentry
- the given classpath entrycheckSourceAttachment
- a flag to determine if source attachement should be checked
IStatus.OK
if the entry is fine
|
Eclipse JDT 2.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |