xjavadoc

Class SourceClass

public final class SourceClass extends AbstractClass

This class represents a class for which the source code is available XJavaDocFil

Author: Aslak Hellesxy

UNKNOWN: 3. januar 2002

Field Summary
static intinstanceCount
SimpleNode_compilationUnit
The root node of the AST
boolean_dirty
doe we nees saving?
Reader_in
boolean_isExtraClass
Map_qualifiedClasses
AbstractFile_sourceFile
Keep a ref to the file in case of warning reporting
List_tagsForValidation
Constructor Summary
SourceClass(SourceClass containingClass, XTagFactory tagFactory)
Constructor to use for inner classes.
SourceClass(SourceClass mainClass, int dummy, XTagFactory tagFactory)
Constructor to use for "extra" classes, that is, secondary classes that figure in the same source.
SourceClass(XJavaDoc xJavaDoc, File sourceFile, XTagFactory tagFactory)
Constructor to use for outer classes
SourceClass(XJavaDoc xJavaDoc, Reader sourceFile, XTagFactory tagFactory)
Constructor to use for outer classes
SourceClass(XJavaDoc xJavaDoc, File sourceFile, boolean useNodeParser, XTagFactory tagFactory)
SourceClass(XJavaDoc xJavaDoc, AbstractFile sourceFile, boolean useNodeParser, XTagFactory tagFactory, String encoding)
Constructor to use for outer classes
Method Summary
voidaddTagForValidation(DefaultXTag tag)
SimpleNodegetCompilationUnit()
AbstractFilegetFile()
static StringgetFileName(String qualifiedName)
Describe what the method does
StringgetNextAnonymousClassName()
Returns "1", "2", etc., depending on how many inner classes we have.
ReadergetReader()
Returns a reader for the source code.
booleanisExtraClass()
booleanisOuterClass()
Gets the OuterClass attribute of the SourceClass object
booleanisPrimitive()
booleanisWriteable()
Gets the Writeable attribute of the SourceClass object
longlastModified()
Describe what the method does
voidparse(boolean useNodeParser)
Describe what the method does
voidprint(Writer out)
Prints this class to a stream
XClassqualify(String unqualifiedClassName)
Returns fully qualified name of a class.
voidreset()
Stringsave(File rootDir)
Saves the class at root dir rootDir.
booleansaveNeeded()
voidsetCompilationUnit(SimpleNode compilationUnit)
Called by JavaParser at the end of the parsing
voidsetDirty()
say this class is dirty and needs saving propagate to outer class ( if any )
StringunqualifiedNameInImportedClasses(String unqualifiedClassName)
XClassunqualifiedNameInImportedClassesInnerClasses(String unqualifiedClassName)
StringunqualifiedNameInImportedPackages(String unqualifiedClassName)
Describe what the method does
StringunqualifiedNameInInnerClasses(String unqualifiedClassName)
Describe what the method does
StringunqualifiedNameInInnerClassesOfSuperClass(String unqualifiedClassName)
Resolves Inner classes that exist in the super class hierarchy.
StringunqualifiedNameInInnerInterface(String unqualifiedClassName)
Resolves Inner interfaces that exist in current class.
StringunqualifiedNameInJavaDotLang(String unqualifiedClassName)
Returns the fully qualified class name if it's found in java.lang, otherwise null.
StringunqualifiedNameInTheSameClassAsAnInnerClass(String unqualifiedClassName)
StringunqualifiedNameInTheSamePackage(String unqualifiedClassName)
Describe what the method does
voidvalidateTags()
Called by XJavaDoc after the entire source is parsed, but only if validation is on.

Field Detail

instanceCount

public static int instanceCount

_compilationUnit

private SimpleNode _compilationUnit
The root node of the AST

_dirty

private boolean _dirty
doe we nees saving?

_in

private Reader _in

_isExtraClass

private final boolean _isExtraClass

_qualifiedClasses

private final Map _qualifiedClasses

_sourceFile

private AbstractFile _sourceFile
Keep a ref to the file in case of warning reporting

_tagsForValidation

private final List _tagsForValidation

Constructor Detail

SourceClass

public SourceClass(SourceClass containingClass, XTagFactory tagFactory)
Constructor to use for inner classes.

Parameters: containingClass The containing class;

SourceClass

public SourceClass(SourceClass mainClass, int dummy, XTagFactory tagFactory)
Constructor to use for "extra" classes, that is, secondary classes that figure in the same source.

Parameters: mainClass The containing class. Or rather the "main" class in the source. dummy

SourceClass

public SourceClass(XJavaDoc xJavaDoc, File sourceFile, XTagFactory tagFactory)
Constructor to use for outer classes

Parameters: sourceFile The file containing the source

SourceClass

public SourceClass(XJavaDoc xJavaDoc, Reader sourceFile, XTagFactory tagFactory)
Constructor to use for outer classes

