User: vharcq
Date: 02/04/17 13:32:20
Modified: core/src/xdoclet/tags AbstractProgramElementTagsHandler.java
MergeTagsHandler.java PackageTagsHandler.java
Log:
1. Merging shuld care of package substitution (Address-env-entries.xml should be
found i ejb/ and not in interfaces/)
2. Inheritance for ejb:env-entry now works
3. beautifier
Revision Changes Path
1.34 +612 -557
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.33
retrieving revision 1.34
diff -u -w -r1.33 -r1.34
--- AbstractProgramElementTagsHandler.java 16 Apr 2002 20:39:27 -0000 1.33
+++ AbstractProgramElementTagsHandler.java 17 Apr 2002 20:32:20 -0000 1.34
@@ -1,37 +1,6 @@
/*
- * Copyright (c) 2001, Aslak Helles�y, BEKK Consulting
+ * Copyright (c) 2001,2002 The XDoclet team
* 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;
@@ -67,9 +36,10 @@
/**
* @author Ara Abrahamian ([EMAIL PROTECTED])
* @created Oct 15, 2001
- * @version $Revision: 1.33 $
+ * @version $Revision: 1.34 $
*/
-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
@@ -94,21 +64,195 @@
* @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.
@@ -117,16 +261,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
@@ -136,11 +280,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.
*
@@ -149,23 +293,26 @@
* @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.
*
@@ -174,15 +321,16 @@
* @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
@@ -195,15 +343,16 @@
* @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.
@@ -214,22 +363,25 @@
* @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.
@@ -239,10 +391,12 @@
* @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];
}
@@ -253,7 +407,6 @@
return spaces;
}
-
/**
* Describe what the method does
*
@@ -267,7 +420,8 @@
* @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;
@@ -275,7 +429,8 @@
XExecutableMember executableMember = null;
- switch (for_type) {
+ switch ( for_type )
+ {
case FOR_CONSTRUCTOR:
executableMember = getCurrentConstructor();
member_name = attributes.getProperty("constructor");
@@ -288,18 +443,22 @@
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 "";
}
@@ -309,24 +468,26 @@
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
*
@@ -340,17 +501,20 @@
* @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);
}
@@ -358,21 +522,27 @@
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);
}
@@ -380,14 +550,17 @@
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);
}
@@ -399,7 +572,6 @@
matchPattern = null;
}
-
/**
* Describe what the method does
*
@@ -417,12 +589,14 @@
* @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;
@@ -436,25 +610,30 @@
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 (cat.isDebugEnabled()) {
- cat.debug("Tag = " + attributes.getProperty("tagName")
+ " Value = " + m + " MatchPattern = " + matchPattern);
+ if( cat.isDebugEnabled() )
+ {
+ cat.debug( "Tag/Param = " + attributes.getProperty(
"tagName" ) + "/" + attributes.getProperty( "paramName" ) + " Value = " + m + "
MatchPattern = " + matchPattern );
}
- if (matchPattern == null) {
+ 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);
}
}
@@ -462,25 +641,26 @@
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;
@@ -494,37 +674,44 @@
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);
}
}
@@ -535,12 +722,12 @@
return result.toString();
}
- else {
+ else
+ {
return "";
}
}
-
/**
* Describe what the method does
*
@@ -552,34 +739,37 @@
* @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;
@@ -593,19 +783,24 @@
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;
@@ -625,16 +820,17 @@
}
}
- 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.
@@ -642,14 +838,18 @@
* @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);
}
@@ -660,7 +860,6 @@
return pText.trim();
}
-
/**
* Gets the InAppendExceptionsList attribute of the
* AbstractProgramElementTagsHandler object
@@ -671,16 +870,18 @@
* @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
@@ -691,16 +892,18 @@
* @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
*
@@ -710,16 +913,18 @@
* @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
*
@@ -735,10 +940,12 @@
* @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;
@@ -749,167 +956,15 @@
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;
}
}
1.23 +3 -2 xdoclet/core/src/xdoclet/tags/MergeTagsHandler.java
Index: MergeTagsHandler.java
===================================================================
RCS file: /cvsroot/xdoclet/xdoclet/core/src/xdoclet/tags/MergeTagsHandler.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -w -r1.22 -r1.23
--- MergeTagsHandler.java 15 Apr 2002 06:59:03 -0000 1.22
+++ MergeTagsHandler.java 17 Apr 2002 20:32:20 -0000 1.23
@@ -30,7 +30,7 @@
/**
* @author Ara Abrahamian ([EMAIL PROTECTED])
* @created Oct 15, 2001
- * @version $Revision: 1.22 $
+ * @version $Revision: 1.23 $
*/
public class MergeTagsHandler extends XDocletTagSupport
{
@@ -134,8 +134,9 @@
}
else
{
+
String ejb_name = MessageFormat.format(
merge_file_pattern, new Object[]{AbstractProgramElementTagsHandler.getClassNameFor(
getCurrentClass() )} );
- String merge_file_name =
PackageTagsHandler.packageNameAsPathFor( getCurrentClass().containingPackage() ) +
File.separator + ejb_name;
+ String merge_file_name =
PackageTagsHandler.packageNameAsPathWithoutSubstitutionFor(
getCurrentClass().containingPackage() ) + File.separator + ejb_name;
if(
getDocletContext().getActiveSubTask().getMergeDir() != null )
{
1.14 +195 -165 xdoclet/core/src/xdoclet/tags/PackageTagsHandler.java
Index: PackageTagsHandler.java
===================================================================
RCS file: /cvsroot/xdoclet/xdoclet/core/src/xdoclet/tags/PackageTagsHandler.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -w -r1.13 -r1.14
--- PackageTagsHandler.java 4 Apr 2002 12:57:41 -0000 1.13
+++ PackageTagsHandler.java 17 Apr 2002 20:32:20 -0000 1.14
@@ -20,141 +20,57 @@
/**
* @author Ara Abrahamian ([EMAIL PROTECTED])
* @created Oct 14, 2001
- * @version $Revision: 1.13 $
+ * @version $Revision: 1.14 $
*/
-public class PackageTagsHandler extends AbstractProgramElementTagsHandler {
-
- /**
- * Returns the current package name. If we're in the context of a package
- * iteration, this is the name of the current package. If we're in the context
- * of a class iteration without a package iteration, return the name of the
- * current class' package.
- *
- * @return current package name
- * @exception XDocletException Description of Exception
- * @doc:tag type="content"
- */
- public String packageName() throws XDocletException {
- if (getCurrentPackage() != null) {
- // first try to get the name from current package. It exists if
- return getCurrentPackage().name();
- }
- else {
- return getCurrentClass().containingPackage().name();
- }
- }
-
-
- /**
- * Returns the not-full-qualified package name of the full-qualified class name
- * specified in the body of this tag.
- *
- * @param template The body of the block tag
- * @exception XDocletException Description of Exception
- * @doc:tag type="block"
- */
- public void packageOf(String template) throws XDocletException {
- try {
- String fullClassName = getEngine().outputOf(template);
-
- getEngine().print(getPackageNameFor(fullClassName.substring(0,
fullClassName.lastIndexOf('.'))));
- } catch (TemplateException ex) {
- throw new XDocletException(ex,
Translator.getString("method_failed", new String[]{"packageOf"}));
- }
- }
-
-
- /**
- * Iterates over all packages loaded by javadoc. Subsequent calls to
- * forAllClasses will only iterate over the classes in the current package.
- *
- * @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="abstract" optional="true" values="true,false"
- * description="If true then accept abstract classes also; otherwise
- * don't."
- * @doc:param name="type" optional="true" description="For all classes by the
- * type."
- * @doc:param name="extent" optional="true"
- * values="concrete-type,superclass,hierarchy" description="Specifies the
- * extent of the type search. If concrete-type then only check the
- * concrete type, if superclass then check also superclass, if hierarchy
- * then search the whole hierarchy and find if the class is of the
- * specified type. Default is hierarchy."
- */
- public void forAllPackages(String template, Properties attributes) throws
XDocletException {
- try {
- XClass[] classes = XJavaDoc.getInstance().sourceClasses();
- SortedSet packages = new TreeSet();
-
- for (int i = 0; i < classes.length; i++) {
- packages.add(classes[i].containingPackage());
- }
-
- XPackage cur_package = null;
-
- for (Iterator packageIterator = packages.iterator();
packageIterator.hasNext(); ) {
- cur_package = (XPackage)packageIterator.next();
- setCurrentPackage(cur_package);
- generate(template);
- }
- // restore current package to null, so subsequent class
iterations can
- // perform outside the context of a current package
- setCurrentPackage(null);
- } catch (XJavaDocException e) {
- throw new XDocletException(e, e.getMessage());
- }
- }
-
-
- /**
- * Returns the current package name as path
- *
- * @return current package name as path
- * @exception XDocletException Description of Exception
- * @doc:tag type="content"
- */
- public String packageNameAsPath() throws XDocletException {
- return packageNameAsPathFor(packageName());
- }
-
+public class PackageTagsHandler extends AbstractProgramElementTagsHandler
+{
/**
* Gets the PackageNameFor attribute of the PackageTagsHandler class
*
* @param pak Describe what the parameter does
+ * @param withSubstitution
* @return The PackageNameFor value
* @todo-javadoc Write javadocs for method parameter
*/
- public static String getPackageNameFor(XPackage pak) {
- return getPackageNameFor(pak.name());
+ public static String getPackageNameFor( XPackage pak, boolean withSubstitution
)
+ {
+ return getPackageNameFor( pak.name(), withSubstitution );
}
+ public static String getPackageNameFor( String packageName )
+ {
+ return getPackageNameFor( packageName, true );
+ }
/**
* It applies package substitutions.
*
* @param packageName
+ * @param withSubstitution
* @return The package name after substitutions.
*/
- public static String getPackageNameFor(String packageName) {
+ public static String getPackageNameFor( String packageName, boolean
withSubstitution )
+ {
ArrayList package_substitutions =
getPackageSubstitutions(DocletContext.getInstance().getActiveSubTask().getSubTaskName());
- if (package_substitutions == null) {
+ if( package_substitutions == null || !withSubstitution )
+ {
return packageName;
}
- for (int i = 0; i < package_substitutions.size(); i++) {
+ for( int i = 0; i < package_substitutions.size(); i++ )
+ {
PackageSubstitution ps =
(PackageSubstitution)package_substitutions.get(i);
StringTokenizer st = new StringTokenizer(ps.getPackages(),
",", false);
- while (st.hasMoreTokens()) {
+ while( st.hasMoreTokens() )
+ {
String packages = st.nextToken();
String suffix = "." + packages;
- if (packageName.endsWith(suffix)) {
+ if( packageName.endsWith( suffix ) )
+ {
packageName = packageName.substring(0,
packageName.length() - suffix.length()) + '.' + ps.getSubstituteWith();
break;
}
@@ -164,7 +80,6 @@
return packageName;
}
-
/**
* Gets the PackageSubstitutions attribute of the PackageTagsHandler class
*
@@ -172,28 +87,30 @@
* @return The PackageSubstitutions value
* @todo-javadoc Write javadocs for method parameter
*/
- public static ArrayList getPackageSubstitutions(String subtask_name) {
+ public static ArrayList getPackageSubstitutions( String subtask_name )
+ {
//SubTask's packageSubstitutions has precedence over the global
packageSubstitutions defined in DocletTask
ArrayList package_substitutions = null;
boolean supports_package_substitution_inheritance = true;
Boolean supports =
((Boolean)DocletContext.getInstance().getConfigParam(subtask_name +
".packageSubstitutionInheritanceSupported"));
- if (supports != null) {
+ if( supports != null )
+ {
supports_package_substitution_inheritance =
supports.booleanValue();
}
package_substitutions =
(ArrayList)DocletContext.getInstance().getConfigParam(subtask_name +
".packageSubstitutions");
//nothing specified for subtask, inherit the one from DocletTask
- if (supports_package_substitution_inheritance &&
(package_substitutions == null || package_substitutions.isEmpty())) {
+ if( supports_package_substitution_inheritance && (
package_substitutions == null || package_substitutions.isEmpty() ) )
+ {
package_substitutions =
(ArrayList)DocletContext.getInstance().getConfigParam("packageSubstitutions");
}
return package_substitutions;
}
-
/**
* Returns the current package name as path
*
@@ -201,10 +118,15 @@
* @return current package name as path
* @doc:tag type="content"
*/
- public static String packageNameAsPathFor(XPackage pak) {
- return getPackageNameFor(pak).replace('.', '/');
+ public static String packageNameAsPathFor( XPackage pak )
+ {
+ return getPackageNameFor( pak, true ).replace( '.', '/' );
}
+ public static String packageNameAsPathWithoutSubstitutionFor( XPackage pak )
+ {
+ return getPackageNameFor( pak, false ).replace( '.', '/' );
+ }
/**
* Returns the current package name as path
@@ -213,63 +135,171 @@
* @return current package name as path
* @doc:tag type="content"
*/
- public static String packageNameAsPathFor(String qualified_name) {
+ public static String packageNameAsPathFor( String qualified_name )
+ {
return qualified_name.replace('.', '/');
}
-
- /**
- * @author Aslak Helles�y
- * @created November 16, 2001
- */
- public static class PackageSubstitution implements Serializable {
/**
- * @todo-javadoc Describe the field
+ * Returns the current package name. If we're in the context of a package
+ * iteration, this is the name of the current package. If we're in the context
+ * of a class iteration without a package iteration, return the name of the
+ * current class' package.
+ *
+ * @return current package name
+ * @exception XDocletException Description of Exception
+ * @doc:tag type="content"
*/
- private String packages = null;
+ public String packageName() throws XDocletException
+ {
+ if( getCurrentPackage() != null )
+ {
+ // first try to get the name from current package. It exists if
+ return getCurrentPackage().name();
+ }
+ else
+ {
+ return getCurrentClass().containingPackage().name();
+ }
+ }
+
/**
- * @todo-javadoc Describe the field
+ * Returns the not-full-qualified package name of the full-qualified class name
+ * specified in the body of this tag.
+ *
+ * @param template The body of the block tag
+ * @exception XDocletException Description of Exception
+ * @doc:tag type="block"
*/
- private String substituteWith = null;
+ public void packageOf( String template ) throws XDocletException
+ {
+ try
+ {
+ String fullClassName = getEngine().outputOf( template );
+ getEngine().print( getPackageNameFor( fullClassName.substring(
0, fullClassName.lastIndexOf( '.' ) ), true ) );
+ }
+ catch( TemplateException ex )
+ {
+ throw new XDocletException( ex, Translator.getString(
"method_failed", new String[]{"packageOf"} ) );
+ }
+ }
/**
- * Sets the Packages attribute of the PackageSubstitution object
+ * Iterates over all packages loaded by javadoc. Subsequent calls to
+ * forAllClasses will only iterate over the classes in the current package.
*
- * @param packages The new Packages value
+ * @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="abstract" optional="true"
+ * values="true,false" description="If true then accept abstract classes
+ * also; otherwise don't."
+ * @doc:param name="type" optional="true" description="For
+ * all classes by the type."
+ * @doc:param name="extent" optional="true"
+ * values="concrete-type,superclass,hierarchy" description="Specifies the
+ * extent of the type search. If concrete-type then only check the
+ * concrete type, if superclass then check also superclass, if hierarchy
+ * then search the whole hierarchy and find if the class is of the
+ * specified type. Default is hierarchy."
*/
- public void setPackages(String packages) {
- this.packages = packages;
+ public void forAllPackages( String template, Properties attributes ) throws
XDocletException
+ {
+ try
+ {
+ XClass[] classes = XJavaDoc.getInstance().sourceClasses();
+ SortedSet packages = new TreeSet();
+
+ for( int i = 0; i < classes.length; i++ )
+ {
+ packages.add( classes[i].containingPackage() );
}
+ XPackage cur_package = null;
+
+ for( Iterator packageIterator = packages.iterator();
packageIterator.hasNext(); )
+ {
+ cur_package = ( XPackage ) packageIterator.next();
+ setCurrentPackage( cur_package );
+ generate( template );
+ }
+ // restore current package to null, so subsequent class
iterations can
+ // perform outside the context of a current package
+ setCurrentPackage( null );
+ }
+ catch( XJavaDocException e )
+ {
+ throw new XDocletException( e, e.getMessage() );
+ }
+ }
/**
- * Sets the SubstituteWith attribute of the PackageSubstitution object
+ * Returns the current package name as path
*
- * @param substituteWith The new SubstituteWith value
+ * @return current package name as path
+ * @exception XDocletException Description of Exception
+ * @doc:tag type="content"
*/
- public void setSubstituteWith(String substituteWith) {
- this.substituteWith = substituteWith;
+ public String packageNameAsPath() throws XDocletException
+ {
+ return packageNameAsPathFor( packageName() );
}
+ /**
+ * @author Aslak Helles�y
+ * @created November 16, 2001
+ */
+ public static class PackageSubstitution implements Serializable
+ {
+ /**
+ * @todo-javadoc Describe the field
+ */
+ private String packages = null;
+ /**
+ * @todo-javadoc Describe the field
+ */
+ private String substituteWith = null;
/**
* Gets the Packages attribute of the PackageSubstitution object
*
* @return The Packages value
*/
- public String getPackages() {
+ public String getPackages()
+ {
return packages;
}
-
/**
* Gets the SubstituteWith attribute of the PackageSubstitution object
*
* @return The SubstituteWith value
*/
- public String getSubstituteWith() {
+ public String getSubstituteWith()
+ {
return substituteWith;
}
+
+ /**
+ * Sets the Packages attribute of the PackageSubstitution object
+ *
+ * @param packages The new Packages value
+ */
+ public void setPackages( String packages )
+ {
+ this.packages = packages;
+ }
+
+ /**
+ * Sets the SubstituteWith attribute of the PackageSubstitution object
+ *
+ * @param substituteWith The new SubstituteWith value
+ */
+ public void setSubstituteWith( String substituteWith )
+ {
+ this.substituteWith = substituteWith;
+ }
}
}
\ No newline at end of file
_______________________________________________
Xdoclet-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-devel