User: rinkrank
Date: 02/03/01 04:07:37
Modified: core/src/xdoclet/tags MethodTagsHandler.java
FieldTagsHandler.java ConstructorTagsHandler.java
AbstractProgramElementTagsHandler.java
Log:
-Refactored common logic in Field/Constructor/MethodTagsHandler up in
AbstractProgramElementTagsHandler
(It was pretty bad inheritance-by-copy-paste, and I was guilty of parts of it)
Revision Changes Path
1.26 +32 -418 xdoclet/core/src/xdoclet/tags/MethodTagsHandler.java
Index: MethodTagsHandler.java
===================================================================
RCS file: /cvsroot/xdoclet/xdoclet/core/src/xdoclet/tags/MethodTagsHandler.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -w -r1.25 -r1.26
--- MethodTagsHandler.java 28 Feb 2002 20:22:47 -0000 1.25
+++ MethodTagsHandler.java 1 Mar 2002 12:07:36 -0000 1.26
@@ -18,7 +18,7 @@
/**
* @author Ara Abrahamian ([EMAIL PROTECTED])
* @created Oct 15, 2001
- * @version $Revision: 1.25 $
+ * @version $Revision: 1.26 $
*/
public class MethodTagsHandler extends AbstractProgramElementTagsHandler
{
@@ -85,45 +85,14 @@
* @param clazz Description of Parameter
* @param methodName Description of Parameter
* @param parameters Description of Parameter
+ * @param setCurrentMethod
* @return Description of the Returned Value
+ * @exception XDocletException
*/
- protected static boolean hasMethod( ClassDoc clazz, String methodName,
String[] parameters )
+ protected static boolean hasMethod( ClassDoc clazz, String methodName,
String[] parameters, boolean setCurrentMethod )
+ throws XDocletException
{
- Category cat = Log.getCategory( MethodTagsHandler.class, "hasMethod" );
-
- while( clazz != null )
- {
- MethodDoc[] methods = clazz.methods();
-
- methodLoop :
- for( int i = 0; i < methods.length; i++ )
- {
- if( methods[i].name().equals( methodName ) )
- {
- // All parameters must be equal to have
"method equality"
- Parameter[] params = methods[i].parameters();
-
- cat.debug( "params.length=" + params.length );
-
- for( int j = 0; j < params.length; j++ )
- {
- cat.debug( "params[j].typeName()=" +
params[j].typeName() );
- cat.debug( "parameters[j]=" +
parameters[j] );
-
- if( parameters == null ||
!params[j].typeName().equals( parameters[j] ) )
- continue methodLoop;
- }
-
- // The class has the given method
- return true;
- }
- }
-
- // Check super class info
- clazz = clazz.superclass();
- }
-
- return false;
+ return hasExecutableMember( clazz, methodName, parameters,
setCurrentMethod, FOR_METHOD );
}
/**
@@ -250,53 +219,7 @@
*/
public String methodComment( Properties attributes ) throws XDocletException
{
- String no_comment_signs = attributes.getProperty( "no-comment-signs" );
-
- if( no_comment_signs != null && no_comment_signs.equalsIgnoreCase(
"true" ) )
- return getCurrentMethod().commentText();
-
- char[] spaces = getIndentChars( attributes );
- Tag[] method_tags = getCurrentMethod().tags();
-
- if( method_tags.length > 0 )
- {
- StringBuffer result = new StringBuffer();
-
- //add user comments
- StringTokenizer st = new StringTokenizer(
getCurrentMethod().commentText().trim(), "\n", false );
-
- if( st.countTokens() > 0 )
- {
- result.append( spaces ).append( "/**" ).append(
PrettyPrintWriter.LINE_SEPARATOR );
- while( st.hasMoreTokens() )
- {
- result.append( spaces ).append( " * "
).append( st.nextToken().trim() ).append( PrettyPrintWriter.LINE_SEPARATOR );
- }
-
- for( int i = 0; i < method_tags.length; i++ )
- {
- //all of our xdoclet-specific tags have a ":"
or "."
- String method_tag_name = method_tags[i].name();
-
- if( method_tag_name.lastIndexOf( ':' ) == -1
&& method_tag_name.lastIndexOf( '.' ) == -1 )
- {
- result.append( spaces ).append( " * " )
- .append( method_tags[i].name()
).append( ' ' )
- .append( method_tags[i].text()
);
-
- //for all lines but not the last line
- if( i < method_tags.length - 1 )
- result.append(
PrettyPrintWriter.LINE_SEPARATOR );
- }
- }
-
- result.append( spaces ).append( " */" );
- }
-
- return result.toString();
- }
- else
- return "";
+ return memberComment( attributes, FOR_METHOD );
}
/**
@@ -319,46 +242,7 @@
*/
public String exceptionList( Properties attributes ) throws XDocletException
{
- String skip_exceptions = attributes.getProperty( "skip" );
- String append_exceptions = attributes.getProperty( "append" );
- String method_name = attributes.getProperty( "method" );
- ClassDoc[] exceptions = null;
-
- if( getCurrentMethod() == null && method_name == null )
- return "";
-
- if( method_name == null )
- exceptions = getCurrentMethod().thrownExceptions();
- else
- {
- MethodDoc method_doc = getMethodDocForMethodName( method_name,
true );
-
- //no method with the specified name found in class
- if( method_doc == null )
- return "";
-
- exceptions = method_doc.thrownExceptions();
- }
-
- StringBuffer st = new StringBuffer();
- String type = null;
-
- for( int i = 0; i < exceptions.length; i++ )
- {
- type = exceptions[i].toString();
-
- if( isInSkipExceptionsList( skip_exceptions, type ) == false &&
- isInAppendExceptionsList( append_exceptions, type ) ==
false )
- {
- appendException( st, type );
- }
- }
-
- //append all exceptions specfied to be always appended by default
- if( append_exceptions != null )
- appendException( st, append_exceptions );
-
- return st.toString();
+ return exceptionList( attributes, FOR_METHOD );
}
/**
@@ -370,27 +254,13 @@
* @see
#ifIsNotAbstract(java.lang.String,java.util.Properties)
* @doc:tag type="block"
* @doc:param name="method" optional="true" description="The
- * method name of which exceptions list is extracted. If not specified
- * then current method is used."
+ * method name of which abstractness is evaluated. If not specified then
+ * current method is used."
*/
public void ifIsAbstract( String template, Properties attributes ) throws
XDocletException
{
- String method_name = attributes.getProperty( "method" );
-
- if( method_name == null )
+ if( isAbstract( attributes ) )
{
- if( getCurrentMethod().isAbstract() )
- generate( template );
- }
- else
- {
- MethodDoc method_doc = getMethodDocForMethodName( method_name,
false );
-
- //no method with the specified name found in class
- if( method_doc == null )
- throw new XDocletException( Translator.getString(
"method_not_found", new String[]{method_name} ) );
-
- if( method_doc.isAbstract() )
generate( template );
}
}
@@ -409,22 +279,8 @@
*/
public void ifIsNotAbstract( String template, Properties attributes ) throws
XDocletException
{
- String method_name = attributes.getProperty( "method" );
-
- if( method_name == null )
- {
- if( !getCurrentMethod().isAbstract() )
- generate( template );
- }
- else
+ if( !isAbstract( attributes ) )
{
- MethodDoc method_doc = getMethodDocForMethodName( method_name,
false );
-
- //no method with the specified name found in class
- if( method_doc == null )
- throw new XDocletException( Translator.getString(
"method_not_found", new String[]{method_name} ) );
-
- if( !method_doc.isAbstract() )
generate( template );
}
}
@@ -495,59 +351,7 @@
*/
public void forAllMethods( String template, Properties attributes ) throws
XDocletException
{
- boolean superclasses = TypeConversionUtil.stringToBoolean(
attributes.getProperty( "superclasses" ), true );
- boolean sort = TypeConversionUtil.stringToBoolean(
attributes.getProperty( "sort" ), true );
- ClassDoc cur_class = getCurrentClass();
- Map already = new HashMap();
-
- do
- {
- MethodDoc[] methods = cur_class.methods();
-
- if( sort == true )
- {
- List the_list = Arrays.asList( methods );
-
- //sort methods
- Collections.sort( the_list,
- new Comparator()
- {
- public int compare( Object o1, Object
o2 )
- {
- MethodDoc m1 = ( MethodDoc )
o1;
- MethodDoc m2 = ( MethodDoc )
o2;
-
- return m1.name().compareTo(
m2.name() );
- }
-
- public boolean equals( Object obj )
- {
- //dumb
- return obj == this;
- }
- } );
-
- methods = ( MethodDoc[] ) the_list.toArray( methods );
- }
-
- for( int j = 0; j < methods.length; j++ )
- {
- if( superclasses == false || ( superclasses == true &&
methods[j].containingClass() == cur_class ) )
- {
- if( already.containsKey( methods[j] ) == false
)
- {
- setCurrentMethod( methods[j] );
- already.put( methods[j], methods[j] );
- generate( template );
- }
- }
- }
-
- if( superclasses == true )
- cur_class = cur_class.superclass();
- else
- break;
- }while ( cur_class != null );
+ forAllMembers( template, attributes, FOR_METHOD );
}
/**
@@ -711,24 +515,7 @@
*/
public void forAllMethodTags( String template, Properties attributes ) throws
XDocletException
{
- if( getCurrentMethod() == null )
- throw new XDocletException( Translator.getString(
"only_call_method_not_null", new String[]{"forAllMethodTags"} ) );
-
- Tag[] tags = DocletUtil.getTagsByName( getCurrentMethod(),
attributes.getProperty( "tagName" ) );
-
- for( int i = 0; i < tags.length; i++ )
- {
- setCurrentTag( tags[i] );
-
- String m = getTagValue( attributes, FOR_METHOD );
-
- if( matchPattern == null )
- generate( template );
- else if( matchPattern != null && ( matchPattern.equals( m ) ||
m.equals( "*" ) ) )
- generate( template );
- }
-
- setCurrentTag( null );
+ forAllMemberTags( template, attributes, FOR_METHOD,
"only_call_method_not_null", new String[]{"forAllMethodTags"} );
}
/**
@@ -749,51 +536,7 @@
*/
public void forAllMethodTagTokens( String template, Properties attributes )
throws XDocletException
{
- Category cat = Log.getCategory( MethodTagsHandler.class,
"forAllMethodTagTokens" );
-
- // get method tag value to iterate over
- String tagValue = getTagValue( attributes, FOR_METHOD );
- String delimiter = attributes.getProperty( "delimiter" );
- String s = attributes.getProperty( "skip" );
- int skip;
-
- try
- {
- skip = Integer.valueOf( attributes.getProperty( "skip" )
).intValue();
- }
- catch( Throwable t )
- {
- skip = 0;
- }
-
- if( delimiter == null )
- {
- if( cat.isDebugEnabled() )
- cat.debug( "got null delimiter -
forAllMethodTagTokens" );
-
- delimiter = PARAMETER_DELIMITER;
- }
-
- tagTokenizer = new StringTokenizer( tagValue, delimiter, false );
- currentToken = "";
- matchPattern = null;
-
- for( int i = 0; tagTokenizer.hasMoreTokens() && i < skip; i++ )
- tagTokenizer.nextToken();
-
- while( tagTokenizer.hasMoreTokens() )
- {
- currentToken = tagTokenizer.nextToken();
-
- if( cat.isDebugEnabled() )
- cat.debug( "generate current token: " + currentToken );
-
- generate( template );
- }
-
- currentToken = null;
- tagTokenizer = null;
- matchPattern = null;
+ forAllMemberTagTokens( template, attributes, FOR_METHOD );
}
/**
@@ -936,154 +679,25 @@
ifHasMethod_Impl( template, attributes, false );
}
- /**
- * Searches for the MethodDoc of the method with name methodName and returns
- * it.
- *
- * @param methodName Description of Parameter
- * @return The MethodDocForMethodName value
- */
- protected MethodDoc getMethodDocForMethodName( String methodName )
- {
- if( methodName != null )
- return extractMethodDoc( getCurrentClass(), methodName );
-
- return null;
- }
-
- /**
- * Searches for the MethodDoc of the method with name methodName and returns
- * it.
- *
- * @param methodName The method to return MethodDoc for.
- * @param superclasses Search superclasses.
- * @return The MethodDoc for the method named value
- */
- protected MethodDoc getMethodDocForMethodName( String methodName, boolean
superclasses )
- {
- if( !superclasses )
- return getMethodDocForMethodName( methodName );
-
- for( ClassDoc clazz = getCurrentClass(); clazz != null; clazz =
clazz.superclass() )
- {
- MethodDoc method = extractMethodDoc( clazz, methodName );
-
- if( method != null )
- return method;
- }
- return null;
- }
-
- /**
- * Returns true if a method with the specified methodName+parameters is found
- * in the class clazz. The parameters array can be empty, if so any method with
- * any set of parameters is considered equal to the method we're searching for.
- * if not empty all parameters of the method must be equal to the ones
- * specified in parameters array to have "method equality".
- *
- * @param clazz Description of Parameter
- * @param methodName Description of Parameter
- * @param parameters Description of Parameter
- * @param setCurrentMethod Description of Parameter
- * @return Description of the Returned Value
- */
- protected boolean hasMethod( ClassDoc clazz, String methodName, String[]
parameters, boolean setCurrentMethod )
- {
- Category cat = Log.getCategory( MethodTagsHandler.class, "hasMethod" );
-
- if( cat.isDebugEnabled() )
- cat.debug( "Search for method " + methodName + " in " +
clazz.name() );
-
- while( clazz != null )
- {
- MethodDoc[] methods = clazz.methods();
-
- methodLoop :
- for( int i = 0; i < methods.length; i++ )
- {
- if( methods[i].name().equals( methodName ) )
- {
- // All parameters must be equal to have
"method equality"
- Parameter[] params = methods[i].parameters();
-
- if( parameters == null )
- {
- // The class has the given method
- if( setCurrentMethod )
- setCurrentMethod( methods[i] );
- return true;
- }
- if( parameters != null && params == null )
- continue methodLoop;
- if( parameters.length != params.length )
- continue methodLoop;
- for( int j = 0; j < params.length; j++ )
+ private boolean isAbstract( Properties attributes ) throws XDocletException
{
- if( !params[j].typeName().equals(
parameters[j] ) )
- continue methodLoop;
- }
- // we have to handle the inverse order as well
- for( int j = 0; j < parameters.length; j++ )
- {
- if( !params[j].typeName().equals(
parameters[j] ) )
- continue methodLoop;
- }
- if( cat.isDebugEnabled() )
- cat.debug( "Method found in " +
clazz.name() );
-
- // The class has the given method
- if( setCurrentMethod )
- setCurrentMethod( methods[i] );
- return true;
- }
- }
-
- // Check super class info
- clazz = clazz.superclass();
- }
- if( cat.isDebugEnabled() )
- cat.debug( "Method not found" );
-
- return false;
- }
+ String method_name = attributes.getProperty( "method" );
- private boolean isInAppendExceptionsList( String append_exceptions, String
type )
+ if( method_name == null )
{
- if( append_exceptions == null )
- return false;
- else
- return append_exceptions.indexOf( type ) != -1;
+ return getCurrentMethod().isAbstract();
}
-
- private boolean isInSkipExceptionsList( String skip_exceptions, String type )
- {
- if( skip_exceptions == null )
- return false;
else
- return skip_exceptions.indexOf( type ) != -1;
- }
-
- private MethodDoc extractMethodDoc( ClassDoc clazz, String methodName )
{
- MethodDoc[] methods = clazz.methods();
+ MethodDoc method_doc = ( MethodDoc )
getExecutableMemberDocForMemberName( method_name, false, FOR_METHOD );
- for( int i = 0; i < methods.length; i++ )
- {
- if( methods[i].name().equals( methodName ) )
- return methods[i];
- }
+ //no method with the specified name found in class
+ if( method_doc == null )
+ throw new Error( "GRRR:" );
+// throw new XDocletException( Translator.getString(
"method_not_found", new String[]{method_name} ) );
- return null;
+ return method_doc.isAbstract();
}
-
- private void appendException( StringBuffer st, String type )
- {
- if( st.length() == 0 )
- st.append( "throws " );
- else
- st.append( ", " );
-
- st.append( type );
}
/**
1.8 +66 -69 xdoclet/core/src/xdoclet/tags/FieldTagsHandler.java
Index: FieldTagsHandler.java
===================================================================
RCS file: /cvsroot/xdoclet/xdoclet/core/src/xdoclet/tags/FieldTagsHandler.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -w -r1.7 -r1.8
--- FieldTagsHandler.java 28 Feb 2002 20:22:47 -0000 1.7
+++ FieldTagsHandler.java 1 Mar 2002 12:07:37 -0000 1.8
@@ -17,10 +17,15 @@
/**
* @author <a href="mailto:[EMAIL PROTECTED]">Aslak Helles�y</a>
* @created 13. januar 2002
- * @version $Revision: 1.7 $
+ * @version $Revision: 1.8 $
*/
public class FieldTagsHandler extends AbstractProgramElementTagsHandler
{
+
+ public static String getFieldTypeFor( FieldDoc field ) throws XDocletException
+ {
+ return field.type().qualifiedTypeName() + field.type().dimension();
+ }
/**
* Iterates over all fields of current class and evaluates the body of the tag
* for each field.
@@ -37,60 +42,36 @@
*/
public void forAllFields( String template, Properties attributes ) throws
XDocletException
{
- boolean superclasses = TypeConversionUtil.stringToBoolean(
attributes.getProperty( "superclasses" ), true );
- boolean sort = TypeConversionUtil.stringToBoolean(
attributes.getProperty( "sort" ), true );
-
- ClassDoc cur_class = getCurrentClass();
- Map already = new HashMap();
-
- do
- {
- FieldDoc[] fields = cur_class.fields();
-
- if( sort == true )
- {
- List the_list = Arrays.asList( fields );
-
- //sort fields
- Collections.sort( the_list,
- new Comparator()
- {
- public int compare( Object o1, Object
o2 )
- {
- FieldDoc m1 = ( FieldDoc ) o1;
- FieldDoc m2 = ( FieldDoc ) o2;
-
- return m1.name().compareTo(
m2.name() );
+ forAllMembers( template, attributes, FOR_FIELD );
}
- public boolean equals( Object obj )
+ /**
+ * Returns the name of the current field.
+ *
+ * @return Description of the Returned Value
+ * @exception XDocletException Description of Exception
+ * @doc:tag type="content"
+ */
+ public String fieldName() throws XDocletException
{
- //dumb
- return obj == this;
+ return getCurrentField().name();
}
- } );
- fields = ( FieldDoc[] ) the_list.toArray( fields );
- }
-
- for( int j = 0; j < fields.length; j++ )
- {
- if( superclasses == false || ( superclasses == true &&
fields[j].containingClass() == cur_class ) )
- {
- if( already.containsKey( fields[j] ) == false )
+ /**
+ * The comment for the current field.
+ *
+ * @param attributes The attributes of the template tag
+ * @return Description of the Returned Value
+ * @exception XDocletException Description of Exception
+ * @see
ClassTagsHandler#classComment(java.util.Properties)
+ * @doc:tag type="content"
+ * @doc:param name="no-comment-signs" optional="true"
+ * values="true,false" description="If true then don't decorate the
+ * comment with comment signs."
+ */
+ public String fieldComment( Properties attributes ) throws XDocletException
{
- setCurrentField( fields[j] );
- already.put( fields[j], fields[j] );
- generate( template );
- }
- }
- }
-
- if( superclasses == true )
- cur_class = cur_class.superclass();
- else
- break;
- }while ( cur_class != null );
+ return memberComment( attributes, FOR_FIELD );
}
/**
@@ -106,24 +87,28 @@
*/
public void forAllFieldTags( String template, Properties attributes ) throws
XDocletException
{
- if( getCurrentField() == null )
- throw new XDocletException( Translator.getString(
"only_call_field_not_null", new String[]{"forAllFieldTags"} ) );
-
- Tag[] tags = DocletUtil.getTagsByName( getCurrentField(),
attributes.getProperty( "tagName" ) );
-
- for( int i = 0; i < tags.length; i++ )
- {
- setCurrentTag( tags[i] );
-
- String m = getTagValue( attributes, FOR_FIELD );
-
- if( matchPattern == null )
- generate( template );
- else if( matchPattern != null && ( matchPattern.equals( m ) ||
m.equals( "*" ) ) )
- generate( template );
+ forAllMemberTags( template, attributes, FOR_FIELD,
"only_call_field_not_null", new String[]{"forAllFieldTags"} );
}
- setCurrentTag( null );
+ /**
+ * Iterates over all tokens in current field tag with the name tagName and
+ * evaluates the body for every token.
+ *
+ * @param template The body of the block tag
+ * @param attributes The attributes of the template tag
+ * @exception XDocletException Description of Exception
+ * @doc:tag type="block"
+ * @doc:param name="tagName" optional="false"
+ * description="The tag name."
+ * @doc:param name="delimiter" description="delimiter for the
+ * StringTokenizer. consult javadoc for java.util.StringTokenizer default
+ * is ','"
+ * @doc:param name="skip" description="how many tokens to
+ * skip on start"
+ */
+ public void forAllFieldTagTokens( String template, Properties attributes )
throws XDocletException
+ {
+ forAllMemberTagTokens( template, attributes, FOR_FIELD );
}
/**
@@ -152,6 +137,18 @@
// setting field to true will override the for_class value.
attributes.setProperty( "field", "true" );
return getTagValue( attributes, FOR_FIELD );
+ }
+
+ /**
+ * Returns the type of the current field.
+ *
+ * @return Description of the Returned Value
+ * @exception XDocletException Description of Exception
+ * @doc:tag type="content"
+ */
+ public String fieldType() throws XDocletException
+ {
+ return getFieldTypeFor( getCurrentField() );
}
/**
1.4 +15 -393 xdoclet/core/src/xdoclet/tags/ConstructorTagsHandler.java
Index: ConstructorTagsHandler.java
===================================================================
RCS file:
/cvsroot/xdoclet/xdoclet/core/src/xdoclet/tags/ConstructorTagsHandler.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -w -r1.3 -r1.4
--- ConstructorTagsHandler.java 28 Feb 2002 20:22:47 -0000 1.3
+++ ConstructorTagsHandler.java 1 Mar 2002 12:07:37 -0000 1.4
@@ -18,7 +18,7 @@
/**
* @author Jerome Bernard ([EMAIL PROTECTED])
* @created Jan 18, 2002
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*/
public class ConstructorTagsHandler extends AbstractProgramElementTagsHandler
{
@@ -32,45 +32,14 @@
* @param clazz Description of Parameter
* @param constructorName Description of Parameter
* @param parameters Description of Parameter
+ * @param setCurrentConstructor
* @return Description of the Returned Value
+ * @exception XDocletException
*/
- protected static boolean hasConstructor( ClassDoc clazz, String
constructorName, String[] parameters )
+ protected static boolean hasConstructor( ClassDoc clazz, String
constructorName, String[] parameters, boolean setCurrentConstructor )
+ throws XDocletException
{
- Category cat = Log.getCategory( ConstructorTagsHandler.class,
"hasConstructor" );
-
- while( clazz != null )
- {
- ConstructorDoc[] constructors = clazz.constructors();
-
- constructorLoop :
- for( int i = 0; i < constructors.length; i++ )
- {
- if( constructors[i].name().equals( constructorName ) )
- {
- // All parameters must be equal to have
"constructor equality"
- Parameter[] params =
constructors[i].parameters();
-
- cat.debug( "params.length=" + params.length );
-
- for( int j = 0; j < params.length; j++ )
- {
- cat.debug( "params[j].typeName()=" +
params[j].typeName() );
- cat.debug( "parameters[j]=" +
parameters[j] );
-
- if( parameters == null ||
!params[j].typeName().equals( parameters[j] ) )
- continue constructorLoop;
- }
-
- // The class has the given constructor
- return true;
- }
- }
-
- // Check super class info
- clazz = clazz.superclass();
- }
-
- return false;
+ return hasExecutableMember( clazz, constructorName, parameters,
setCurrentConstructor, FOR_CONSTRUCTOR );
}
/**
@@ -114,7 +83,7 @@
ConstructorDoc oldConstructor = getCurrentConstructor();
- if( hasConstructor( getCurrentClass(), constructorName, parameters,
true ) == true )
+ if( hasConstructor( getCurrentClass(), constructorName, parameters,
true ) )
{
generate( template );
}
@@ -136,53 +105,7 @@
*/
public String constructorComment( Properties attributes ) throws
XDocletException
{
- String no_comment_signs = attributes.getProperty( "no-comment-signs" );
-
- if( no_comment_signs != null && no_comment_signs.equalsIgnoreCase(
"true" ) )
- return getCurrentConstructor().commentText();
-
- char[] spaces = getIndentChars( attributes );
- Tag[] constructor_tags = getCurrentConstructor().tags();
-
- if( constructor_tags.length > 0 )
- {
- StringBuffer result = new StringBuffer();
-
- //add user comments
- StringTokenizer st = new StringTokenizer(
getCurrentConstructor().commentText().trim(), "\n", false );
-
- if( st.countTokens() > 0 )
- {
- result.append( spaces ).append( "/**" ).append(
PrettyPrintWriter.LINE_SEPARATOR );
- while( st.hasMoreTokens() )
- {
- result.append( spaces ).append( " * "
).append( st.nextToken().trim() ).append( PrettyPrintWriter.LINE_SEPARATOR );
- }
-
- for( int i = 0; i < constructor_tags.length; i++ )
- {
- //all of our xdoclet-specific tags have a ":"
or "."
- String constructor_tag_name =
constructor_tags[i].name();
-
- if( constructor_tag_name.lastIndexOf( ':' ) ==
-1 && constructor_tag_name.lastIndexOf( '.' ) == -1 )
- {
- result.append( spaces ).append( " * " )
- .append(
constructor_tags[i].name() ).append( ' ' )
- .append(
constructor_tags[i].text() );
-
- //for all lines but not the last line
- if( i < constructor_tags.length - 1 )
- result.append(
PrettyPrintWriter.LINE_SEPARATOR );
- }
- }
-
- result.append( spaces ).append( " */" );
- }
-
- return result.toString();
- }
- else
- return "";
+ return memberComment( attributes, FOR_CONSTRUCTOR );
}
/**
@@ -205,46 +128,7 @@
*/
public String exceptionList( Properties attributes ) throws XDocletException
{
- String skip_exceptions = attributes.getProperty( "skip" );
- String append_exceptions = attributes.getProperty( "append" );
- String constructor_name = attributes.getProperty( "constructor" );
- ClassDoc[] exceptions = null;
-
- if( getCurrentConstructor() == null && constructor_name == null )
- return "";
-
- if( constructor_name == null )
- exceptions = getCurrentConstructor().thrownExceptions();
- else
- {
- ConstructorDoc constructor_doc =
getConstructorDocForConstructorName( constructor_name, true );
-
- //no constructor with the specified name found in class
- if( constructor_doc == null )
- return "";
-
- exceptions = constructor_doc.thrownExceptions();
- }
-
- StringBuffer st = new StringBuffer();
- String type = null;
-
- for( int i = 0; i < exceptions.length; i++ )
- {
- type = exceptions[i].toString();
-
- if( isInSkipExceptionsList( skip_exceptions, type ) == false &&
- isInAppendExceptionsList( append_exceptions, type ) ==
false )
- {
- appendException( st, type );
- }
- }
-
- //append all exceptions specfied to be always appended by default
- if( append_exceptions != null )
- appendException( st, append_exceptions );
-
- return st.toString();
+ return exceptionList( attributes, FOR_CONSTRUCTOR );
}
/**
@@ -313,75 +197,8 @@
*/
public void forAllConstructors( String template, Properties attributes )
throws XDocletException
{
- boolean superclasses = TypeConversionUtil.stringToBoolean(
attributes.getProperty( "superclasses" ), true );
- boolean sort = TypeConversionUtil.stringToBoolean(
attributes.getProperty( "sort" ), true );
- ClassDoc cur_class = getCurrentClass();
- List already = new ArrayList();
-
- do
- {
- ConstructorDoc[] constructors = cur_class.constructors();
- ConstructorDoc constructorFound = null;
-
- if( sort == true )
- {
- List the_list = Arrays.asList( constructors );
-
- //sort constructors
- Collections.sort( the_list,
- new Comparator()
- {
- public int compare( Object o1, Object
o2 )
- {
- ConstructorDoc m1 = (
ConstructorDoc ) o1;
- ConstructorDoc m2 = (
ConstructorDoc ) o2;
-
- return m1.name().compareTo(
m2.name() );
- }
-
- public boolean equals( Object obj )
- {
- //dumb
- return obj == this;
- }
- } );
-
- constructors = ( ConstructorDoc[] ) the_list.toArray(
constructors );
- }
-
- for( int j = 0; j < constructors.length; j++ )
- {
- if( superclasses == false || ( superclasses == true &&
constructors[j].containingClass() == cur_class ) )
- {
- // We can not use contains because it is based
on equals() and
- // we need to compare based on compareTo()
- Iterator i = already.iterator();
- boolean contained = false;
-
- while( i.hasNext() )
- {
- if( ( ( ConstructorDoc ) i.next()
).compareTo( constructors[j] ) == 0 )
- contained = true;
-
- if( contained )
- break;
- }
- if( contained == false )
- {
- setCurrentConstructor( constructors[j]
);
- already.add( constructors[j] );
- generate( template );
- }
+ forAllMembers( template, attributes, FOR_CONSTRUCTOR );
}
- }
-
- if( superclasses == true )
- cur_class = cur_class.superclass();
- else
- break;
- }while ( cur_class != null );
- }
-
/**
* Evaluates the body if current constructor doesn't have at least one tag with
* the specified name.
@@ -544,24 +361,7 @@
*/
public void forAllConstructorTags( String template, Properties attributes )
throws XDocletException
{
- if( getCurrentConstructor() == null )
- throw new XDocletException( Translator.getString(
"only_call_constructor_not_null", new String[]{"forAllConstructorTags"} ) );
-
- Tag[] tags = getCurrentConstructor().tags( attributes.getProperty(
"tagName" ) );
-
- for( int i = 0; i < tags.length; i++ )
- {
- setCurrentTag( tags[i] );
-
- String m = getTagValue( attributes, FOR_CONSTRUCTOR );
-
- if( matchPattern == null )
- generate( template );
- else if( matchPattern != null && ( matchPattern.equals( m ) ||
m.equals( "*" ) ) )
- generate( template );
- }
-
- setCurrentTag( null );
+ forAllMemberTags( template, attributes, FOR_CONSTRUCTOR,
"only_call_constructor_not_null", new String[]{"forAllConstructorTags"} );
}
/**
@@ -582,51 +382,7 @@
*/
public void forAllConstructorTagTokens( String template, Properties attributes
) throws XDocletException
{
- Category cat = Log.getCategory( ConstructorTagsHandler.class,
"forAllConstructorTagTokens" );
-
- // get constructor tag value to iterate over
- String tagValue = getTagValue( attributes, FOR_CONSTRUCTOR );
- String delimiter = attributes.getProperty( "delimiter" );
- String s = attributes.getProperty( "skip" );
- int skip;
-
- try
- {
- skip = Integer.valueOf( attributes.getProperty( "skip" )
).intValue();
- }
- catch( Throwable t )
- {
- skip = 0;
- }
-
- if( delimiter == null )
- {
- if( cat.isDebugEnabled() )
- cat.debug( "got null delimiter -
forAllConstructorTagTokens" );
-
- delimiter = PARAMETER_DELIMITER;
- }
-
- tagTokenizer = new StringTokenizer( tagValue, delimiter, false );
- currentToken = "";
- matchPattern = null;
-
- for( int i = 0; tagTokenizer.hasMoreTokens() && i < skip; i++ )
- tagTokenizer.nextToken();
-
- while( tagTokenizer.hasMoreTokens() )
- {
- currentToken = tagTokenizer.nextToken();
-
- if( cat.isDebugEnabled() )
- cat.debug( "generate current token: " + currentToken );
-
- generate( template );
- }
-
- currentToken = null;
- tagTokenizer = null;
- matchPattern = null;
+ forAllMemberTagTokens( template, attributes, FOR_CONSTRUCTOR );
}
/**
@@ -733,140 +489,6 @@
public void ifDoesntHaveConstructor( String template, Properties attributes )
throws XDocletException
{
ifHasConstructor_Impl( template, attributes, false );
- }
-
- /**
- * Searches for the ConstructorDoc of the constructor with name constructorName
- * and returns it.
- *
- * @param constructorName Description of Parameter
- * @return The ConstructorDocForConstructorName value
- */
- protected ConstructorDoc getConstructorDocForConstructorName( String
constructorName )
- {
- if( constructorName != null )
- return extractConstructorDoc( getCurrentClass(),
constructorName );
-
- return null;
- }
-
- /**
- * Searches for the ConstructorDoc of the constructor with name constructorName
- * and returns it.
- *
- * @param constructorName The constructor to return ConstructorDoc for.
- * @param superclasses Search superclasses.
- * @return The ConstructorDoc for the constructor named value
- */
- protected ConstructorDoc getConstructorDocForConstructorName( String
constructorName, boolean superclasses )
- {
- if( !superclasses )
- return getConstructorDocForConstructorName( constructorName );
-
- for( ClassDoc clazz = getCurrentClass(); clazz != null; clazz =
clazz.superclass() )
- {
- ConstructorDoc constructor = extractConstructorDoc( clazz,
constructorName );
-
- if( constructor != null )
- return constructor;
- }
- return null;
- }
-
- /**
- * Returns true if a constructor with the specified constructorName+parameters
- * is found in the class clazz. The parameters array can be empty, if so any
- * constructor with any set of parameters is considered equal to the
- * constructor we're searching for. if not empty all parameters of the
- * constructor must be equal to the ones specified in parameters array to have
- * "constructor equality".
- *
- * @param clazz Description of Parameter
- * @param constructorName Description of Parameter
- * @param parameters Description of Parameter
- * @param setCurrentConstructor Description of Parameter
- * @return Description of the Returned Value
- */
- protected boolean hasConstructor( ClassDoc clazz, String constructorName,
String[] parameters, boolean setCurrentConstructor )
- {
- Category cat = Log.getCategory( ConstructorTagsHandler.class,
"hasConstructor" );
-
- if( cat.isDebugEnabled() )
- cat.debug( "Search for constructor " + constructorName + " in
" + clazz.name() );
-
- while( clazz != null )
- {
- ConstructorDoc[] constructors = clazz.constructors();
-
- constructorLoop :
- for( int i = 0; i < constructors.length; i++ )
- {
- if( constructors[i].name().equals( constructorName ) )
- {
- // All parameters must be equal to have
"constructor equality"
- Parameter[] params =
constructors[i].parameters();
-
- for( int j = 0; j < params.length; j++ )
- {
- if( parameters == null ||
!params[j].typeName().equals( parameters[j] ) )
- continue constructorLoop;
- }
- if( cat.isDebugEnabled() )
- cat.debug( "Constructor found in " +
clazz.name() );
-
- // The class has the given constructor
- if( setCurrentConstructor )
- setCurrentConstructor( constructors[i]
);
- return true;
- }
- }
-
- // Check super class info
- clazz = clazz.superclass();
- }
- if( cat.isDebugEnabled() )
- cat.debug( "Constructor not found" );
-
- return false;
- }
-
- private boolean isInAppendExceptionsList( String append_exceptions, String
type )
- {
- if( append_exceptions == null )
- return false;
- else
- return append_exceptions.indexOf( type ) != -1;
- }
-
- private boolean isInSkipExceptionsList( String skip_exceptions, String type )
- {
- if( skip_exceptions == null )
- return false;
- else
- return skip_exceptions.indexOf( type ) != -1;
- }
-
- private ConstructorDoc extractConstructorDoc( ClassDoc clazz, String
constructorName )
- {
- ConstructorDoc[] constructors = clazz.constructors();
-
- for( int i = 0; i < constructors.length; i++ )
- {
- if( constructors[i].name().equals( constructorName ) )
- return constructors[i];
- }
-
- return null;
- }
-
- private void appendException( StringBuffer st, String type )
- {
- if( st.length() == 0 )
- st.append( "throws " );
- else
- st.append( ", " );
-
- st.append( type );
}
/**
1.21 +465 -1
xdoclet/core/src/xdoclet/tags/AbstractProgramElementTagsHandler.java
Index: AbstractProgramElementTagsHandler.java
===================================================================
RCS file:
/cvsroot/xdoclet/xdoclet/core/src/xdoclet/tags/AbstractProgramElementTagsHandler.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -w -r1.20 -r1.21
--- AbstractProgramElementTagsHandler.java 28 Feb 2002 20:22:47 -0000 1.20
+++ AbstractProgramElementTagsHandler.java 1 Mar 2002 12:07:37 -0000 1.21
@@ -1,8 +1,12 @@
package xdoclet.tags;
import com.sun.javadoc.ClassDoc;
+import com.sun.javadoc.MemberDoc;
+import com.sun.javadoc.FieldDoc;
import com.sun.javadoc.MethodDoc;
-import com.sun.javadoc.ProgramElementDoc;
+import com.sun.javadoc.ExecutableMemberDoc;
+import com.sun.javadoc.Parameter;
+import com.sun.javadoc.ConstructorDoc;
import com.sun.javadoc.Tag;
import org.apache.log4j.Category;
@@ -19,11 +23,14 @@
import java.util.Properties;
import java.util.StringTokenizer;
+import java.util.HashSet;
+import java.util.Arrays;
+import java.util.Comparator;
/**
* @author Ara Abrahamian ([EMAIL PROTECTED])
* @created Oct 15, 2001
- * @version $Revision: 1.20 $
+ * @version $Revision: 1.21 $
*/
public abstract class AbstractProgramElementTagsHandler extends XDocletTagSupport
{
@@ -47,6 +54,24 @@
*/
protected static String matchPattern;
+ private final static Comparator memberComparator =
+ new Comparator()
+ {
+ public int compare( Object o1, Object o2 )
+ {
+ MemberDoc m1 = ( MemberDoc ) o1;
+ MemberDoc m2 = ( MemberDoc ) o2;
+
+ return m1.name().compareTo( m2.name() );
+ }
+
+ public boolean equals( Object obj )
+ {
+ //dumb
+ return obj == this;
+ }
+ };
+
/**
* Returns the not-full-qualified name of the current class without the package
* name.
@@ -103,6 +128,73 @@
return
DocletContext.getInstance().getActiveSubTask().getCurrentPackage().allClasses();
}
+ protected static boolean hasExecutableMember( ClassDoc clazz, String
executableMemberName, String[] parameters, boolean setCurrentExecutableMember, int
for_type )
+ throws XDocletException
+ {
+ Category cat = Log.getCategory( ConstructorTagsHandler.class,
"hasConstructor" );
+
+ while( clazz != null )
+ {
+ ExecutableMemberDoc[] executableMembers = null;
+
+ switch ( for_type )
+ {
+ case FOR_CONSTRUCTOR:
+ executableMembers = clazz.constructors();
+ break;
+ case FOR_METHOD:
+ executableMembers = clazz.methods();
+ break;
+ default:
+ throw new XDocletException( "Bad type: " + for_type );
+ }
+
+ loop :
+ for( int i = 0; i < executableMembers.length; i++ )
+ {
+ if( executableMembers[i].name().equals(
executableMemberName ) )
+ {
+ // All parameters must be equal to have
"constructor equality"
+ Parameter[] params =
executableMembers[i].parameters();
+
+ cat.debug( "params.length=" + params.length );
+
+ for( int j = 0; j < params.length; j++ )
+ {
+ cat.debug( "params[j].typeName()=" +
params[j].typeName() );
+ cat.debug( "parameters[j]=" +
parameters[j] );
+
+ if( parameters == null ||
!params[j].typeName().equals( parameters[j] ) )
+ continue loop;
+ }
+
+ // The class has the given executable member
+ if( setCurrentExecutableMember )
+ {
+ switch ( for_type )
+ {
+ case FOR_CONSTRUCTOR:
+ setCurrentConstructor( (
ConstructorDoc ) executableMembers[i] );
+ break;
+ case FOR_METHOD:
+ setCurrentMethod( ( MethodDoc
) executableMembers[i] );
+ break;
+ default:
+ throw new XDocletException(
"Bad type: " + for_type );
+ }
+ }
+
+ return true;
+ }
+ }
+
+ // Check super class info
+ clazz = clazz.superclass();
+ }
+
+ return false;
+ }
+
/**
* Sets the value of match variable.
*
@@ -228,6 +320,39 @@
return "";
}
+ protected ExecutableMemberDoc getExecutableMemberDocForMemberName( String
memberName, int for_type ) throws XDocletException
+ {
+ if( memberName != null )
+ return extractExecutableMemberDoc( getCurrentClass(),
memberName, for_type );
+
+ return null;
+ }
+
+ /**
+ * Searches for the ExecutableMemberDoc of the member with name methodName and
+ * returns it.
+ *
+ * @param superclasses Search superclasses.
+ * @param memberName
+ * @param for_type
+ * @return The MethodDoc for the method named value
+ * @exception XDocletException
+ */
+ protected ExecutableMemberDoc getExecutableMemberDocForMemberName( String
memberName, boolean superclasses, int for_type ) throws XDocletException
+ {
+ if( !superclasses )
+ return getExecutableMemberDocForMemberName( memberName,
for_type );
+
+ for( ClassDoc clazz = getCurrentClass(); clazz != null; clazz =
clazz.superclass() )
+ {
+ ExecutableMemberDoc member = extractExecutableMemberDoc(
clazz, memberName, for_type );
+
+ if( member != null )
+ return member;
+ }
+ return null;
+ }
+
/**
* A utility method to get the blank space characters used for indenting
* comments.
@@ -253,6 +378,295 @@
return spaces;
}
+ protected String exceptionList( Properties attributes, int for_type ) throws
XDocletException
+ {
+ String skip_exceptions = attributes.getProperty( "skip" );
+ String append_exceptions = attributes.getProperty( "append" );
+ String member_name = null;
+ ClassDoc[] exceptions = null;
+
+ ExecutableMemberDoc executableMember = null;
+
+ switch ( for_type )
+ {
+ case FOR_CONSTRUCTOR:
+ executableMember = getCurrentConstructor();
+ member_name = attributes.getProperty( "constructor" );
+ break;
+ case FOR_METHOD:
+ executableMember = getCurrentMethod();
+ member_name = attributes.getProperty( "method" );
+ break;
+ default:
+ throw new XDocletException( "Can't forAll for type " +
for_type );
+ }
+
+ if( executableMember == null && member_name == null )
+ return "";
+
+ if( member_name == null )
+ exceptions = executableMember.thrownExceptions();
+ else
+ {
+ executableMember = getExecutableMemberDocForMemberName(
member_name, true, for_type );
+
+ //no member with the specified name found in class
+ if( executableMember == null )
+ return "";
+
+ exceptions = executableMember.thrownExceptions();
+ }
+
+ StringBuffer st = new StringBuffer();
+ String type = null;
+
+ for( int i = 0; i < exceptions.length; i++ )
+ {
+ type = exceptions[i].toString();
+
+ if( isInSkipExceptionsList( skip_exceptions, type ) == false &&
+ isInAppendExceptionsList( append_exceptions, type ) ==
false )
+ {
+ appendException( st, type );
+ }
+ }
+
+ //append all exceptions specfied to be always appended by default
+ if( append_exceptions != null )
+ appendException( st, append_exceptions );
+
+ return st.toString();
+ }
+
+ protected void forAllMemberTagTokens( String template, Properties attributes,
int for_type ) throws XDocletException
+ {
+ Category cat = Log.getCategory( MethodTagsHandler.class,
"forAllMemberTagTokens" );
+
+ // get method tag value to iterate over
+ String tagValue = getTagValue( attributes, for_type );
+ String delimiter = attributes.getProperty( "delimiter" );
+ String s = attributes.getProperty( "skip" );
+ int skip;
+
+ try
+ {
+ skip = Integer.valueOf( attributes.getProperty( "skip" )
).intValue();
+ }
+ catch( Throwable t )
+ {
+ skip = 0;
+ }
+
+ if( delimiter == null )
+ {
+ if( cat.isDebugEnabled() )
+ cat.debug( "got null delimiter -
forAllMethodTagTokens" );
+
+ delimiter = PARAMETER_DELIMITER;
+ }
+
+ tagTokenizer = new StringTokenizer( tagValue, delimiter, false );
+ currentToken = "";
+ matchPattern = null;
+
+ for( int i = 0; tagTokenizer.hasMoreTokens() && i < skip; i++ )
+ tagTokenizer.nextToken();
+
+ while( tagTokenizer.hasMoreTokens() )
+ {
+ currentToken = tagTokenizer.nextToken();
+
+ if( cat.isDebugEnabled() )
+ cat.debug( "generate current token: " + currentToken );
+
+ generate( template );
+ }
+
+ currentToken = null;
+ tagTokenizer = null;
+ matchPattern = null;
+ }
+
+ protected void forAllMemberTags( String template, Properties attributes, int
for_type, String resourceKey, String[] arguments ) throws XDocletException
+ {
+ MemberDoc member = null;
+
+ switch ( for_type )
+ {
+ case FOR_FIELD:
+ member = getCurrentField();
+ break;
+ case FOR_CONSTRUCTOR:
+ member = getCurrentConstructor();
+ break;
+ case FOR_METHOD:
+ member = getCurrentMethod();
+ break;
+ default:
+ throw new XDocletException( "Bad type " + for_type );
+ }
+
+ if( member == null )
+ throw new XDocletException( Translator.getString( resourceKey,
arguments ) );
+
+ Tag[] tags = DocletUtil.getTagsByName( member, attributes.getProperty(
"tagName" ) );
+
+ for( int i = 0; i < tags.length; i++ )
+ {
+ setCurrentTag( tags[i] );
+
+ String m = getTagValue( attributes, for_type );
+
+ if( matchPattern == null )
+ generate( template );
+ else if( matchPattern != null && ( matchPattern.equals( m ) ||
m.equals( "*" ) ) )
+ generate( template );
+ }
+
+ setCurrentTag( null );
+ }
+
+ protected String memberComment( Properties attributes, int for_type ) throws
XDocletException
+ {
+ String no_comment_signs = attributes.getProperty( "no-comment-signs" );
+
+ MemberDoc member = null;
+
+ switch ( for_type )
+ {
+ case FOR_FIELD:
+ member = getCurrentField();
+ break;
+ case FOR_CONSTRUCTOR:
+ member = getCurrentConstructor();
+ break;
+ case FOR_METHOD:
+ member = getCurrentMethod();
+ break;
+ default:
+ throw new XDocletException( "Bad type " + for_type );
+ }
+
+ if( no_comment_signs != null && no_comment_signs.equalsIgnoreCase(
"true" ) )
+ {
+ return member.commentText();
+ }
+
+ char[] spaces = getIndentChars( attributes );
+ Tag[] member_tags = member.tags();
+
+ if( member_tags.length > 0 )
+ {
+ StringBuffer result = new StringBuffer();
+
+ //add user comments
+ StringTokenizer st = new StringTokenizer(
member.commentText().trim(), "\n", false );
+
+ if( st.countTokens() > 0 )
+ {
+ result.append( spaces ).append( "/**" ).append(
PrettyPrintWriter.LINE_SEPARATOR );
+ while( st.hasMoreTokens() )
+ {
+ result.append( spaces ).append( " * "
).append( st.nextToken().trim() ).append( PrettyPrintWriter.LINE_SEPARATOR );
+ }
+
+ for( int i = 0; i < member_tags.length; i++ )
+ {
+ //all of our xdoclet-specific tags have a ":"
or "."
+ String member_tag_name = member_tags[i].name();
+
+ if( member_tag_name.lastIndexOf( ':' ) == -1
&& member_tag_name.lastIndexOf( '.' ) == -1 )
+ {
+ result.append( spaces ).append( " * " )
+ .append( member_tags[i].name()
).append( ' ' )
+ .append( member_tags[i].text()
);
+
+ //for all lines but not the last line
+ if( i < member_tags.length - 1 )
+ result.append(
PrettyPrintWriter.LINE_SEPARATOR );
+ }
+ }
+
+ result.append( spaces ).append( " */" );
+ }
+
+ return result.toString();
+ }
+ else
+ return "";
+ }
+
+ protected void forAllMembers( String template, Properties attributes, int
for_type ) throws XDocletException
+ {
+ boolean superclasses = TypeConversionUtil.stringToBoolean(
attributes.getProperty( "superclasses" ), true );
+ boolean sort = TypeConversionUtil.stringToBoolean(
attributes.getProperty( "sort" ), true );
+
+ ClassDoc cur_class = getCurrentClass();
+ HashSet already = new HashSet();
+
+ do
+ {
+ MemberDoc[] members = null;
+
+ switch ( for_type )
+ {
+ case FOR_FIELD:
+ members = cur_class.fields();
+ break;
+ case FOR_CONSTRUCTOR:
+ members = cur_class.constructors();
+ break;
+ case FOR_METHOD:
+ members = cur_class.methods();
+ break;
+ default:
+ throw new XDocletException( "Bad type: " + for_type );
+ }
+
+ if( sort == true )
+ {
+ //sort fields
+ Arrays.sort( members, memberComparator );
+ }
+
+ for( int j = 0; j < members.length; j++ )
+ {
+ // don't handle the member if it's a static
initialiser block "method"
+ // otherwisee (most cases), follow these rules:
+ // a) if superclasses == true -> handle it anyway
+ // b) if superclasses == false -> only handle it if
it's defined in the current class
+ if( ( superclasses || ( !superclasses &&
members[j].containingClass() == cur_class ) ) && !"<clinit>".equals( members[j].name()
) )
+ {
+ if( already.contains( members[j] ) == false )
+ {
+ switch ( for_type )
+ {
+ case FOR_FIELD:
+ setCurrentField( ( FieldDoc )
members[j] );
+ break;
+ case FOR_CONSTRUCTOR:
+ setCurrentConstructor( (
ConstructorDoc ) members[j] );
+ break;
+ case FOR_METHOD:
+ setCurrentMethod( ( MethodDoc
) members[j] );
+ break;
+ default:
+ throw new XDocletException(
"Bad type: " + for_type );
+ }
+
+ already.add( members[j] );
+ generate( template );
+ }
+ }
+ }
+
+ if( superclasses == true )
+ cur_class = cur_class.superclass();
+ else
+ break;
+ }while ( cur_class != null );
+ }
+
/**
* A utility method used by ifHasClassTag/ifDoesntHaveClassTag and
* ifHasMethodTag/ifDoesntHaveMethodTag, return true if at least one tag exists
@@ -317,6 +731,56 @@
// Avoid any trailing spaces
return pText.trim();
+ }
+
+ private boolean isInAppendExceptionsList( String append_exceptions, String
type )
+ {
+ if( append_exceptions == null )
+ return false;
+ else
+ return append_exceptions.indexOf( type ) != -1;
+ }
+
+ private boolean isInSkipExceptionsList( String skip_exceptions, String type )
+ {
+ if( skip_exceptions == null )
+ return false;
+ else
+ return skip_exceptions.indexOf( type ) != -1;
+ }
+
+ private void appendException( StringBuffer sb, String type )
+ {
+ if( sb.length() == 0 )
+ {
+ sb.append( "throws " ).append( type );
+ }
+ sb.append( ", " ).append( type );
+ }
+
+ private ExecutableMemberDoc extractExecutableMemberDoc( ClassDoc clazz, String
memberName, int for_type ) throws XDocletException
+ {
+ ExecutableMemberDoc[] executableMembers;
+
+ switch ( for_type )
+ {
+ case FOR_CONSTRUCTOR:
+ executableMembers = clazz.constructors();
+ break;
+ case FOR_METHOD:
+ executableMembers = clazz.methods();
+ break;
+ default:
+ throw new XDocletException( "Bad type: " + for_type );
+ }
+
+ for( int i = 0; i < executableMembers.length; i++ )
+ {
+ if( executableMembers[i].name().equals( memberName ) )
+ return executableMembers[i];
+ }
+
+ return null;
}
}
_______________________________________________
Xdoclet-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-devel