User: vharcq
Date: 02/04/17 16:02:29
Modified: core/src/xdoclet DocletSupport.java XDocletTagSupport.java
Log:
Important patch!
I split currentTag in one for class tag and one for method tag
I check if it is set in getTagValue (the biggest method around)
This is to solve in once problems like having
@ejb:permission role-name="a,b" on class and/or method
or having
* @ejb.finder
* signature="Collection findByCode(String code)"
* query="SELECT OBJECT(p) FROM LANGUAGE as p WHERE p.id = ?1"
* @ejb.finder
* signature "Collection findByCode(java.lang.String a, java.lang.String b)"
* query="SELECT OBJECT(p) FROM LANGUAGE as p WHERE p.id = ?1 AND p.id = ?2"
Plus all tags that merge forAllClass and forAllMethod
Plus all tags that have in a forAllMethod on a tag/param a lookup on another
(tag)/(param)
It passes samples and unit tests
Revision Changes Path
1.10 +136 -123 xdoclet/core/src/xdoclet/DocletSupport.java
Index: DocletSupport.java
===================================================================
RCS file: /cvsroot/xdoclet/xdoclet/core/src/xdoclet/DocletSupport.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -w -r1.9 -r1.10
--- DocletSupport.java 4 Apr 2002 01:03:07 -0000 1.9
+++ DocletSupport.java 17 Apr 2002 23:02:29 -0000 1.10
@@ -18,9 +18,19 @@
/**
* @author Ara Abrahamian ([EMAIL PROTECTED])
* @created Oct 13, 2001
- * @version $Revision: 1.9 $
+ * @version $Revision: 1.10 $
*/
-public abstract class DocletSupport {
+public abstract class DocletSupport
+{
+ /**
+ * The current Tag. Various template tag implementations set this value,
+ * including looping tags such as forAllClassTags. There's no distinction
+ * between class/method/field/constructor/whatever tags, and currentTag can
+ * point to any one them.
+ */
+ protected static XTag currentMethodTag;
+
+ protected static XTag currentClassTag;
/**
* The current class stack is used for pushing/poping classes to/from it, so
@@ -75,198 +85,201 @@
* @see #setCurrentPackage(xjavadoc.XPackage)
*/
private transient XPackage currentPackage = null;
- /**
- * The current Tag. Various template tag implementations set this value,
- * including looping tags such as forAllClassTags. There's no distinction
- * between class/method/field/constructor/whatever tags, and currentTag can
- * point to any one them.
- */
- protected static XTag currentTag;
-
/**
* Describe what the DocletSupport constructor does
*
* @todo-javadoc Write javadocs for constructor
*/
- public DocletSupport() {
+ public DocletSupport()
+ {
currentClassStack = new Stack();
}
-
/**
- * Returns current package.
+ * Gets the CurrentTag attribute of the DocletSupport class
*
- * @param pakkage The new CurrentPackage value
- * @see #setCurrentPackage(xjavadoc.XPackage)
+ * @return The CurrentTag value
*/
- public void setCurrentPackage(XPackage pakkage) {
- currentPackage = pakkage;
-
- // since we're now working on a new package, clear the class stack
-
- currentClassStack.clear();
+ public static XTag getCurrentMethodTag()
+ {
+ return currentMethodTag;
}
-
- /**
- * Sets the CurrentMethod attribute of the DocletSupport object
- *
- * @param method The new CurrentMethod value
- */
- public void setCurrentMethod(XMethod method) {
- currentMethod = method;
+ public static XTag getCurrentClassTag()
+ {
+ return currentClassTag;
}
-
/**
- * Sets the CurrentConstructor attribute of the DocletSupport object
+ * Returns true if the clazz generated by xdoclet. An xdoclet generated class
+ * has a class-level xdoclet-generated tag.
*
- * @param constructor The new CurrentConstructor value
+ * @param clazz Description of Parameter
+ * @return The DocletGenerated value
+ * @ejb:doclet-generated class tag defined. EJBDoclet does not try to analyze
+ * classes that are generated by EJBDoclet itself.
*/
- public void setCurrentConstructor(XConstructor constructor) {
- currentConstructor = constructor;
+ public static boolean isDocletGenerated( XClass clazz )
+ {
+ return clazz.doc().hasTag( "xdoclet-generated", false );
}
-
/**
- * Sets the CurrentField attribute of the DocletSupport object
+ * Sets the CurrentTag attribute of the DocletSupport class
*
- * @param field The new CurrentField value
+ * @param currentTag The new CurrentTag value
*/
- public void setCurrentField(XField field) {
- currentField = field;
+ public static void setCurrentMethodTag( XTag currentTag )
+ {
+ DocletSupport.currentMethodTag = currentTag;
}
-
- /**
- * Sets current class to clazz by clearing currentClassStack stack and pushing
- * clazz into top of it.
- *
- * @param clazz The new CurrentClass value
- * @see #getCurrentClass()
- */
- public void setCurrentClass(XClass clazz) {
- currentClassStack.clear();
- currentClassStack.push(clazz);
+ public static void setCurrentClassTag( XTag currentTag )
+ {
+ DocletSupport.currentClassTag = currentTag;
}
-
/**
* Peeks and return the current class from top of currentClassStack stack.
*
* @return The CurrentClass value
* @see #setCurrentClass(xjavadoc.XClass)
*/
- public XClass getCurrentClass() {
+ public XClass getCurrentClass()
+ {
return currentClassStack.empty() ? null :
(XClass)currentClassStack.peek();
}
-
/**
* Returns current package.
*
* @return The CurrentPackage value
* @see #setCurrentPackage(xjavadoc.XPackage)
*/
- public XPackage getCurrentPackage() {
+ public XPackage getCurrentPackage()
+ {
return currentPackage;
}
-
/**
* Returns current method.
*
* @return The CurrentMethod value
* @see #setCurrentMethod(xjavadoc.XMethod)
*/
- public XMethod getCurrentMethod() {
+ public XMethod getCurrentMethod()
+ {
return currentMethod;
}
-
/**
* Returns current constructor.
*
* @return The CurrentConstructor value
* @see #setCurrentConstructor(xjavadoc.XConstructor)
*/
- public XConstructor getCurrentConstructor() {
+ public XConstructor getCurrentConstructor()
+ {
return currentConstructor;
}
-
/**
* Returns current field.
*
* @return The CurrentField value
* @see #setCurrentField(xjavadoc.XField)
*/
- public XField getCurrentField() {
+ public XField getCurrentField()
+ {
return currentField;
}
-
/**
- * Pushes class clazz to top of currentClassStack stack, making it effectively
- * the current class.
+ * Returns current package.
*
- * @param clazz Description of Parameter
- * @return Description of the Returned Value
- * @see #getCurrentClass()
- * @see #setCurrentClass(xjavadoc.XClass)
- * @see #popCurrentClass()
+ * @param pakkage The new CurrentPackage value
+ * @see #setCurrentPackage(xjavadoc.XPackage)
*/
- public XClass pushCurrentClass(XClass clazz) {
- return (XClass)currentClassStack.push(clazz);
- }
+ public void setCurrentPackage( XPackage pakkage )
+ {
+ currentPackage = pakkage;
+
+ // since we're now working on a new package, clear the class stack
+ currentClassStack.clear();
+ }
/**
- * Popes current class from top currentClassStack stack. The poped class is no
- * longer the current class.
+ * Sets the CurrentMethod attribute of the DocletSupport object
*
- * @return Description of the Returned Value
- * @see #getCurrentClass()
- * @see #setCurrentClass(xjavadoc.XClass)
- * @see #pushCurrentClass(xjavadoc.XClass)
+ * @param method The new CurrentMethod value
*/
- public XClass popCurrentClass() {
- return (XClass)currentClassStack.pop();
+ public void setCurrentMethod( XMethod method )
+ {
+ currentMethod = method;
}
-
/**
- * Sets the CurrentTag attribute of the DocletSupport class
+ * Sets the CurrentConstructor attribute of the DocletSupport object
*
- * @param currentTag The new CurrentTag value
+ * @param constructor The new CurrentConstructor value
*/
- public static void setCurrentTag(XTag currentTag) {
- DocletSupport.currentTag = currentTag;
+ public void setCurrentConstructor( XConstructor constructor )
+ {
+ currentConstructor = constructor;
}
-
/**
- * Gets the CurrentTag attribute of the DocletSupport class
+ * Sets the CurrentField attribute of the DocletSupport object
*
- * @return The CurrentTag value
+ * @param field The new CurrentField value
*/
- public static XTag getCurrentTag() {
- return currentTag;
+ public void setCurrentField( XField field )
+ {
+ currentField = field;
}
+ /**
+ * Sets current class to clazz by clearing currentClassStack stack and pushing
+ * clazz into top of it.
+ *
+ * @param clazz The new CurrentClass value
+ * @see #getCurrentClass()
+ */
+ public void setCurrentClass( XClass clazz )
+ {
+ currentClassStack.clear();
+ currentClassStack.push( clazz );
+ }
/**
- * Returns true if the clazz generated by xdoclet. An xdoclet generated class
- * has a class-level xdoclet-generated tag.
+ * Pushes class clazz to top of currentClassStack stack, making it effectively
+ * the current class.
*
* @param clazz Description of Parameter
- * @return The DocletGenerated value
- * @ejb:doclet-generated class tag defined. EJBDoclet does not try to analyze
- * classes that are generated by EJBDoclet itself.
+ * @return Description of the Returned Value
+ * @see #getCurrentClass()
+ * @see #setCurrentClass(xjavadoc.XClass)
+ * @see #popCurrentClass()
*/
- public static boolean isDocletGenerated(XClass clazz) {
- return clazz.doc().hasTag("xdoclet-generated", false);
+ public XClass pushCurrentClass( XClass clazz )
+ {
+ return ( XClass ) currentClassStack.push( clazz );
+ }
+
+ /**
+ * Popes current class from top currentClassStack stack. The poped class is no
+ * longer the current class.
+ *
+ * @return Description of the Returned Value
+ * @see #getCurrentClass()
+ * @see #setCurrentClass(xjavadoc.XClass)
+ * @see #pushCurrentClass(xjavadoc.XClass)
+ */
+ public XClass popCurrentClass()
+ {
+ return ( XClass ) currentClassStack.pop();
}
}
1.37 +109 -78 xdoclet/core/src/xdoclet/XDocletTagSupport.java
Index: XDocletTagSupport.java
===================================================================
RCS file: /cvsroot/xdoclet/xdoclet/core/src/xdoclet/XDocletTagSupport.java,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -w -r1.36 -r1.37
--- XDocletTagSupport.java 16 Apr 2002 23:01:05 -0000 1.36
+++ XDocletTagSupport.java 17 Apr 2002 23:02:29 -0000 1.37
@@ -11,6 +11,7 @@
import java.util.List;
import java.util.Iterator;
import java.util.Map;
+import java.util.Arrays;
import xjavadoc.XClass;
import xjavadoc.XDoc;
@@ -38,7 +39,7 @@
*
* @author Dmitri Colebatch ([EMAIL PROTECTED])
* @created October 12, 2001
- * @version $Revision: 1.36 $
+ * @version $Revision: 1.37 $
*/
public abstract class XDocletTagSupport extends TemplateTagHandler
{
@@ -67,9 +68,14 @@
/**
* @return The current tag.
*/
- public static XTag getCurrentTag()
+ public static XTag getCurrentMethodTag()
{
- return getDocletContext().getActiveSubTask().getCurrentTag();
+ return getDocletContext().getActiveSubTask().getCurrentMethodTag();
+ }
+
+ public static XTag getCurrentClassTag()
+ {
+ return getDocletContext().getActiveSubTask().getCurrentClassTag();
}
/**
@@ -182,9 +188,14 @@
*
* @param currentTag The new CurrentTag value
*/
- public static void setCurrentTag( XTag currentTag )
+ public static void setCurrentMethodTag( XTag currentTag )
+ {
+ getDocletContext().getActiveSubTask().setCurrentMethodTag( currentTag
);
+ }
+
+ public static void setCurrentClassTag( XTag currentTag )
{
- getDocletContext().getActiveSubTask().setCurrentTag( currentTag );
+ getDocletContext().getActiveSubTask().setCurrentClassTag( currentTag );
}
/**
@@ -393,6 +404,17 @@
boolean superclasses = TypeConversionUtil.stringToBoolean(
attributes.getProperty( "superclasses" ), true );
boolean is_mandatory = TypeConversionUtil.stringToBoolean(
attributes.getProperty( "mandatory" ), false );
+
+ if( for_type == FOR_METHOD && getCurrentMethodTag() != null &&
getCurrentMethodTag().name().equals( tag_name ) && Arrays.asList(
getCurrentMethodTag().attributeValueNames() ).contains( param_name ) )
+ {
+ return getCurrentMethodTag().attributeValue( param_name );
+ }
+ else if( for_type == FOR_CLASS && getCurrentClassTag() != null )
+ {
+ return getCurrentClassTag().attributeValue( param_name );
+ }
+ else
+ {
/*
* Handles multiple tags/parameters. Multiple tags/parameter are
specified
* as alternatives, and are meant to be used as a "backward
compatibility"
@@ -477,6 +499,7 @@
tagValue = delimit( tagValue, attributes );
return tagValue;
}
+ }
/**
* Gets the TagValue attribute of the XDocletTagSupport class
@@ -561,17 +584,21 @@
boolean is_mandatory
) throws XDocletException
{
- // first try to get current tag
- XTag tag = getCurrentTag();
-
- if( tag != null && !tag.name().equals( tag_name ) )
- tag = null;
+// // first try to get current tag
+// XTag tag = getCurrentTag();
+//
+// if( tag != null && !tag.name().equals( tag_name ) )
+// tag = null;
+ /**
+ */
+ XTag tag = null;
- if( tag == null )
- {
+// if( tag == null )
+// {
// if there is no current tag, look in the doc
tag = doc.tag( tag_name, superclasses );
- }
+
+// }
String value = null;
@@ -656,9 +683,13 @@
String tag_name = attributes.getProperty( "tagName" );
String param_name = attributes.getProperty( "paramName" );
- if( getCurrentTag() != null && getCurrentTag().name().equals( tag_name
) )
+ if( for_type == FOR_METHOD && getCurrentMethodTag() != null &&
getCurrentMethodTag().name().equals( tag_name ) )
+ {
+ attribute_value = getCurrentMethodTag().attributeValue(
param_name );
+ }
+ if( for_type == FOR_CLASS && getCurrentClassTag() != null &&
getCurrentClassTag().name().equals( tag_name ) )
{
- attribute_value = getCurrentTag().attributeValue( param_name );
+ attribute_value = getCurrentClassTag().attributeValue(
param_name );
}
else
{
_______________________________________________
Xdoclet-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-devel