Parameters: sourceFile The file containing the source

SourceClass

public SourceClass(XJavaDoc xJavaDoc, File sourceFile, boolean useNodeParser, XTagFactory tagFactory)

Parameters: sourceFile useNodeParser

SourceClass

public SourceClass(XJavaDoc xJavaDoc, AbstractFile sourceFile, boolean useNodeParser, XTagFactory tagFactory, String encoding)
Constructor to use for outer classes

Parameters: sourceFile The file containing the source useNodeParser

Method Detail

addTagForValidation

public void addTagForValidation(DefaultXTag tag)

getCompilationUnit

public SimpleNode getCompilationUnit()

getFile

public AbstractFile getFile()

getFileName

public static String getFileName(String qualifiedName)
Describe what the method does

Parameters: qualifiedName Describe what the parameter does

Returns: Describe the return value

getNextAnonymousClassName

public String getNextAnonymousClassName()
Returns "1", "2", etc., depending on how many inner classes we have.

Returns: String containing number of next anonymous inner class

getReader

public Reader getReader()
Returns a reader for the source code.

Returns: a reader for the source code.

isExtraClass

public boolean isExtraClass()

isOuterClass

private boolean isOuterClass()
Gets the OuterClass attribute of the SourceClass object

Returns: The OuterClass value

isPrimitive

public boolean isPrimitive()

isWriteable

public boolean isWriteable()
Gets the Writeable attribute of the SourceClass object

Returns: The Writeable value

lastModified

public long lastModified()
Describe what the method does

Returns: Describe the return value

parse

private void parse(boolean useNodeParser)
Describe what the method does

Parameters: useNodeParser Describe what the parameter does

print

public void print(Writer out)
Prints this class to a stream

Parameters: out Describe what the parameter does

qualify

public XClass qualify(String unqualifiedClassName)
Returns fully qualified name of a class. 1: check for "." 2: if "." it's already qualified 3: if no ".", must try with all imported packages or classes

Parameters: unqualifiedClassName Describe what the parameter does

Returns: Describe the return value

reset

public void reset()

save

public String save(File rootDir)
Saves the class at root dir rootDir. The actual java file is derived from tha package name. If no root dir is specified, save where it was loaded from

Parameters: rootDir the root directory.

Returns: the relative fileName to which the file was saved.

Throws: IOException if the file couldn't be saved

saveNeeded

public boolean saveNeeded()

setCompilationUnit

public void setCompilationUnit(SimpleNode compilationUnit)
Called by JavaParser at the end of the parsing

Parameters: compilationUnit The new CompilationUnit value

setDirty

public void setDirty()
say this class is dirty and needs saving propagate to outer class ( if any )

unqualifiedNameInImportedClasses

private final String unqualifiedNameInImportedClasses(String unqualifiedClassName)

unqualifiedNameInImportedClassesInnerClasses

private final XClass unqualifiedNameInImportedClassesInnerClasses(String unqualifiedClassName)

unqualifiedNameInImportedPackages

private final String unqualifiedNameInImportedPackages(String unqualifiedClassName)
Describe what the method does

Parameters: unqualifiedClassName Describe what the parameter does

Returns: Describe the return value

unqualifiedNameInInnerClasses

private final String unqualifiedNameInInnerClasses(String unqualifiedClassName)
Describe what the method does

Parameters: unqualifiedClassName Describe what the parameter does

Returns: Describe the return value

unqualifiedNameInInnerClassesOfSuperClass

private final String unqualifiedNameInInnerClassesOfSuperClass(String unqualifiedClassName)
Resolves Inner classes that exist in the super class hierarchy.

Parameters: unqualifiedClassName Name of the class to resolve

Returns: The qualified name of the inner class.

unqualifiedNameInInnerInterface

private final String unqualifiedNameInInnerInterface(String unqualifiedClassName)
Resolves Inner interfaces that exist in current class. This catches inner classes as well because isInterface() does not indicate if it's an interface.

Parameters: unqualifiedClassName Name of the class to resolve

Returns: The qualified name of the inner class.

unqualifiedNameInJavaDotLang

private final String unqualifiedNameInJavaDotLang(String unqualifiedClassName)
Returns the fully qualified class name if it's found in java.lang, otherwise null.

Parameters: unqualifiedClassName

Returns: fully qualified class name, or null

unqualifiedNameInTheSameClassAsAnInnerClass

private final String unqualifiedNameInTheSameClassAsAnInnerClass(String unqualifiedClassName)

unqualifiedNameInTheSamePackage

private final String unqualifiedNameInTheSamePackage(String unqualifiedClassName)
Describe what the method does

Parameters: unqualifiedClassName Describe what the parameter does

Returns: Describe the return value

validateTags

public void validateTags()
Called by XJavaDoc after the entire source is parsed, but only if validation is on.

Throws: TagValidationException