xjavadoc

Class XJavaDoc

public final class XJavaDoc extends Object

This class represents the entry-point for xjavadoc classes. Come here to get classes and packages.

Author: Aslak Hellesxy

UNKNOWN: 3. januar 2002

Nested Class Summary
classXJavaDoc.LogMessage
static classXJavaDoc.NoInnerClassesPredicate
Field Summary
static StringIS_UNICODE
Indicates whether this XJavaDoc was built with or without unicode support
static intNO_IMPORTED_PACKAGES
messgage level for reporting unqualified classes when there are no imported packages
static intONE_OR_MORE_IMPORTED_PACKAGES
messgage level for reporting unqualified classes when there are one or more imported packages
static ListPRIMITIVES
Map_abstractFileClasses
Map_allSourceClasses
This map contains the same classes as _sourceSetSourceClasses, but it is also populated with additional classes that may be accessed that were not in the source sets.
Map_binaryClasses
long_birthday
Remember when we're born.
String_docEncoding
charset for generated file
String_encoding
charset for source file
List_logMessages
info, error and warning messages related to parsing and class qualification
Map_packages
static HashMap_primitiveClasses
Map_properties
Set_sourceSetClassNames
Set_sourceSets
Map_sourceSetSourceClasses
This map contains all the classes that were passed in the source sets, excluding all inner classes.
Collection_sourceSetSourceClassesWithInnerClasses
This map contains all the classes that were passed in the source sets, including all inner classes.
XTagFactory_tagFactory
Map_unknownClasses
boolean_useNodeParser
sticky parameter for useNodeParser.
Constructor Summary
XJavaDoc()
Method Summary
voidaddAbstractFile(String qualifiedName, AbstractFile file)
voidaddInnerClassRecursive(XClass outer, Collection c)
Recursively adds inner classes to a collection
XPackageaddPackageMaybe(String packageName)
Describe the method
voidaddPrimitive(String name, String type)
Describe the method
voidaddSourceClass(SourceClass sourceClass)
Adds a source class to the cache.
voidaddSourceSet(SourceSet sourceSet)
Adds a new set of java sources to be parsed.
booleanclassExists(String qualifiedClassName)
StringdereferenceProperties(String value)
ClassgetClass(String qualifiedName)
Returns the Class with the given name, or null if unknown.
StringgetDocEncoding()
Getter for generated file charset.
StringgetEncoding()
Getter for source file charset.
CollectiongetOuterSourceClasses()
Returns all classes in the registered source sets
static PrimitivegetPrimitive(String name)
Gets the Primitive attribute of the XJavaDoc class
MapgetPropertyMap()
CollectiongetSourceClasses(Predicate predicate)
CollectiongetSourceClasses()
Returns all classes in the registered source sets, including inner classes
AbstractFilegetSourceFile(String qualifiedName)
Gets the SourceFile attribute of the XJavaDoc object
static AbstractFilegetSourceFileFor(XProgramElement pe)
Gets the file the pe is contained in.
XPackagegetSourcePackage(String packageName)
Returns the package.
CollectiongetSourcePackages()
Returns the packages of the specified classes during parsing.
XTagFactorygetTagFactory()
XClassgetXClass(String qualifiedName)
Get the XClass corresponding to the qualifiedName.
voidlogMessage(SourceClass clazz, UnknownClass unknownClass, String unqualifiedClassName, int level)
static voidparsePropertyString(String value, List fragments, List propertyRefs)
Parses a string containing ${xxx} style property references into two lists.
voidprintLogMessages(PrintStream out, int level)
Prints the log messages encountered during parsing
static voidprintMemoryStatus()
Dump to sytem out the status of XJavadoc.
voidregisterTags(String classpath)
Registers tags.
static StringreplaceProperties(String value, Map keys)
Replaces ${xxx} style constructions in the given value with the string value of the corresponding data types.
voidreset(boolean resetTimeStamp)
Resets the caches.
SourceClassscanAndPut(String qualifiedName)
Scan's a class and puts it in the cache.
voidsetDocEncoding(String docencoding)
Setter for generated file charset.
voidsetEncoding(String encoding)
Setter for source file charset.
voidsetPropertyMap(Map properties)
voidsetUseNodeParser(boolean useNodeParser)
This method can be called prior to parsing so that all classes are parsed with AST (to make it possible to write the source back to disk)
booleansourceExists(String qualifiedName)
Checks is the source exists
XClassupdateClassTag(String className, String tagName, String parameterName, String parameterValue, int tagIndex)
Describe what the method does
XClassupdateMethodTag(String className, String methodNameWithSignature, String tagName, String parameterName, String parameterValue, int tagIndex)
Describe what the method does

