Update of /cvsroot/xdoclet/xdoclet2/src/java/xdoclet
In directory sc8-pr-cvs1:/tmp/cvs-serv8437/src/java/xdoclet
Modified Files:
Plugin.java PluginFactory.java XDoclet.java
Log Message:
Added jxpath
Minor beaninfo related changes
Index: Plugin.java
===================================================================
RCS file: /cvsroot/xdoclet/xdoclet2/src/java/xdoclet/Plugin.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** Plugin.java 16 Mar 2003 17:06:55 -0000 1.10
--- Plugin.java 16 Mar 2003 23:24:15 -0000 1.11
***************
*** 6,10 ****
--- 6,13 ----
import org.apache.commons.collections.CollectionUtils;
+ import org.apache.commons.collections.Predicate;
import org.apache.commons.logging.LogFactory;
+ import org.apache.commons.jxpath.JXPathContext;
+ import org.apache.commons.jxpath.JXPathException;
import xdoclet.util.TypeConversionUtil;
***************
*** 30,36 ****
* <ul>
* <li>If there is a "{0}" in the fileName, one file will be generated for
! * each object returned by [EMAIL PROTECTED] XDoclet#getCollection()}.</li>
* <li>If there is no "{0}" in the fileName, one file will be generated for each
object
! * returned by [EMAIL PROTECTED] XDoclet#getCollection()}. This makes it
possible to use the XDoclet
* core for generation of files where the "metadata source" is other kinds of
* objects than e.g. xjavadoc.</li>
--- 33,39 ----
* <ul>
* <li>If there is a "{0}" in the fileName, one file will be generated for
! * each object returned by [EMAIL PROTECTED]
XDoclet#getMetadataCollection()}.</li>
* <li>If there is no "{0}" in the fileName, one file will be generated for each
object
! * returned by [EMAIL PROTECTED] XDoclet#getMetadataCollection()}. This makes it
possible to use the XDoclet
* core for generation of files where the "metadata source" is other kinds of
* objects than e.g. xjavadoc.</li>
***************
*** 57,68 ****
/** The name. */
private String _name;
- private Accept _accept = null;
/** The directory where plugin will write the files. */
private File _destination;
- /** The instance of XDoclet we're under. Set by XDoclet when we're added to it.
*/
- private XDoclet _xdoclet;
-
public Plugin() {
// We'll use our own name as default
--- 60,67 ----
***************
*** 71,75 ****
public XDoclet getXDoclet() {
! return _xdoclet;
}
--- 70,74 ----
public XDoclet getXDoclet() {
! return (XDoclet) getParent();
}
***************
*** 91,102 ****
/**
- * Called right after instantiation. Should only be called from PluginFactory.
- * @param xdoclet our owner
- */
- void setXDoclet(XDoclet xdoclet) {
- _xdoclet = xdoclet;
- }
-
- /**
* Returns the destination directory (without package directory).
* @return the destination directory
--- 90,93 ----
***************
*** 129,139 ****
*/
public final Accept createAccept() {
! if (_accept != null) {
throw new IllegalStateException("Only one accept is allowed");
}
! _accept = new Accept();
! return _accept;
}
--- 120,138 ----
*/
public final Accept createAccept() {
! if (getAccept() != null) {
throw new IllegalStateException("Only one accept is allowed");
}
! Accept accept = new Accept();
! add( accept );
! return accept;
! }
! private Accept getAccept() {
! return (Accept) CollectionUtils.find( this, new Predicate() {
! public boolean evaluate( Object o ) {
! return o instanceof Accept;
! }
! });
}
***************
*** 323,332 ****
throws XDocletException {
// Get all the classes including inner classes.
! Collection collection = getXDoclet().getCollection();
Collection result;
! if (_accept != null) {
// Filter out the objects we want.
! result = CollectionUtils.select(collection, _accept);
} else {
result = collection;
--- 322,331 ----
throws XDocletException {
// Get all the classes including inner classes.
! Collection collection = getXDoclet().getMetadataCollection();
Collection result;
! if ( getAccept() != null) {
// Filter out the objects we want.
! result = CollectionUtils.select(collection, getAccept());
} else {
result = collection;
***************
*** 442,445 ****
--- 441,460 ----
throw new XDocletException("Couldn't load " + className
+ ". Make sure you have this class on the classpath used to define
XDoclet.");
+ }
+ }
+
+ /**
+ * Hook to JXPath, which lets templates query the datamodel with xpath.
+ *
+ * @param contextBean the bean to query.
+ * @param xpath the xpath expression.
+ * @return the resulting bean.
+ */
+ public Object jxpath(Object contextBean, String xpath) {
+ try {
+ JXPathContext context = JXPathContext.newContext( contextBean );
+ return context.getValue( xpath );
+ } catch (JXPathException e) {
+ return null;
}
}
Index: PluginFactory.java
===================================================================
RCS file: /cvsroot/xdoclet/xdoclet2/src/java/xdoclet/PluginFactory.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** PluginFactory.java 16 Mar 2003 17:06:55 -0000 1.7
--- PluginFactory.java 16 Mar 2003 23:24:15 -0000 1.8
***************
*** 171,175 ****
plugin.setName(pluginName);
- plugin.setXDoclet(xdoclet);
return plugin;
--- 171,174 ----
Index: XDoclet.java
===================================================================
RCS file: /cvsroot/xdoclet/xdoclet2/src/java/xdoclet/XDoclet.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** XDoclet.java 16 Mar 2003 17:06:55 -0000 1.9
--- XDoclet.java 16 Mar 2003 23:24:15 -0000 1.10
***************
*** 22,27 ****
* <a href="../gui/package.html"></a>xdoclet.gui</p> package.
*
! * @bean.class locale="en"
! * displayName="Simple XDoclet"
* shortDescription="This is a simple XDoclet that can be used as a
container by generic Plugins"
* @see Plugin
--- 22,26 ----
* <a href="../gui/package.html"></a>xdoclet.gui</p> package.
*
! * @bean.class displayName="Simple XDoclet"
* shortDescription="This is a simple XDoclet that can be used as a
container by generic Plugins"
* @see Plugin
***************
*** 51,56 ****
private transient MetadataProvider _metadataProvider;
! /** A cache of the collection created by _metadataProvider. */
! private transient Collection _collection;
/**
--- 50,57 ----
private transient MetadataProvider _metadataProvider;
! /**
! * A cache of the collection created by _metadataProvider.
! */
! private transient Collection _metadataCollection;
/**
***************
*** 114,120 ****
* @bean.ignore
*/
! public Collection getCollection()
throws XDocletException {
! if (_collection == null) {
if (getMetadataProvider() == null) {
// Use xdoclet.xjavadoc.XJavadocCollectionFactory as default.
--- 115,121 ----
* @bean.ignore
*/
! public Collection getMetadataCollection()
throws XDocletException {
! if (_metadataCollection == null) {
if (getMetadataProvider() == null) {
// Use xdoclet.xjavadoc.XJavadocCollectionFactory as default.
***************
*** 132,139 ****
LogFactory.getLog(XDoclet.class).debug("Getting collection from a "
+ getMetadataProvider().getClass().getName());
! _collection = getMetadataProvider().createCollection();
}
! return _collection;
}
--- 133,140 ----
LogFactory.getLog(XDoclet.class).debug("Getting collection from a "
+ getMetadataProvider().getClass().getName());
! _metadataCollection = getMetadataProvider().createCollection();
}
! return _metadataCollection;
}
-------------------------------------------------------
This SF.net email is sponsored by:Crypto Challenge is now open!
Get cracking and register here for some mind boggling fun and
the chance of winning an Apple iPod:
http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0031en
_______________________________________________
xdoclet-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-devel