net.sf.fikin.doclets
Class TemplateTools

java.lang.Object
  extended by net.sf.fikin.doclets.TemplateTools

public class TemplateTools
extends java.lang.Object

Utility class providing methods for various Doclet API specific operations

Typically an object of this class is exported to Velocity templates to be used there. Varialbe name is $tools

created on Sep 24, 2006

Since:
Version:
$Revision: 1.7 $
Author:
fiykov

Constructor Summary
TemplateTools()
           
 
Method Summary
 boolean descendsFrom(com.sun.javadoc.ClassDoc cls, java.lang.String fqClassName)
          tests if this ClassDoc object extends or implements the interface/superclass specified by fqClassName
 com.sun.javadoc.MethodDoc[] getAllMethods(com.sun.javadoc.ClassDoc cls)
          collects all methods of that class, including its own and all inherited ones
protected  void getAllMethodsTraverse(com.sun.javadoc.ClassDoc cls, java.util.Vector methods)
          recursively travers class hierarchy and collects all methods into the vector makes sure that overwriten methods are not duplicated but only last one is present
 java.lang.Object getAntNestedElementCls(com.sun.javadoc.MethodDoc m, com.sun.javadoc.ClassDoc cls)
          get Ant Task nested element ClassDoc representing this element.
 java.lang.String getAntNestedElementName(com.sun.javadoc.MethodDoc m)
          get Ant Task nested element name by removing "add" or "create" prefix from method's name and setting fist character to be lower case.
protected  com.sun.javadoc.Tag getFirstTag(com.sun.javadoc.Doc cls, java.lang.String tagName)
          search all tags and selects first one whose name is as asked
 java.lang.Object getFirstTagByName(com.sun.javadoc.Doc cls, java.lang.String tagName)
          search all tags and selects first one whose name is as asked
 com.sun.javadoc.MethodDoc[] getObjectMethods(com.sun.javadoc.ClassDoc cls)
          get all methods (inherited ones too) and remove all overloaded ones
 com.sun.javadoc.ProgramElementDoc[] getOrderedObjectMethods(com.sun.javadoc.ClassDoc cls)
          get all methods (inherited ones too) and remove all overloaded ones
 java.lang.String getSetterName(com.sun.javadoc.MethodDoc m)
          get setter name by removing "set" prefix from method's name and setting fist character to be lower case.
 com.sun.javadoc.Tag[] getTagsByName(com.sun.javadoc.ClassDoc cls, java.lang.String tagName)
          search all tags and selects only those which name is as asked
 java.lang.String getTagText(com.sun.javadoc.Doc doc, java.lang.String tagName, java.lang.String defaultValue)
          return tag's text or default value if not such tag found
 boolean isAntNestedElement(com.sun.javadoc.MethodDoc m)
          test if this method is Ant Task nested element i.e.
 boolean isAntSetterMethod(com.sun.javadoc.MethodDoc m)
          test if this method is an Ant setter method i.e.
 boolean isAntTaskClass(com.sun.javadoc.ClassDoc cls)
          Test if given class is an Ant Task class i.e.
 boolean isSetter(com.sun.javadoc.MethodDoc m)
          test if this method is setter i.e.
 java.lang.String lpad(java.lang.String text, java.lang.String pad, int len)
          left-pad given text with pad until resulting len equals or become greater than the given len
 com.sun.javadoc.MethodDoc[] removeOverwitenMethods(com.sun.javadoc.MethodDoc[] methods)
          removes all methods which has been deemed as overwriten
 java.lang.String rpad(java.lang.String text, java.lang.String pad, int len)
          right-pad given text with pad until resulting len equals or become greater than the given len
 com.sun.javadoc.ProgramElementDoc[] sortByName(com.sun.javadoc.ProgramElementDoc[] list)
          sorts elements by Name
 com.sun.javadoc.ProgramElementDoc[] sortByQualifiedName(com.sun.javadoc.ProgramElementDoc[] list)
          sorts elements by qualifiedName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TemplateTools

public TemplateTools()
Method Detail

descendsFrom

public boolean descendsFrom(com.sun.javadoc.ClassDoc cls,
                            java.lang.String fqClassName)
tests if this ClassDoc object extends or implements the interface/superclass specified by fqClassName

Parameters:
cls - is the class which is to be tested that implements given interface or superclass
fqClassName - is the superclass or interface to be checked against
Returns:
true if cls implements or extends fqClassName, otherwise false

getTagsByName

public com.sun.javadoc.Tag[] getTagsByName(com.sun.javadoc.ClassDoc cls,
                                           java.lang.String tagName)
search all tags and selects only those which name is as asked

Parameters:
cls - to e inspected
tagName - tag name to be searched for
Returns:
an array with all found tags, sezo size array if none

getFirstTagByName

public java.lang.Object getFirstTagByName(com.sun.javadoc.Doc cls,
                                          java.lang.String tagName)