Field Detail

IS_UNICODE

public static final String IS_UNICODE
Indicates whether this XJavaDoc was built with or without unicode support

NO_IMPORTED_PACKAGES

public static final int NO_IMPORTED_PACKAGES
messgage level for reporting unqualified classes when there are no imported packages

ONE_OR_MORE_IMPORTED_PACKAGES

public static final int ONE_OR_MORE_IMPORTED_PACKAGES
messgage level for reporting unqualified classes when there are one or more imported packages

PRIMITIVES

private static final List PRIMITIVES

_abstractFileClasses

private final Map _abstractFileClasses

_allSourceClasses

private final Map _allSourceClasses
This map contains the same classes as _sourceSetSourceClasses, but it is also populated with additional classes that may be accessed that were not in the source sets. This can be superclasses, classes referenced in methods, import statements etc.

_binaryClasses

private final Map _binaryClasses

_birthday

private long _birthday
Remember when we're born. We hate sources that are born after us and we pretend they don't exist, because if we don't we'll have very unpredictable behaviour. Well, since we have editor plugin and this is singleton object, we have to relax our policy on this. Or we will have to restart editor every time we like to tag the same class again...

_docEncoding

private String _docEncoding
charset for generated file

_encoding

private String _encoding
charset for source file

_logMessages

private List _logMessages
info, error and warning messages related to parsing and class qualification

_packages

private final Map _packages

_primitiveClasses

private static HashMap _primitiveClasses

_properties

private final Map _properties

_sourceSetClassNames

private final Set _sourceSetClassNames

_sourceSets

private final Set _sourceSets

_sourceSetSourceClasses

private final Map _sourceSetSourceClasses
This map contains all the classes that were passed in the source sets, excluding all inner classes.

_sourceSetSourceClassesWithInnerClasses

private Collection _sourceSetSourceClassesWithInnerClasses
This map contains all the classes that were passed in the source sets, including all inner classes.

_tagFactory

private final XTagFactory _tagFactory

_unknownClasses

private final Map _unknownClasses

_useNodeParser

private boolean _useNodeParser
sticky parameter for useNodeParser. _useNodeParser = true -> slower parsing, but modifiable javaodcs.

Constructor Detail

XJavaDoc

public XJavaDoc()

Method Detail

addAbstractFile

public void addAbstractFile(String qualifiedName, AbstractFile file)

addInnerClassRecursive

private void addInnerClassRecursive(XClass outer, Collection c)
Recursively adds inner classes to a collection

Parameters: outer The feature to be added to the InnerClassRecursive attribute c The feature to be added to the InnerClassRecursive attribute

addPackageMaybe

XPackage addPackageMaybe(String packageName)
Describe the method

Parameters: packageName Describe the method parameter

Returns: Describe the return value

addPrimitive

private final void addPrimitive(String name, String type)
Describe the method

Parameters: name Describe the method parameter type The feature to be added to the Primitive attribute

addSourceClass

void addSourceClass(SourceClass sourceClass)
Adds a source class to the cache. This method is also called from JavaParser when parsing inner classes.

Parameters: sourceClass Describe the method parameter

addSourceSet

public void addSourceSet(SourceSet sourceSet)
Adds a new set of java sources to be parsed.

Parameters: sourceSet a set of java sources.

classExists

final boolean classExists(String qualifiedClassName)

Parameters: qualifiedClassName

Returns: true if the class exists, either as source or binary

dereferenceProperties

public String dereferenceProperties(String value)

getClass

private final Class getClass(String qualifiedName)
Returns the Class with the given name, or null if unknown.

Parameters: qualifiedName Describe what the parameter does

Returns: The Class value

getDocEncoding

public String getDocEncoding()
Getter for generated file charset.

Returns: encoding

getEncoding

public String getEncoding()
Getter for source file charset.

Returns: encoding

getOuterSourceClasses

private Collection getOuterSourceClasses()
Returns all classes in the registered source sets

Returns: A Collection of XClass

getPrimitive

static Primitive getPrimitive(String name)
Gets the Primitive attribute of the XJavaDoc class

Parameters: name Describe what the parameter does

Returns: The Primitive value

getPropertyMap

public Map getPropertyMap()

getSourceClasses

public Collection getSourceClasses(Predicate predicate)

getSourceClasses

public Collection getSourceClasses()
Returns all classes in the registered source sets, including inner classes

Returns: A Collection of XClass

getSourceFile

private AbstractFile getSourceFile(String qualifiedName)
Gets the SourceFile attribute of the XJavaDoc object

Parameters: qualifiedName Describe what the parameter does

Returns: The SourceFile value

getSourceFileFor

