Update of /cvsroot/xdoclet/xdoclet/core/src/xdoclet/tagshandler
In directory
sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27017/core/src/xdoclet/tagshandler
Modified Files:
PackageTagsHandler.java
Log Message:
support for unqualifed classes added (XDT-688)
Index: PackageTagsHandler.java
===================================================================
RCS file:
/cvsroot/xdoclet/xdoclet/core/src/xdoclet/tagshandler/PackageTagsHandler.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -r1.14 -r1.15
*** PackageTagsHandler.java 1 Sep 2004 22:43:50 -0000 1.14
--- PackageTagsHandler.java 26 Mar 2005 10:25:32 -0000 1.15
***************
*** 220,230 ****
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(XDocletMessages.class, XDocletMessages.METHOD_FAILED, new
String[]{"packageOf"}));
}
}
--- 220,240 ----
public void packageOf(String template) throws XDocletException
{
! getEngine().print(getPackageNameFrom(template));
! }
! /**
! * Writes the package declaration for the package name of the
full-qualified class name specified in the body
! * of this tag. No package declaration is written if the full-qualified
class name has no package.
! *
! * @param template The body of the block tag
! * @exception XDocletException Description of Exception
! * @doc.tag type="block"
! */
! public void packageDeclarationOf(String template) throws XDocletException
! {
! String packageName = getPackageNameFrom(template);
!
! if (packageName != null && packageName.length() > 0) {
! getEngine().print("package " + packageName + ";");
}
}
***************
*** 281,284 ****
--- 291,321 ----
}
+ /**
+ * Returns the package name for the full-qualified class name specified in
the body
+ * of the passed tag.
+ *
+ * @param template The body of the block tag
+ * @return the package name or an empty string if the full-qualified class
name has no package
+ * @exception XDocletException Description of Exception
+ */
+ private String getPackageNameFrom(String template) throws XDocletException
+ {
+ try {
+ String fullClassName = getEngine().outputOf(template);
+ int pos = fullClassName.lastIndexOf('.');
+
+ if (pos < 0) {
+ return "";
+ }
+ else {
+ return getPackageNameFor(fullClassName.substring(0, pos),
true);
+ }
+ }
+ catch (TemplateException ex) {
+ throw new XDocletException(ex,
Translator.getString(XDocletMessages.class, XDocletMessages.METHOD_FAILED, new
String[]{"packageOf"}));
+ }
+
+ }
+
/**
* It's good practice to put interfaces (such as remote/local interfaces,
data objects and home interfaces) in a
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
xdoclet-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xdoclet-devel