Package com.iizigo.java
Class JavaSource
- java.lang.Object
- com.iizigo.java.JavaSource
 
- Direct Known Subclasses:
- ParsedJavaSource
 - public class JavaSource extends java.lang.ObjectClass handling a Java Source. The Java source in this case is used for Classes only, with optional implemented interfaces. It has listeners attached to it and can have several instances of JavaClass, the smallest implementation of a Java class. In a JavaSource, there is always a main JavaClass.- When ClassReference wants to have a reference to a class that is not found, a JavaSource will be created with a - nullfile resource.- Author:
- Christopher Mindus
 
- Nested Class Summary- Nested Classes - Modifier and Type - Class - Description - static class- JavaSource.TypeThe Java source types.
 - Field Summary- Fields - Modifier and Type - Field - Description - static java.lang.String- NOT_PROCESSEDSpecial return code for "not processed".- protected org.eclipse.core.resources.IFile- sourceFileThe file for ".java" SOURCE file, null if unresolved or binary.
 - Constructor Summary- Constructors - Modifier - Constructor - Description - protected- JavaSource(JavaSource.Type type)Creates a Java source instance for BINARY.- protected- JavaSource(org.eclipse.core.resources.IFile sourceFile, ModuleModel model)Creates a Java source instance for PARSED.
 - Method Summary- All Methods Instance Methods Concrete Methods - Modifier and Type - Method - Description - protected void- clearCache()Clears the cache.- protected boolean- dispose()Disposes of the Java source and all its classes.- JavaClass- getClass(java.lang.String className, org.eclipse.jdt.core.IType javaType, IClassReferenceListener listener)Called to add a new class name or to get an existing one.- java.lang.String- getFileName()Gets the file name.- protected int- getJavaClassCount()Gets the JavaClass count, for assertions.- org.eclipse.jdt.core.IJavaProject- getJavaProject()Gets the Java project when class is UNRESOLVED or PARSED.- org.eclipse.core.resources.IProject- getProject()Attempts to locate the IProject of the Java source file.- protected void- getPublicOrStaticClasses(java.util.ArrayList<JavaClass> list)Gets all the JavaClasses available in all projects that are parsed.- org.eclipse.core.resources.IFile- getSourceFile()Gets the ".java" source file for PARSED.- JavaSource.Type- getType()Gets the file type.- boolean- isDisposed()Checks if the instance is disposed of.- protected void- onJavaSourceMoved(org.eclipse.core.resources.IFile newFile, java.lang.String oldPKG, java.lang.String newPKG)Called when a Java source has been moved or renamed.- protected boolean- onJavaSourceRemoved(org.eclipse.core.resources.IFile file)Called when a Java source has been removed.- protected void- onRefactoringChange(java.lang.String classFQN, java.lang.String oldFQN, java.lang.String newFQN)Called from Refactoring Rename for classes or methods.- void- resolveClassReferences()When a SOURCE file is touched, e.g.- void- triggerSWTChangeEvent()Triggers an SWT changed event to the JavaClass listeners to perform resolve, etc.- java.lang.String- validateClass(org.eclipse.jdt.core.IType type, java.lang.String implementsInterface, java.lang.String requiredAnnotation, java.lang.String annotationParam, java.lang.String annotationValue)Validates the class for the interface and annotation.- protected java.lang.String- validateClassProcessors(org.eclipse.jdt.core.IType type, java.lang.String implementsInterface, java.lang.String requiredAnnotation, java.lang.String annotationParam, java.lang.String annotationValue)Validates the class for the interface and annotation.- MethodLookup- validateMethod(org.eclipse.jdt.core.IType type, java.lang.String method, boolean isStatic, java.lang.String requiredAnnotation, java.lang.String annotationParam, java.lang.String annotationValue, boolean allowAll)Validates the method for the annotation.- protected MethodLookup- validateMethodProcessors(org.eclipse.jdt.core.IType type, java.lang.String method, boolean isStatic, java.lang.String requiredAnnotation, java.lang.String annotationParam, java.lang.String annotationValue, boolean allowAll)Validates the method for the annotation.
 
- Field Detail- NOT_PROCESSED- public static final java.lang.String NOT_PROCESSED Special return code for "not processed".- See Also:
- Constant Field Values
 
 - sourceFile- protected org.eclipse.core.resources.IFile sourceFile The file for ".java" SOURCE file, null if unresolved or binary.
 
 - Constructor Detail- JavaSource- protected JavaSource(JavaSource.Type type) Creates a Java source instance for BINARY.
 - JavaSource- protected JavaSource(org.eclipse.core.resources.IFile sourceFile, ModuleModel model)Creates a Java source instance for PARSED.
 
 - Method Detail- getFileName- public java.lang.String getFileName() Gets the file name.
 - dispose- protected boolean dispose() Disposes of the Java source and all its classes. No call to Java Manager. is done, this call is initiated from there.- Returns:
- true if disposed of, false if already disposed of.
 
 - isDisposed- public boolean isDisposed() Checks if the instance is disposed of.
 - getJavaClassCount- protected int getJavaClassCount() Gets the JavaClass count, for assertions.
 - getJavaProject- public org.eclipse.jdt.core.IJavaProject getJavaProject() Gets the Java project when class is UNRESOLVED or PARSED.- Returns:
- The Java project if possible to retrieve, null otherwise.
 
 - getSourceFile- public org.eclipse.core.resources.IFile getSourceFile() Gets the ".java" source file for PARSED.- Returns:
- The file, null if BINARY or UNRESOLVED.
 
 - getProject- public org.eclipse.core.resources.IProject getProject() Attempts to locate the IProject of the Java source file.- Returns:
- The project, or null if not found.
 
 - getClass- public JavaClass getClass(java.lang.String className, org.eclipse.jdt.core.IType javaType, IClassReferenceListener listener) Called to add a new class name or to get an existing one.- Parameters:
- className- The fully qualified class name.
- javaType- The resolved type or null if not resolved.
- listener- The listener for the JavaClass.
- Returns:
- A new or existing instance of the JavaClass for the type, with a reference listener.
 
 - getType- public JavaSource.Type getType() Gets the file type.
 - onJavaSourceRemoved- protected boolean onJavaSourceRemoved(org.eclipse.core.resources.IFile file) Called when a Java source has been removed.- Parameters:
- file- The file handle.
- Returns:
- true if the file belonged to this class, false otherwise.
 
 - onJavaSourceMoved- protected void onJavaSourceMoved(org.eclipse.core.resources.IFile newFile, java.lang.String oldPKG, java.lang.String newPKG)Called when a Java source has been moved or renamed. The- getSourceFile()method in JavaSource is already moved or renamed when this method is called.- Parameters:
- newFile- The new file name.
- oldPKG- The old class name of the main class.
- newPKG- The new class name of the main class.
 
 - onRefactoringChange- protected void onRefactoringChange(java.lang.String classFQN, java.lang.String oldFQN, java.lang.String newFQN)Called from Refactoring Rename for classes or methods. The "FQN" is for classes including packages, and enclosed classes are separated by '.' and not '$'. For methods, it's the name followed by ',' and "returnType(param1,..,paramN)" as JavaHelper.getSignature gives.- Parameters:
- classFQN- The class fully qualified name, null for classes (only for methods).
- oldFQN- The old fully qualified name or "oldName,signature".
- newFQN- The new fully qualified name or "newName,signature".
 
 - resolveClassReferences- public void resolveClassReferences() When a SOURCE file is touched, e.g. changed or added in the workspace, this method attempts to resolve the class references.- When a Java file is touched, it's package name will attempt to resolve UNRESOLVED classes. 
 - triggerSWTChangeEvent- public void triggerSWTChangeEvent() Triggers an SWT changed event to the JavaClass listeners to perform resolve, etc.
 - clearCache- protected void clearCache() Clears the cache.
 - validateClass- public java.lang.String validateClass(org.eclipse.jdt.core.IType type, java.lang.String implementsInterface, java.lang.String requiredAnnotation, java.lang.String annotationParam, java.lang.String annotationValue)Validates the class for the interface and annotation.- Parameters:
- implementsInterface- The interface required, or null for none.
- requiredAnnotation- The required annotation, or null for none.
- annotationParam- Parameter member value pair to verify the value with for back-referencing, null for none.
- annotationValue- The value to match for back-referencing, null for none.
- Returns:
- null for OK, otherwise an error message.
 
 - validateClassProcessors- protected java.lang.String validateClassProcessors(org.eclipse.jdt.core.IType type, java.lang.String implementsInterface, java.lang.String requiredAnnotation, java.lang.String annotationParam, java.lang.String annotationValue)Validates the class for the interface and annotation.- Parameters:
- implementsInterface- The interface required, or null for none.
- requiredAnnotation- The required annotation, or null for none.
- annotationParam- Parameter member value pair to verify the value with for back-referencing, null for none.
- annotationValue- The value to match for back-referencing, null for none.
- Returns:
- null for OK, otherwise an error message.
 
 - validateMethod- public MethodLookup validateMethod(org.eclipse.jdt.core.IType type, java.lang.String method, boolean isStatic, java.lang.String requiredAnnotation, java.lang.String annotationParam, java.lang.String annotationValue, boolean allowAll) Validates the method for the annotation.- Parameters:
- type- Type containing method.
- method- The method name.
- isStatic- Method must be static flag.
- requiredAnnotation- The required annotation, or null for none.
- annotationParam- Parameter member value pair to verify the value with for back-referencing, null for none.
- annotationValue- The value to match for back-referencing, null for none.
- allowAll- Flag to allow a ref "*" as back-reference.
- Returns:
- The method look-up.
 
 - validateMethodProcessors- protected MethodLookup validateMethodProcessors(org.eclipse.jdt.core.IType type, java.lang.String method, boolean isStatic, java.lang.String requiredAnnotation, java.lang.String annotationParam, java.lang.String annotationValue, boolean allowAll) Validates the method for the annotation.- Parameters:
- method- The method name.
- isStatic- Method must be static flag.
- requiredAnnotation- The required annotation, or null for none.
- annotationParam- Parameter member value pair to verify the value with for back-referencing, null for none.
- annotationValue- The value to match for back-referencing, null for none.
- allowAll- Flag to allow a ref "*" as back-reference.
- Returns:
- The method look-up or null if not processed.
 
 - getPublicOrStaticClasses- protected void getPublicOrStaticClasses(java.util.ArrayList<JavaClass> list) Gets all the JavaClasses available in all projects that are parsed. Matching classes are public and public static inner classes.