xjavadoc
Class SourceClass

java.lang.Object
  extended by xjavadoc.AbstractProgramElement
      extended by xjavadoc.AbstractClass
          extended by xjavadoc.SourceClass
All Implemented Interfaces:
java.lang.Comparable, Named, XClass, XProgramElement, XType

public final class SourceClass
extends AbstractClass

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

Author:
Aslak Helles?y

Field Summary
private  SimpleNode _compilationUnit
          The root node of the AST
private  boolean _dirty
          doe we nees saving?
private  java.io.Reader _in
           
private  boolean _isExtraClass
           
private  java.util.Map _qualifiedClasses
           
private  AbstractFile _sourceFile
          Keep a ref to the file in case of warning reporting
private  java.util.List _tagsForValidation
           
static int instanceCount
           
 
Fields inherited from class xjavadoc.AbstractProgramElement
EMPTY_LIST
 
Constructor Summary
SourceClass(SourceClass mainClass, int dummy, XTagFactory tagFactory)
          Constructor to use for "extra" classes, that is, secondary classes that figure in the same source.
SourceClass(SourceClass containingClass, XTagFactory tagFactory)
          Constructor to use for inner classes.
SourceClass(XJavaDoc xJavaDoc, AbstractFile sourceFile, boolean useNodeParser, XTagFactory tagFactory, java.lang.String encoding)
          Constructor to use for outer classes
SourceClass(XJavaDoc xJavaDoc, java.io.File sourceFile, boolean useNodeParser, XTagFactory tagFactory)
           
SourceClass(XJavaDoc xJavaDoc, java.io.File sourceFile, XTagFactory tagFactory)
          Constructor to use for outer classes
SourceClass(XJavaDoc xJavaDoc, java.io.Reader sourceFile, XTagFactory tagFactory)
          Constructor to use for outer classes
 
Method Summary
 void addTagForValidation(DefaultXTag tag)
           
 SimpleNode getCompilationUnit()
           
 AbstractFile getFile()
           
static java.lang.String getFileName(java.lang.String qualifiedName)
          Describe what the method does
 java.lang.String getNextAnonymousClassName()
          Returns "1", "2", etc., depending on how many inner classes we have.
 java.io.Reader getReader()
          Returns a reader for the source code.
 boolean isExtraClass()
           
private  boolean isOuterClass()
          Gets the OuterClass attribute of the SourceClass object
 boolean isPrimitive()
          Returns true if this class is a primitive.
 boolean isWriteable()
          Gets the Writeable attribute of the SourceClass object
 long lastModified()
          Describe what the method does
private  void parse(boolean useNodeParser)
          Describe what the method does
 void print(java.io.Writer out)
          Prints this class to a stream
 XClass qualify(java.lang.String unqualifiedClassName)
          Returns fully qualified name of a class.
 void reset()
           
 java.lang.String save(java.io.File rootDir)
          Saves the class at root dir rootDir.
 boolean saveNeeded()
          whether class needs saving
 void setCompilationUnit(SimpleNode compilationUnit)
          Called by JavaParser at the end of the parsing
 void setDirty()
          say this class is dirty and needs saving propagate to outer class ( if any )
private  java.lang.String unqualifiedNameInImportedClasses(java.lang.String unqualifiedClassName)
           
private  XClass unqualifiedNameInImportedClassesInnerClasses(java.lang.String unqualifiedClassName)
           
private  java.lang.String unqualifiedNameInImportedPackages(java.lang.String unqualifiedClassName)
          Describe what the method does
private  java.lang.String unqualifiedNameInInnerClasses(java.lang.String unqualifiedClassName)
          Describe what the method does
private  java.lang.String unqualifiedNameInInnerClassesOfSuperClass(java.lang.String unqualifiedClassName)
          Resolves Inner classes that exist in the super class hierarchy.
private  java.lang.String unqualifiedNameInInnerInterface(java.lang.String unqualifiedClassName)
          Resolves Inner interfaces that exist in current class.
private  java.lang.String unqualifiedNameInJavaDotLang(java.lang.String unqualifiedClassName)
          Returns the fully qualified class name if it's found in java.lang, otherwise null.
private  java.lang.String unqualifiedNameInTheSameClassAsAnInnerClass(java.lang.String unqualifiedClassName)
           
private  java.lang.String unqualifiedNameInTheSamePackage(java.lang.String unqualifiedClassName)
          Describe what the method does
 void validateTags()
          Called by XJavaDoc after the entire source is parsed, but only if validation is on.
 
Methods inherited from class xjavadoc.AbstractClass
addConstructor, addField, addImportedClass, addImportedPackage, addInnerClass, addInterface, addMethod, compareTo, equals, getAllSubclasses, getConstructor, getConstructors, getContainingPackage, getDeclaredInterfaces, getDirectSubclasses, getExtendingInterfaces, getField, getFields, getFields, getFields, getImplementingClasses, getImportedClasses, getImportedPackages, getInnerClasses, getInterfaces, getMethod, getMethod, getMethods, getMethods, getMethods, getMethodTags, getName, getQualifiedName, getSuperclass, getSuperElement, getSuperInterfaceElements, getTransformedName, getTransformedQualifiedName, getType, hashCode, hasImportedClasses, hasImportedPackages, hasInnerClasses, isA, isA, isAnonymous, isImplementingInterface, isImplementingInterface, isInner, isInterface, isSubclassOf, isSubclassOf, resolveImportedClasses, setContainingPackage, setInterface, setName, setQualifiedName, setRealised, setSuperclass, toString, updateDoc
 