static AbstractFile getSourceFileFor(XProgramElement pe)
Gets the file the pe is contained in. Note: calling this method with a XProgramElement not from source (but from a binary or unknown class) will result in a ClassCastException, so don't do that. This method is only used for diagnostics in error reporting.

Parameters: pe the program element we want the source for.

Returns: the file the program element is contained in.

getSourcePackage

public XPackage getSourcePackage(String packageName)
Returns the package. The package must be one of the packages of the sources. Other packages, such as java.lang are not available.

Parameters: packageName

Returns: an XPackage, or null if the packageName is not among the sources.

getSourcePackages

public Collection getSourcePackages()
Returns the packages of the specified classes during parsing.

Returns: Describe the return value

getTagFactory

public XTagFactory getTagFactory()

getXClass

public XClass getXClass(String qualifiedName)
Get the XClass corresponding to the qualifiedName. This can be a class from source, a precompiled class or a primitive. UnknownClass is never returned from this method, unless it has been previously instantiated. IMPORTANT: If the Java source can be located, an instance of SourceClass will be returned. -Even if that file was not among the files in the fileset or sourceset. IMPORTANT: If qualifiedName represents an inner class, an UnknownClass will be returned unless the enclousing "outer" class has been resolved first.

Parameters: qualifiedName Fully qualified class name

Returns: The XClass value

logMessage

void logMessage(SourceClass clazz, UnknownClass unknownClass, String unqualifiedClassName, int level)

parsePropertyString

public static void parsePropertyString(String value, List fragments, List propertyRefs)
Parses a string containing ${xxx} style property references into two lists. The first list is a collection of text fragments, while the other is a set of string property names. null entries in the first list indicate a property reference from the second list. NOTE: This method was taken directly from Ant's source code (org.apache.tools.ant.ProjectHelper) with the BuildException throwing removed.

Parameters: value Text to parse. Must not be null. fragments List to add text fragments to. Must not be null. propertyRefs List to add property names to. Must not be null.

printLogMessages

public void printLogMessages(PrintStream out, int level)
Prints the log messages encountered during parsing

Parameters: out level

printMemoryStatus

public static void printMemoryStatus()
Dump to sytem out the status of XJavadoc.

registerTags

public void registerTags(String classpath)
Registers tags.

Parameters: classpath where tags are found.

replaceProperties

public static String replaceProperties(String value, Map keys)
Replaces ${xxx} style constructions in the given value with the string value of the corresponding data types. NOTE: This method was taken directly from Ant's source code (org.apache.tools.ant.ProjectHelper) and modified slightly to use a Map instead of a HashMap.

Parameters: value The string to be scanned for property references. May be null , in which case this method returns immediately with no effect. keys Mapping (String to String) of property names to their values. Must not be null.

Returns: the original string with the properties replaced, or null if the original string is null.

reset

public void reset(boolean resetTimeStamp)
Resets the caches.

Parameters: resetTimeStamp true if timestamps should be reset too.

scanAndPut

private SourceClass scanAndPut(String qualifiedName)
Scan's a class and puts it in the cache.

Parameters: qualifiedName Describe what the parameter does

Returns: Describe the return value

setDocEncoding

public void setDocEncoding(String docencoding)
Setter for generated file charset.

Parameters: string encoding

setEncoding

public void setEncoding(String encoding)
Setter for source file charset.

Parameters: string encoding

setPropertyMap

public void setPropertyMap(Map properties)

setUseNodeParser

public void setUseNodeParser(boolean useNodeParser)
This method can be called prior to parsing so that all classes are parsed with AST (to make it possible to write the source back to disk)

Parameters: useNodeParser

sourceExists

private boolean sourceExists(String qualifiedName)
Checks is the source exists

Parameters: qualifiedName the class to check for

Returns: true if source exists.

updateClassTag

public XClass updateClassTag(String className, String tagName, String parameterName, String parameterValue, int tagIndex)
Describe what the method does

Parameters: className Describe what the parameter does tagName Describe what the parameter does parameterName Describe what the parameter does parameterValue Describe what the parameter does tagIndex Describe what the parameter does

Returns: Describe the return value

Throws: XJavaDocException Describe the exception

updateMethodTag

public XClass updateMethodTag(String className, String methodNameWithSignature, String tagName, String parameterName, String parameterValue, int tagIndex)
Describe what the method does

Parameters: className qualified name of class tagName tag name parameterName parameter name parameterValue new parameter value tagIndex index of tag (??) methodNameWithSignature method name followed by signature. no spaces. Ex:
doIt(java.lang.String,int)

Returns: the class corresponding to the className

Throws: XJavaDocException If the tag for some reason couldn't be updated