User: vharcq
Date: 02/04/16 13:39:27
Modified: core/src/xdoclet/tags AbstractProgramElementTagsHandler.java
Log:
beautifier
Revision Changes Path
1.33 +560 -607
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.32
retrieving revision 1.33
diff -u -w -r1.32 -r1.33
--- AbstractProgramElementTagsHandler.java 12 Apr 2002 22:32:45 -0000 1.32
+++ AbstractProgramElementTagsHandler.java 16 Apr 2002 20:39:27 -0000 1.33
@@ -1,6 +1,37 @@
/*
- * Copyright (c) 2001,2002 The XDoclet team
+ * Copyright (c) 2001, Aslak Helles�y, BEKK Consulting
* All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * - Neither the name of BEKK Consulting nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ */
+
+/*
+ * Change log
+ *
*/
package xdoclet.tags;
@@ -36,10 +67,9 @@
/**
* @author Ara Abrahamian ([EMAIL PROTECTED])
* @created Oct 15, 2001
- * @version $Revision: 1.32 $
+ * @version $Revision: 1.33 $
*/
-public abstract class AbstractProgramElementTagsHandler extends XDocletTagSupport
-{
+public abstract class AbstractProgramElementTagsHandler extends XDocletTagSupport {
/**
* The current token. Currently forAllParameterTypes and forAllClassTagTokens
* set it and currentToken returns the value. Tokens are computed for cases
@@ -64,195 +94,21 @@
* @todo-javadoc Describe the field
*/
private final static Comparator memberComparator =
- new Comparator()
- {
- public int compare( Object o1, Object o2 )
- {
+ new Comparator() {
+ public int compare(Object o1, Object o2) {
XMember m1 = ( XMember ) o1;
XMember m2 = ( XMember ) o2;
return m1.name().compareTo( m2.name() );
}
- public boolean equals( Object obj )
- {
+
+ public boolean equals(Object obj) {
//dumb
return obj == this;
}
};
- /**
- * Returns the not-full-qualified name of the current class without the package
- * name.
- *
- * @param clazz Description of Parameter
- * @return Description of the Returned Value
- * @doc:tag type="content"
- */
- public static String getClassNameFor( XClass clazz )
- {
- return clazz.name();
- }
-
- /**
- * Returns the full-qualified name of the current class with the package name.
- *
- * @param clazz Description of Parameter
- * @return Description of the Returned Value
- * @doc:tag type="content"
- */
- public static String getFullClassNameFor( XClass clazz )
- {
- return clazz.qualifiedName();
- }
-
- /**
- * Returns the full-qualified name of the superclass of the current class.
- *
- * @param clazz Description of Parameter
- * @return Description of the Returned Value
- * @doc:tag type="content"
- */
- public static String getFullSuperclassNameFor( XClass clazz )
- {
- if( clazz.superclass() != null )
- {
- return clazz.superclass().qualifiedName();
- }
- else
- {
- return "java.lang.Object";
- }
- }
-
- /**
- * Utility method to get classes for iteration used by various methods. The
- * result depends on the context: are we within a forAllPackages iteration or
- * not.
- *
- * @return An array with all classes in that context in
- * it.
- * @exception XDocletException Describe the exception
- * @todo-javadoc Write javadocs for exception
- */
- public static XClass[] getAllClasses() throws XDocletException
- {
- try
- {
- if(
DocletContext.getInstance().getActiveSubTask().getCurrentPackage() == null )
- {
- // not in a forAllPackages context
- return XJavaDoc.getInstance().sourceClasses();
- }
- else
- {
- return
DocletContext.getInstance().getActiveSubTask().getCurrentPackage().classes();
- }
- }
- catch( XJavaDocException e )
- {
- throw new XDocletException( e, e.getMessage() );
- }
- }
-
- /**
- * Describe what the method does
- *
- * @param clazz Describe what the parameter does
- * @param executableMemberName Describe what the parameter does
- * @param parameters Describe what the parameter does
- * @param setCurrentExecutableMember Describe what the parameter does
- * @param for_type Describe what the parameter does
- * @return Describe the return value
- * @exception XDocletException Describe the exception
- * @todo-javadoc Write javadocs for method
- * @todo-javadoc Write javadocs for method parameter
- * @todo-javadoc Write javadocs for method parameter
- * @todo-javadoc Write javadocs for method parameter
- * @todo-javadoc Write javadocs for method parameter
- * @todo-javadoc Write javadocs for method parameter
- * @todo-javadoc Write javadocs for return value
- * @todo-javadoc Write javadocs for exception
- */
- protected static boolean hasExecutableMember( XClass clazz, String
executableMemberName, String[] parameters, boolean setCurrentExecutableMember, int
for_type )
- throws XDocletException
- {
- Category cat = Log.getCategory(
AbstractProgramElementTagsHandler.class, "hasExecutableMember" );
-
- while( clazz != null )
- {
- XExecutableMember[] 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"
- if( parameters != null )
- {
- XParameter[] params =
executableMembers[i].parameters();
-
- if( cat.isDebugEnabled() )
- {
- cat.debug( "params.length=" +
params.length );
- }
-
- for( int j = 0; j < params.length; j++
)
- {
- if( cat.isDebugEnabled() )
- {
- cat.debug(
"params[j].type().qualifiedName()=" + params[j].type().qualifiedName() );
- cat.debug(
"parameters[j]=" + parameters[j] );
- }
-
- StringBuffer sb = new
StringBuffer();
-
- sb.append(
params[j].type().qualifiedName() ).append( params[j].dimensionAsString() );
- if( parameters == null ||
!sb.toString().equals( parameters[j] ) )
- {
- continue loop;
- }
- }
- }
-
- // The class has the given executable member
- if( setCurrentExecutableMember )
- {
- switch ( for_type )
- {
- case FOR_CONSTRUCTOR:
- setCurrentConstructor( (
XConstructor ) executableMembers[i] );
- break;
- case FOR_METHOD:
- setCurrentMethod( ( XMethod )
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.
@@ -261,16 +117,16 @@
* @param attributes The attributes of the template tag
* @exception XDocletException Description of Exception
* @doc:tag type="content"
- * @doc:param name="value" optional="false" description="The
- * new value for matchPattern."
+ * @doc:param name="value" optional="false" description="The new value for
+ * matchPattern."
*/
- public void setMatchValue( String template, Properties attributes ) throws
XDocletException
- {
+ public void setMatchValue(String template, Properties attributes) throws
XDocletException {
matchPattern = attributes.getProperty( "value" );
generate( template );
matchPattern = null;
}
+
/**
* Returns the value of match variable. Match variable serves as a variable for
* templates, you set it somewhere in template and look it up somewhere else in
@@ -280,11 +136,11 @@
* @exception XDocletException Description of Exception
* @doc:tag type="content"
*/
- public String matchValue() throws XDocletException
- {
+ public String matchValue() throws XDocletException {
return matchPattern;
}
+
/**
* Returns current token inside forAllClassTagTokens.
*
@@ -293,26 +149,23 @@
* @exception XDocletException Description of Exception
* @doc:tag type="content"
*/
- public String currentToken( Properties attributes ) throws XDocletException
- {
+ public String currentToken(Properties attributes) throws XDocletException {
Category cat = Log.getCategory( SubTask.class, "currentToken" );
- if( cat.isDebugEnabled() )
- {
+ if (cat.isDebugEnabled()) {
cat.debug( "current token: " + currentToken );
}
- if( currentToken == null )
- {
+ if (currentToken == null) {
cat.error( "null token found" );
return "";
}
- else
- {
+ else {
return currentToken;
}
}
+
/**
* Skips current token. Returns empty string.
*
@@ -321,16 +174,15 @@
* @exception XDocletException Description of Exception
* @doc:tag type="content"
*/
- public String skipToken( Properties attributes ) throws XDocletException
- {
- if( tagTokenizer.hasMoreTokens() )
- {
+ public String skipToken(Properties attributes) throws XDocletException {
+ if (tagTokenizer.hasMoreTokens()) {
tagTokenizer.nextToken();
}
return "";
}
+
/**
* Gets the XExecutableMemberForMemberName attribute of the
* AbstractProgramElementTagsHandler object
@@ -343,16 +195,15 @@
* @todo-javadoc Write javadocs for method parameter
* @todo-javadoc Write javadocs for exception
*/
- protected XExecutableMember getXExecutableMemberForMemberName( String
memberName, int for_type ) throws XDocletException
- {
- if( memberName != null )
- {
+ protected XExecutableMember getXExecutableMemberForMemberName(String
memberName, int for_type) throws XDocletException {
+ if (memberName != null) {
return extractXExecutableMember( getCurrentClass(),
memberName, for_type );
}
return null;
}
+
/**
* Searches for the XExecutableMember of the member with name methodName and
* returns it.
@@ -363,25 +214,22 @@
* @return The XMethod for the method named value
* @exception XDocletException
*/
- protected XExecutableMember getXExecutableMemberForMemberName( String
memberName, boolean superclasses, int for_type ) throws XDocletException
- {
- if( !superclasses )
- {
+ protected XExecutableMember getXExecutableMemberForMemberName(String
memberName, boolean superclasses, int for_type) throws XDocletException {
+ if (!superclasses) {
return getXExecutableMemberForMemberName( memberName, for_type
);
}
- for( XClass clazz = getCurrentClass(); clazz != null; clazz =
clazz.superclass() )
- {
+ for (XClass clazz = getCurrentClass(); clazz != null; clazz =
clazz.superclass()) {
XExecutableMember member = extractXExecutableMember( clazz,
memberName, for_type );
- if( member != null )
- {
+ if (member != null) {
return member;
}
}
return null;
}
+
/**
* A utility method to get the blank space characters used for indenting
* comments.
@@ -391,12 +239,10 @@
* @see MethodTagsHandler#methodComment(java.util.Properties)
* @see ClassTagsHandler#classComment(java.util.Properties)
*/
- protected char[] getIndentChars( Properties attributes )
- {
+ protected char[] getIndentChars(Properties attributes) {
String indent_str = attributes.getProperty( "indent" );
- if( indent_str == null )
- {
+ if (indent_str == null) {
return new char[0];
}
@@ -407,6 +253,7 @@
return spaces;
}
+
/**
* Describe what the method does
*
@@ -420,8 +267,7 @@
* @todo-javadoc Write javadocs for return value
* @todo-javadoc Write javadocs for exception
*/
- protected String exceptionList( Properties attributes, int for_type ) throws
XDocletException
- {
+ 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;
@@ -429,8 +275,7 @@
XExecutableMember executableMember = null;
- switch ( for_type )
- {
+ switch (for_type) {
case FOR_CONSTRUCTOR:
executableMember = getCurrentConstructor();
member_name = attributes.getProperty( "constructor" );
@@ -443,22 +288,18 @@
throw new XDocletException( "Can't forAll for type " +
for_type );
}
- if( executableMember == null && member_name == null )
- {
+ if (executableMember == null && member_name == null) {
return "";
}
- if( member_name == null )
- {
+ if (member_name == null) {
exceptions = executableMember.thrownExceptions();
}
- else
- {
+ else {
executableMember = getXExecutableMemberForMemberName(
member_name, true, for_type );
//no member with the specified name found in class
- if( executableMember == null )
- {
+ if (executableMember == null) {
return "";
}
@@ -468,26 +309,24 @@
StringBuffer st = new StringBuffer();
String type = null;
- for( int i = 0; i < exceptions.length; i++ )
- {
+ for (int i = 0; i < exceptions.length; i++) {
type = exceptions[i].toString();
if( isInSkipExceptionsList( skip_exceptions, type ) == false &&
- isInAppendExceptionsList( append_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 )
- {
+ if (append_exceptions != null) {
appendException( st, append_exceptions );
}
return st.toString();
}
+
/**
* Describe what the method does
*
@@ -501,20 +340,17 @@
* @todo-javadoc Write javadocs for method parameter
* @todo-javadoc Write javadocs for exception
*/
- protected void forAllMemberTagTokens( String template, Properties attributes,
int for_type ) throws XDocletException
- {
+ protected void forAllMemberTagTokens(String template, Properties attributes,
int for_type) throws XDocletException {
Category cat = Log.getCategory( MethodTagsHandler.class,
"forAllMemberTagTokens" );
String tagValue;
- if( getCurrentTag() != null )
- {
+ if (getCurrentTag() != null) {
String paramName = attributes.getProperty( "paramName" );
tagValue = getCurrentTag().attributeValue( paramName );
}
- else
- {
+ else {
tagValue = getTagValue( attributes, for_type );
}
@@ -522,43 +358,36 @@
String skip_str = attributes.getProperty( "skip" );
int skip;
- try
- {
+ try {
skip = Integer.valueOf( skip_str ).intValue();
- }
- catch( Throwable t )
- {
+ } catch (Throwable t) {
skip = 0;
}
- if( delimiter == null )
- {
- if( cat.isDebugEnabled() )
- {
+ if (delimiter == null) {
+ if (cat.isDebugEnabled()) {
cat.debug( "got null delimiter -
forAllMemberTagTokens" );
}
delimiter = PARAMETER_DELIMITER;
}
- if( cat.isDebugEnabled() )
+ if (cat.isDebugEnabled()) {
cat.debug( "Tag Value = " + tagValue );
+ }
tagTokenizer = new StringTokenizer( tagValue, delimiter, false );
currentToken = "";
matchPattern = null;
- for( int i = 0; tagTokenizer.hasMoreTokens() && i < skip; i++ )
- {
+ for (int i = 0; tagTokenizer.hasMoreTokens() && i < skip; i++) {
tagTokenizer.nextToken();
}
- while( tagTokenizer.hasMoreTokens() )
- {
+ while (tagTokenizer.hasMoreTokens()) {
currentToken = tagTokenizer.nextToken();
- if( cat.isDebugEnabled() )
- {
+ if (cat.isDebugEnabled()) {
cat.debug( "generate current token: " + currentToken );
}
@@ -570,6 +399,7 @@
matchPattern = null;
}
+
/**
* Describe what the method does
*
@@ -587,13 +417,12 @@
* @todo-javadoc Write javadocs for method parameter
* @todo-javadoc Write javadocs for exception
*/
- protected void forAllMemberTags( String template, Properties attributes, int
for_type, String resourceKey, String[] arguments ) throws XDocletException
- {
+ protected void forAllMemberTags(String template, Properties attributes, int
for_type, String resourceKey, String[] arguments) throws XDocletException {
+ Category cat =
Log.getCategory(AbstractProgramElementTagsHandler.class, "forAllMethodTags");
boolean superclasses = TypeConversionUtil.stringToBoolean(
attributes.getProperty( "superclasses" ), true );
XMember member = null;
- switch ( for_type )
- {
+ switch (for_type) {
case FOR_FIELD:
member = getCurrentField();
break;
@@ -607,25 +436,25 @@
throw new XDocletException( "Bad type " + for_type );
}
- if( member == null )
- {
+ if (member == null) {
throw new XDocletException( Translator.getString( resourceKey,
arguments ) );
}
XTag[] tags = member.doc().tags( attributes.getProperty( "tagName" ),
superclasses );
- for( int i = 0; i < tags.length; i++ )
- {
+ for (int i = 0; i < tags.length; i++) {
setCurrentTag( tags[i] );
String m = getTagValue( attributes, for_type );
- if( matchPattern == null )
- {
+ if (cat.isDebugEnabled()) {
+ cat.debug("Tag = " + attributes.getProperty("tagName")
+ " Value = " + m + " MatchPattern = " + matchPattern);
+ }
+
+ if (matchPattern == null) {
generate( template );
}
- else if( matchPattern != null && ( matchPattern.equals( m ) ||
m.equals( "*" ) ) )
- {
+ else if (matchPattern != null && (matchPattern.equals(m) ||
m.equals("*"))) {
generate( template );
}
}
@@ -633,26 +462,25 @@
setCurrentTag( null );
}
+
/**
+ * @todo make static and move to DocletUtil. This is a utility method, since no
+ * class members are accessed
* @param attributes Describe what the parameter does
* @param for_type Describe what the parameter does
* @return Describe the return value
* @exception XDocletException Describe the exception
- * @todo make static and move to DocletUtil. This is a
- * utility method, since no class members are accessed
* @todo-javadoc Write javadocs for method parameter
* @todo-javadoc Write javadocs for method parameter
* @todo-javadoc Write javadocs for return value
* @todo-javadoc Write javadocs for exception
*/
- protected String memberComment( Properties attributes, int for_type ) throws
XDocletException
- {
+ protected String memberComment(Properties attributes, int for_type) throws
XDocletException {
String no_comment_signs = attributes.getProperty( "no-comment-signs" );
XMember member = null;
- switch ( for_type )
- {
+ switch (for_type) {
case FOR_FIELD:
member = getCurrentField();
break;
@@ -666,44 +494,37 @@
throw new XDocletException( "Bad type " + for_type );
}
- if( no_comment_signs != null && no_comment_signs.equalsIgnoreCase(
"true" ) )
- {
+ if (no_comment_signs != null &&
no_comment_signs.equalsIgnoreCase("true")) {
return member.doc().commentText();
}
char[] spaces = getIndentChars( attributes );
XTag[] member_tags = member.doc().tags();
- if( member_tags.length > 0 )
- {
+ if (member_tags.length > 0) {
StringBuffer result = new StringBuffer();
//add user comments
StringTokenizer st = new StringTokenizer(
member.doc().commentText().trim(), "\n", false );
- if( st.countTokens() > 0 )
- {
+ if (st.countTokens() > 0) {
result.append( spaces ).append( "/**" ).append(
PrettyPrintWriter.LINE_SEPARATOR );
- while( st.hasMoreTokens() )
- {
+ while (st.hasMoreTokens()) {
result.append( spaces ).append( " * "
).append( st.nextToken().trim() ).append( PrettyPrintWriter.LINE_SEPARATOR );
}
- for( int i = 0; i < member_tags.length; i++ )
- {
+ 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.indexOf( ':' ) == -1 &&
member_tag_name.indexOf( '.' ) == -1
- &&
getDocletContext().getExcludedTags().indexOf( member_tag_name ) == -1 )
- {
+ &&
getDocletContext().getExcludedTags().indexOf(member_tag_name) == -1) {
result.append( spaces ).append( " * " )
.append( member_tags[i].name()
).append( ' ' )
.append(
member_tags[i].value() );
//for all lines but not the last line
- if( i < member_tags.length - 1 )
- {
+ if (i < member_tags.length - 1) {
result.append(
PrettyPrintWriter.LINE_SEPARATOR );
}
}
@@ -714,12 +535,12 @@
return result.toString();
}
- else
- {
+ else {
return "";
}
}
+
/**
* Describe what the method does
*
@@ -731,37 +552,34 @@
* @todo-javadoc Write javadocs for return value
* @todo-javadoc Write javadocs for exception
*/
- protected String firstSentenceDescriptionOfCurrentMember( XMember member )
throws XDocletException
- {
+ protected String firstSentenceDescriptionOfCurrentMember(XMember member)
throws XDocletException {
return member.doc().firstSentence() != null ?
member.doc().firstSentence() : "";
}
+
/**
+ * @todo the already Set contains XMember objects. equals/hashCode should be
+ * defined in XMember and be implemented in all of the implementing
+ * classes.
* @param template Describe what the parameter does
* @param attributes Describe what the parameter does
* @param for_type Describe what the parameter does
* @exception XDocletException Describe the exception
- * @todo the already Set contains XMember objects.
- * equals/hashCode should be defined in XMember and be implemented in all
- * of the implementing classes.
* @todo-javadoc Write javadocs for method parameter
* @todo-javadoc Write javadocs for method parameter
* @todo-javadoc Write javadocs for method parameter
* @todo-javadoc Write javadocs for exception
*/
- protected void forAllMembers( String template, Properties attributes, int
for_type ) throws XDocletException
- {
+ 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 );
XClass cur_class = getCurrentClass();
HashSet already = new HashSet();
- do
- {
+ do {
XMember[] members = null;
- switch ( for_type )
- {
+ switch (for_type) {
case FOR_FIELD:
members = cur_class.fields();
break;
@@ -775,24 +593,19 @@
throw new XDocletException( "Bad type: " + for_type );
}
- if( sort == true )
- {
+ if (sort == true) {
//sort fields
Arrays.sort( members, memberComparator );
}
- for( int j = 0; j < members.length; j++ )
- {
+ 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().equals( cur_class ) ) ) && !"<clinit>".equals(
members[j].name() ) )
- {
- if( already.contains( members[j] ) == false )
- {
- switch ( for_type )
- {
+ if ((superclasses || (!superclasses &&
members[j].containingClass().equals(cur_class))) &&
!"<clinit>".equals(members[j].name())) {
+ if (already.contains(members[j]) == false) {
+ switch (for_type) {
case FOR_FIELD:
setCurrentField( ( XField )
members[j] );
break;
@@ -812,17 +625,16 @@
}
}
- if( superclasses == true )
- {
+ if (superclasses == true) {
cur_class = cur_class.superclass();
}
- else
- {
+ else {
break;
}
}while ( cur_class != null );
}
+
/**
* A utility method used by firstSentenceDescription to replace end of line by
* space.
@@ -830,18 +642,14 @@
* @param pText Description of Parameter
* @return Description of the Returned Value
*/
- protected String checkForWrap( String pText )
- {
+ protected String checkForWrap(String pText) {
int lIndex = pText.indexOf( PrettyPrintWriter.LINE_SEPARATOR );
- while( lIndex >= 0 )
- {
- if( lIndex < pText.length() - 1 )
- {
+ while (lIndex >= 0) {
+ if (lIndex < pText.length() - 1) {
pText = new StringBuffer( pText.substring( 0, lIndex
).trim() ).append( ' ' ).append( pText.substring( lIndex + 1 ).trim() ).toString();
}
- else
- {
+ else {
pText = pText.substring( 0, lIndex );
}
@@ -852,6 +660,7 @@
return pText.trim();
}
+
/**
* Gets the InAppendExceptionsList attribute of the
* AbstractProgramElementTagsHandler object
@@ -862,18 +671,16 @@
* @todo-javadoc Write javadocs for method parameter
* @todo-javadoc Write javadocs for method parameter
*/
- private boolean isInAppendExceptionsList( String append_exceptions, String
type )
- {
- if( append_exceptions == null )
- {
+ private boolean isInAppendExceptionsList(String append_exceptions, String
type) {
+ if (append_exceptions == null) {
return false;
}
- else
- {
+ else {
return append_exceptions.indexOf( type ) != -1;
}
}
+
/**
* Gets the InSkipExceptionsList attribute of the
* AbstractProgramElementTagsHandler object
@@ -884,18 +691,16 @@
* @todo-javadoc Write javadocs for method parameter
* @todo-javadoc Write javadocs for method parameter
*/
- private boolean isInSkipExceptionsList( String skip_exceptions, String type )
- {
- if( skip_exceptions == null )
- {
+ private boolean isInSkipExceptionsList(String skip_exceptions, String type) {
+ if (skip_exceptions == null) {
return false;
}
- else
- {
+ else {
return skip_exceptions.indexOf( type ) != -1;
}
}
+
/**
* Describe what the method does
*
@@ -905,18 +710,16 @@
* @todo-javadoc Write javadocs for method parameter
* @todo-javadoc Write javadocs for method parameter
*/
- private void appendException( StringBuffer sb, String type )
- {
- if( sb.length() == 0 )
- {
+ private void appendException(StringBuffer sb, String type) {
+ if (sb.length() == 0) {
sb.append( "throws " ).append( type );
}
- else
- {
+ else {
sb.append( ", " ).append( type );
}
}
+
/**
* Describe what the method does
*
@@ -932,12 +735,10 @@
* @todo-javadoc Write javadocs for return value
* @todo-javadoc Write javadocs for exception
*/
- private XExecutableMember extractXExecutableMember( XClass clazz, String
memberName, int for_type ) throws XDocletException
- {
+ private XExecutableMember extractXExecutableMember(XClass clazz, String
memberName, int for_type) throws XDocletException {
XExecutableMember[] executableMembers;
- switch ( for_type )
- {
+ switch (for_type) {
case FOR_CONSTRUCTOR:
executableMembers = clazz.constructors();
break;
@@ -948,15 +749,167 @@
throw new XDocletException( "Bad type: " + for_type );
}
- for( int i = 0; i < executableMembers.length; i++ )
- {
- if( executableMembers[i].name().equals( memberName ) )
- {
+ for (int i = 0; i < executableMembers.length; i++) {
+ if (executableMembers[i].name().equals(memberName)) {
return executableMembers[i];
}
}
return null;
+ }
+
+
+ /**
+ * Returns the not-full-qualified name of the current class without the package
+ * name.
+ *
+ * @param clazz Description of Parameter
+ * @return Description of the Returned Value
+ * @doc:tag type="content"
+ */
+ public static String getClassNameFor(XClass clazz) {
+ return clazz.name();
+ }
+
+
+ /**
+ * Returns the full-qualified name of the current class with the package name.
+ *
+ * @param clazz Description of Parameter
+ * @return Description of the Returned Value
+ * @doc:tag type="content"
+ */
+ public static String getFullClassNameFor(XClass clazz) {
+ return clazz.qualifiedName();
+ }
+
+
+ /**
+ * Returns the full-qualified name of the superclass of the current class.
+ *
+ * @param clazz Description of Parameter
+ * @return Description of the Returned Value
+ * @doc:tag type="content"
+ */
+ public static String getFullSuperclassNameFor(XClass clazz) {
+ if (clazz.superclass() != null) {
+ return clazz.superclass().qualifiedName();
+ }
+ else {
+ return "java.lang.Object";
+ }
+ }
+
+
+ /**
+ * Utility method to get classes for iteration used by various methods. The
+ * result depends on the context: are we within a forAllPackages iteration or
+ * not.
+ *
+ * @return An array with all classes in that context in it.
+ * @exception XDocletException Describe the exception
+ * @todo-javadoc Write javadocs for exception
+ */
+ public static XClass[] getAllClasses() throws XDocletException {
+ try {
+ if
(DocletContext.getInstance().getActiveSubTask().getCurrentPackage() == null) {
+ // not in a forAllPackages context
+ return XJavaDoc.getInstance().sourceClasses();
+ }
+ else {
+ return
DocletContext.getInstance().getActiveSubTask().getCurrentPackage().classes();
+ }
+ } catch (XJavaDocException e) {
+ throw new XDocletException(e, e.getMessage());
+ }
+ }
+
+
+ /**
+ * Describe what the method does
+ *
+ * @param clazz Describe what the parameter does
+ * @param executableMemberName Describe what the parameter does
+ * @param parameters Describe what the parameter does
+ * @param setCurrentExecutableMember Describe what the parameter does
+ * @param for_type Describe what the parameter does
+ * @return Describe the return value
+ * @exception XDocletException Describe the exception
+ * @todo-javadoc Write javadocs for method
+ * @todo-javadoc Write javadocs for method parameter
+ * @todo-javadoc Write javadocs for method parameter
+ * @todo-javadoc Write javadocs for method parameter
+ * @todo-javadoc Write javadocs for method parameter
+ * @todo-javadoc Write javadocs for method parameter
+ * @todo-javadoc Write javadocs for return value
+ * @todo-javadoc Write javadocs for exception
+ */
+ protected static boolean hasExecutableMember(XClass clazz, String
executableMemberName, String[] parameters, boolean setCurrentExecutableMember, int
for_type)
+ throws XDocletException {
+ Category cat =
Log.getCategory(AbstractProgramElementTagsHandler.class, "hasExecutableMember");
+
+ while (clazz != null) {
+ XExecutableMember[] 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"
+ if (parameters != null) {
+ XParameter[] params =
executableMembers[i].parameters();
+
+ if (cat.isDebugEnabled()) {
+ cat.debug("params.length=" +
params.length);
+ }
+
+ for (int j = 0; j < params.length;
j++) {
+ if (cat.isDebugEnabled()) {
+
cat.debug("params[j].type().qualifiedName()=" + params[j].type().qualifiedName());
+
cat.debug("parameters[j]=" + parameters[j]);
+ }
+
+ StringBuffer sb = new
StringBuffer();
+
+
sb.append(params[j].type().qualifiedName()).append(params[j].dimensionAsString());
+ if (parameters == null ||
!sb.toString().equals(parameters[j])) {
+ continue loop;
+ }
+ }
+ }
+
+ // The class has the given executable member
+ if (setCurrentExecutableMember) {
+ switch (for_type) {
+ case FOR_CONSTRUCTOR:
+
setCurrentConstructor((XConstructor)executableMembers[i]);
+ break;
+ case FOR_METHOD:
+
setCurrentMethod((XMethod)executableMembers[i]);
+ break;
+ default:
+ throw new
XDocletException("Bad type: " + for_type);
+ }
+ }
+ return true;
+ }
+ }
+
+ // Check super class info
+ clazz = clazz.superclass();
+ }
+
+ return false;
}
}
_______________________________________________
Xdoclet-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-devel