Methods inherited from class xjavadoc.AbstractProgramElement
addModifier, getContainingAbstractClass, getContainingClass, getDoc, getModifiers, getModifierSpecifier, getTagFactory, getXJavaDoc, isAbstract, isFinal, isPackagePrivate, isPrivate, isProtected, isPublic, isStatic, setToken
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface xjavadoc.XClass
getContainingClass, isAbstract
 
Methods inherited from interface xjavadoc.XProgramElement
getDoc, getModifiers, getModifierSpecifier, getXJavaDoc, isFinal, isPackagePrivate, isPrivate, isProtected, isPublic, isStatic
 

Field Detail

instanceCount

public static int instanceCount

_qualifiedClasses

private final java.util.Map _qualifiedClasses

_isExtraClass

private final boolean _isExtraClass

_tagsForValidation

private final java.util.List _tagsForValidation

_compilationUnit

private SimpleNode _compilationUnit
The root node of the AST


_in

private java.io.Reader _in

_sourceFile

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


_dirty

private boolean _dirty
doe we nees saving?

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,
                   java.io.File sourceFile,
                   XTagFactory tagFactory)
Constructor to use for outer classes

Parameters:
sourceFile - The file containing the source

SourceClass

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

Parameters:
sourceFile - The file containing the source

SourceClass

public SourceClass(XJavaDoc xJavaDoc,
                   java.io.File sourceFile,
                   boolean useNodeParser,
                   XTagFactory tagFactory)
Parameters:
sourceFile -
useNodeParser -

SourceClass

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

Parameters:
sourceFile - The file containing the source
useNodeParser -
Method Detail

getFileName

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

Parameters:
qualifiedName - Describe what the parameter does
Returns:
Describe the return value

isExtraClass

public boolean isExtraClass()

getNextAnonymousClassName

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

Returns:
String containing number of next anonymous inner class

isOuterClass

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

Returns:
The OuterClass value

isWriteable

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

Returns:
The Writeable value

getCompilationUnit

public SimpleNode getCompilationUnit()

getReader

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

Returns:
a reader for the source code.

getFile

public AbstractFile getFile()

isPrimitive

public boolean isPrimitive()
Description copied from interface: XClass
Returns true if this class is a primitive. That is, one of the following:

Returns:
true if a primitive

setDirty

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


setCompilationUnit

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

Parameters:
compilationUnit - The new CompilationUnit value

validateTags

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

Throws:
TagValidationException

addTagForValidation

public void addTagForValidation(DefaultXTag tag)

saveNeeded

public boolean saveNeeded()
Description copied from interface: XClass
whether class needs saving

Returns:
true if save needed

lastModified

public long lastModified()
Describe what the method does

Specified by:
lastModified in interface XClass
Overrides:
lastModified in class AbstractClass
Returns:
Describe the return value

print

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

Parameters:
out - Describe what the parameter does

save

public java.lang.String save(java.io.File rootDir)
                      throws java.io.IOException
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

Specified by:
save in interface XClass
Overrides:
save in class AbstractClass
Parameters:
rootDir - the root directory.
Returns:
the relative fileName to which the file was saved.
Throws:
java.io.IOException - if the file couldn't be saved

qualify

public XClass qualify(java.lang.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

Specified by:
qualify in interface XClass
Overrides:
qualify in class AbstractClass
Parameters:
unqualifiedClassName - Describe what the parameter does
Returns:
Describe the return value

reset

public void reset()
Overrides:
reset in class AbstractClass

unqualifiedNameInImportedClasses

private final java.lang.String unqualifiedNameInImportedClasses(java.lang.String unqualifiedClassName)

unqualifiedNameInImportedClassesInnerClasses

private final XClass unqualifiedNameInImportedClassesInnerClasses(java.lang.String unqualifiedClassName)

unqualifiedNameInInnerClasses

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

Parameters:
unqualifiedClassName - Describe what the parameter does
Returns:
Describe the return value

unqualifiedNameInInnerInterface

private final java.lang.String unqualifiedNameInInnerInterface(java.lang.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.

unqualifiedNameInInnerClassesOfSuperClass

private final java.lang.String unqualifiedNameInInnerClassesOfSuperClass(java.lang.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.

unqualifiedNameInImportedPackages

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

Parameters:
unqualifiedClassName - Describe what the parameter does
Returns:
Describe the return value

unqualifiedNameInJavaDotLang

private final java.lang.String unqualifiedNameInJavaDotLang(java.lang.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

unqualifiedNameInTheSamePackage

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

Parameters:
unqualifiedClassName - Describe what the parameter does
Returns:
Describe the return value

unqualifiedNameInTheSameClassAsAnInnerClass

private final java.lang.String unqualifiedNameInTheSameClassAsAnInnerClass(java.lang.String unqualifiedClassName)

parse

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

Parameters:
useNodeParser - Describe what the parameter does