search all tags and selects first one whose name is as asked

Parameters:
cls - to e inspected
tagName - tag name to be searched for
Returns:
first found tag by that name or "False"

getFirstTag

protected com.sun.javadoc.Tag getFirstTag(com.sun.javadoc.Doc cls,
                                          java.lang.String tagName)
search all tags and selects first one whose name is as asked

Parameters:
cls - to e inspected
tagName - tag name to be searched for
Returns:
first found tag by that name or "False"

getTagText

public java.lang.String getTagText(com.sun.javadoc.Doc doc,
                                   java.lang.String tagName,
                                   java.lang.String defaultValue)
return tag's text or default value if not such tag found

Parameters:
doc -
tagName -
defaultValue -
Returns:
tag's text() or defualtValue in case there is not tag like that

getAllMethods

public com.sun.javadoc.MethodDoc[] getAllMethods(com.sun.javadoc.ClassDoc cls)
collects all methods of that class, including its own and all inherited ones

Parameters:
cls -
Returns:
collected methods fomr the class and all inherited ones

getAllMethodsTraverse

protected void getAllMethodsTraverse(com.sun.javadoc.ClassDoc cls,
                                     java.util.Vector methods)
recursively travers class hierarchy and collects all methods into the vector makes sure that overwriten methods are not duplicated but only last one is present

Parameters:
cls -
methods -

removeOverwitenMethods

public com.sun.javadoc.MethodDoc[] removeOverwitenMethods(com.sun.javadoc.MethodDoc[] methods)
removes all methods which has been deemed as overwriten

Parameters:
methods -
Returns:
resulting list

getObjectMethods

public com.sun.javadoc.MethodDoc[] getObjectMethods(com.sun.javadoc.ClassDoc cls)
get all methods (inherited ones too) and remove all overloaded ones

Parameters:
cls - to inspect
Returns:
resulting list

getOrderedObjectMethods

public com.sun.javadoc.ProgramElementDoc[] getOrderedObjectMethods(com.sun.javadoc.ClassDoc cls)
get all methods (inherited ones too) and remove all overloaded ones

Parameters:
cls - to inspect
Returns:
ordered resulting list

sortByQualifiedName

public com.sun.javadoc.ProgramElementDoc[] sortByQualifiedName(com.sun.javadoc.ProgramElementDoc[] list)
sorts elements by qualifiedName

Parameters:
list -
Returns:
sorted list

sortByName

public com.sun.javadoc.ProgramElementDoc[] sortByName(com.sun.javadoc.ProgramElementDoc[] list)
sorts elements by Name

Parameters:
list -
Returns:
sorted list

lpad

public java.lang.String lpad(java.lang.String text,
                             java.lang.String pad,
                             int len)
left-pad given text with pad until resulting len equals or become greater than the given len

Parameters:
text - to left-pad
pad - string to pad with
len - resuting size string length
Returns:
padded text

rpad

public java.lang.String rpad(java.lang.String text,
                             java.lang.String pad,
                             int len)
right-pad given text with pad until resulting len equals or become greater than the given len

Parameters:
text - to right-pad
pad - string to pad with
len - resuting size string length
Returns:
padded text

isSetter

public boolean isSetter(com.sun.javadoc.MethodDoc m)
test if this method is setter i.e. comforts to:

isAntNestedElement

public boolean isAntNestedElement(com.sun.javadoc.MethodDoc m)
test if this method is Ant Task nested element i.e. comforts to:

isAntSetterMethod

public boolean isAntSetterMethod(com.sun.javadoc.MethodDoc m)
test if this method is an Ant setter method i.e.

Parameters:
m -
Returns:
true if this is ant setter method

isAntTaskClass

public boolean isAntTaskClass(com.sun.javadoc.ClassDoc cls)
Test if given class is an Ant Task class i.e.

Parameters:
cls -
Returns:
true if this is ant task

getSetterName

public java.lang.String getSetterName(com.sun.javadoc.MethodDoc m)
get setter name by removing "set" prefix from method's name and setting fist character to be lower case.

Parameters:
m -
Returns:
setter name

getAntNestedElementName

public java.lang.String getAntNestedElementName(com.sun.javadoc.MethodDoc m)
get Ant Task nested element name by removing "add" or "create" prefix from method's name and setting fist character to be lower case.

Parameters:
m -
Returns:
nested element name

getAntNestedElementCls

public java.lang.Object getAntNestedElementCls(com.sun.javadoc.MethodDoc m,
                                               com.sun.javadoc.ClassDoc cls)
get Ant Task nested element ClassDoc representing this element. This is either the returned type for "create" method or it is the passed parameter for "add" methog

Parameters:
m -
cls - is some class, used to resolve the types
Returns:
nested element backing ClassDoc


Copyright © 2003-2007 Nikolay Fiykov. All Rights Reserved.