Package com.iizigo.java
Class JavaSource
java.lang.Object
com.iizigo.java.JavaSource
- Direct Known Subclasses:
- ParsedJavaSource
Class 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 null file resource.
- Author:
- Christopher Mindus
- Nested Class SummaryNested Classes
- Field SummaryFieldsModifier and TypeFieldDescription- static final StringSpecial return code for "not processed".- protected org.eclipse.core.resources.IFileThe file for ".java" SOURCE file, null if unresolved or binary.
- Constructor SummaryConstructorsModifierConstructorDescription- 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 SummaryModifier and TypeMethodDescription- protected voidClears the cache.- protected boolean- dispose()Disposes of the Java source and all its classes.- getClass- (String className, org.eclipse.jdt.core.IType javaType, IClassReferenceListener listener) Called to add a new class name or to get an existing one.Gets the file name.- protected intGets the JavaClass count, for assertions.- org.eclipse.jdt.core.IJavaProjectGets the Java project when class is UNRESOLVED or PARSED.- org.eclipse.core.resources.IProjectAttempts to locate the IProject of the Java source file.- protected voidGets all the JavaClasses available in all projects that are parsed.- org.eclipse.core.resources.IFileGets the ".java" source file for PARSED.- getType()Gets the file type.- booleanChecks if the instance is disposed of.- protected void- onJavaSourceMoved- (org.eclipse.core.resources.IFile newFile, String oldPKG, 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- (String classFQN, String oldFQN, String newFQN) Called from Refactoring Rename for classes or methods.- voidWhen a SOURCE file is touched, e.g.- voidTriggers an SWT changed event to the JavaClass listeners to perform resolve, etc.- validateClass- (org.eclipse.jdt.core.IType type, String implementsInterface, String requiredAnnotation, String annotationParam, String annotationValue) Validates the class for the interface and annotation.- protected String- validateClassProcessors- (org.eclipse.jdt.core.IType type, String implementsInterface, String requiredAnnotation, String annotationParam, String annotationValue) Validates the class for the interface and annotation.- validateMethod- (org.eclipse.jdt.core.IType type, String method, boolean isStatic, String requiredAnnotation, String annotationParam, String annotationValue, boolean allowAll) Validates the method for the annotation.- protected MethodLookup- validateMethodProcessors- (org.eclipse.jdt.core.IType type, String method, boolean isStatic, String requiredAnnotation, String annotationParam, String annotationValue, boolean allowAll) Validates the method for the annotation.
- Field Details- NOT_PROCESSEDSpecial return code for "not processed".- See Also:
 
- sourceFileprotected org.eclipse.core.resources.IFile sourceFileThe file for ".java" SOURCE file, null if unresolved or binary.
 
- Constructor Details- JavaSourceCreates a Java source instance for BINARY.
- JavaSourceCreates a Java source instance for PARSED.
 
- Method Details- getFileNameGets the file name.
- disposeprotected 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.
 
- isDisposedpublic boolean isDisposed()Checks if the instance is disposed of.
- getJavaClassCountprotected int getJavaClassCount()Gets the JavaClass count, for assertions.
- getJavaProjectpublic 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.
 
- getSourceFilepublic org.eclipse.core.resources.IFile getSourceFile()Gets the ".java" source file for PARSED.- Returns:
- The file, null if BINARY or UNRESOLVED.
 
- getProjectpublic org.eclipse.core.resources.IProject getProject()Attempts to locate the IProject of the Java source file.- Returns:
- The project, or null if not found.
 
- getClasspublic JavaClass getClass- (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.
 
- getTypeGets the file type.
- onJavaSourceRemovedprotected 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.
 
- onJavaSourceMovedprotected void onJavaSourceMoved- (org.eclipse.core.resources.IFile newFile, String oldPKG, 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.
 
- onRefactoringChangeCalled 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".
 
- resolveClassReferencespublic 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. 
- triggerSWTChangeEventpublic void triggerSWTChangeEvent()Triggers an SWT changed event to the JavaClass listeners to perform resolve, etc.
- clearCacheprotected void clearCache()Clears the cache.
- validateClasspublic String validateClass- (org.eclipse.jdt.core.IType type, String implementsInterface, String requiredAnnotation, String annotationParam, 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.
 
- validateClassProcessorsprotected String validateClassProcessors- (org.eclipse.jdt.core.IType type, String implementsInterface, String requiredAnnotation, String annotationParam, 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.
 
- validateMethodpublic MethodLookup validateMethod- (org.eclipse.jdt.core.IType type, String method, boolean isStatic, String requiredAnnotation, String annotationParam, 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.
 
- validateMethodProcessorsprotected MethodLookup validateMethodProcessors- (org.eclipse.jdt.core.IType type, String method, boolean isStatic, String requiredAnnotation, String annotationParam, 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.
 
- getPublicOrStaticClassesGets all the JavaClasses available in all projects that are parsed. Matching classes are public and public static inner classes.