Update of /cvsroot/xdoclet/xdoclet2/src/java/xdoclet
In directory sc8-pr-cvs1:/tmp/cvs-serv30662/src/java/xdoclet
Modified Files:
Accept.java
Log Message:
Fixed CCE in TreeModel. Made beans out of predicates and accept
Index: Accept.java
===================================================================
RCS file: /cvsroot/xdoclet/xdoclet2/src/java/xdoclet/Accept.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** Accept.java 7 Mar 2003 09:15:08 -0000 1.3
--- Accept.java 17 Mar 2003 00:22:45 -0000 1.4
***************
*** 2,5 ****
--- 2,6 ----
import org.apache.commons.collections.Predicate;
+ import org.apache.commons.collections.CollectionUtils;
import xdoclet.util.predicates.PredicateFactory;
***************
*** 15,21 ****
* @version $Revision$
*/
! public class Accept implements Predicate {
private static final PredicateFactory PREDICATE_FACTORY = new
SimplePredicateFactory();
- private Predicate _predicate = null;
/**
--- 16,21 ----
* @version $Revision$
*/
! public class Accept extends BeanContextSupportEx implements Predicate {
private static final PredicateFactory PREDICATE_FACTORY = new
SimplePredicateFactory();
/**
***************
*** 28,32 ****
public Object createElement(String predicateType)
throws XDocletException {
! if (_predicate != null) {
throw new XDocletException("Only one predicate allowed under accept");
}
--- 28,32 ----
public Object createElement(String predicateType)
throws XDocletException {
! if (getPredicate() != null) {
throw new XDocletException("Only one predicate allowed under accept");
}
***************
*** 39,42 ****
--- 39,50 ----
}
+ private Predicate getPredicate() {
+ return (Predicate) CollectionUtils.find( this, new Predicate() {
+ public boolean evaluate( Object o ) {
+ return o instanceof Predicate;
+ }
+ });
+ }
+
/**
* Sets the predicate to use.
***************
*** 45,49 ****
*/
public void setPredicate(Predicate predicate) {
! _predicate = predicate;
}
--- 53,57 ----
*/
public void setPredicate(Predicate predicate) {
! add( predicate );
}
***************
*** 55,63 ****
*/
public boolean evaluate(Object o) {
! if (_predicate == null) {
throw new IllegalStateException("One predicate must be specified under
accept");
}
! return _predicate.evaluate(o);
}
}
--- 63,71 ----
*/
public boolean evaluate(Object o) {
! if (getPredicate() == null) {
throw new IllegalStateException("One predicate must be specified under
accept");
}
! return getPredicate().evaluate(o);
}
}
-------------------------------------------------------
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