Update of /cvsroot/xdoclet/xdoclet2/src/java/xdoclet/util/predicates
In directory sc8-pr-cvs1:/tmp/cvs-serv23313/src/java/xdoclet/util/predicates

Modified Files:
        And.java CompositePredicate.java False.java HasClassTag.java 
        IsA.java Not.java Or.java PredicateException.java 
        PredicateFactory.java SimplePredicateFactory.java True.java 
Log Message:
- Applied formatting with Jalopy.
- Added our own Jalopy and Checkstyle settings.
- Added custom tag definitions to keep JavaDoc silent about custom tags.

Index: And.java
===================================================================
RCS file: /cvsroot/xdoclet/xdoclet2/src/java/xdoclet/util/predicates/And.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** And.java    27 Feb 2003 00:13:05 -0000      1.1.1.1
--- And.java    5 Mar 2003 22:27:11 -0000       1.2
***************
*** 3,13 ****
   * All rights reserved.
   */
- 
  package xdoclet.util.predicates;
  
- import java.util.Iterator;
- 
  import org.apache.commons.collections.Predicate;
  
  /**
   * Logical and between one or more predicates.
--- 3,12 ----
   * All rights reserved.
   */
  package xdoclet.util.predicates;
  
  import org.apache.commons.collections.Predicate;
  
+ import java.util.Iterator;
+ 
  /**
   * Logical and between one or more predicates.
***************
*** 16,23 ****
   * @version   $Revision$
   */
! public class And extends CompositePredicate
! {
!     public boolean evaluate(Object o)
!     {
          for (Iterator children = getChildren(); children.hasNext();) {
              Predicate child = (Predicate) children.next();
--- 15,20 ----
   * @version   $Revision$
   */
! public class And extends CompositePredicate {
!     public boolean evaluate(Object o) {
          for (Iterator children = getChildren(); children.hasNext();) {
              Predicate child = (Predicate) children.next();
***************
*** 30,32 ****
          return true;
      }
! }
\ No newline at end of file
--- 27,29 ----
          return true;
      }
! }

Index: CompositePredicate.java
===================================================================
RCS file: 
/cvsroot/xdoclet/xdoclet2/src/java/xdoclet/util/predicates/CompositePredicate.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** CompositePredicate.java     27 Feb 2003 00:13:05 -0000      1.1.1.1
--- CompositePredicate.java     5 Mar 2003 22:27:11 -0000       1.2
***************
*** 3,15 ****
   * All rights reserved.
   */
- 
  package xdoclet.util.predicates;
  
  import java.util.Collection;
  import java.util.Iterator;
  import java.util.LinkedList;
  
- import org.apache.commons.collections.Predicate;
- 
  /**
   * Baseclass for filters that contain other filters.
--- 3,14 ----
   * All rights reserved.
   */
  package xdoclet.util.predicates;
  
+ import org.apache.commons.collections.Predicate;
+ 
  import java.util.Collection;
  import java.util.Iterator;
  import java.util.LinkedList;
  
  /**
   * Baseclass for filters that contain other filters.
***************
*** 18,29 ****
   * @version   $Revision$
   */
! public abstract class CompositePredicate implements Predicate
! {
      private static final PredicateFactory _predicateFactory = new 
SimplePredicateFactory();
- 
      private Collection _children;
  
!     public void add(Predicate predicate)
!     {
          if (_children == null) {
              _children = new LinkedList();
--- 17,25 ----
   * @version   $Revision$
   */
! public abstract class CompositePredicate implements Predicate {
      private static final PredicateFactory _predicateFactory = new 
SimplePredicateFactory();
      private Collection _children;
  
!     public void add(Predicate predicate) {
          if (_children == null) {
              _children = new LinkedList();
***************
*** 33,38 ****
      }
  
!     protected Iterator getChildren()
!     {
          if (_children == null) {
              _children = new LinkedList();
--- 29,33 ----
      }
  
!     protected Iterator getChildren() {
          if (_children == null) {
              _children = new LinkedList();
***************
*** 42,48 ****
      }
  
!     public Predicate createElement(String name) throws PredicateException
!     {
          return _predicateFactory.createPredicate(name);
      }
! }
\ No newline at end of file
--- 37,43 ----
      }
  
!     public Predicate createElement(String name)
!         throws PredicateException {
          return _predicateFactory.createPredicate(name);
      }
! }

Index: False.java
===================================================================
RCS file: /cvsroot/xdoclet/xdoclet2/src/java/xdoclet/util/predicates/False.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** False.java  27 Feb 2003 00:13:05 -0000      1.1.1.1
--- False.java  5 Mar 2003 22:27:11 -0000       1.2
***************
*** 3,7 ****
   * All rights reserved.
   */
- 
  package xdoclet.util.predicates;
  
--- 3,6 ----
***************
*** 13,21 ****
   * @author <a href="aslak.hellesoy at netcom.no">Aslak Helles&oslash;y</a>
   */
! public class False implements Predicate
! {
!     public boolean evaluate(Object o)
!     {
          return false;
      }
! }
\ No newline at end of file
--- 12,18 ----
   * @author <a href="aslak.hellesoy at netcom.no">Aslak Helles&oslash;y</a>
   */
! public class False implements Predicate {
!     public boolean evaluate(Object o) {
          return false;
      }
! }

Index: HasClassTag.java
===================================================================
RCS file: /cvsroot/xdoclet/xdoclet2/src/java/xdoclet/util/predicates/HasClassTag.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** HasClassTag.java    27 Feb 2003 00:13:05 -0000      1.1.1.1
--- HasClassTag.java    5 Mar 2003 22:27:11 -0000       1.2
***************
*** 9,14 ****
   * @version $Revision$
   */
! public class HasClassTag extends ProgramElementPredicate
! {
      private String _tagName;
      private String _attributeName;
--- 9,13 ----
   * @version $Revision$
   */
! public class HasClassTag extends ProgramElementPredicate {
      private String _tagName;
      private String _attributeName;
***************
*** 24,28 ****
      /**
       * Constructs a new HasClassTag.
!      * 
       * @param tagName
       * @param attributeName
--- 23,27 ----
      /**
       * Constructs a new HasClassTag.
!      *
       * @param tagName
       * @param attributeName
***************
*** 35,69 ****
      }
  
!     public void setTagName(String tagName)
!     {
          _tagName = tagName;
      }
  
!     public void setAttributeName(String attributeName)
!     {
          _attributeName = attributeName;
      }
  
!     public void setAttributeValue(String attributeValue)
!     {
          _attributeValue = attributeValue;
      }
  
!     protected boolean evaluate(XProgramElement programElement)
!     {
          assert programElement != null;
  
          boolean result = false;
          if (_tagName == null) {
              throw new IllegalStateException("tagName must be specified for 
has-class-tag");
          }
  
!         if (_attributeName == null && _attributeValue == null) {
              // just see if the tag is there
!             result =  programElement.getDoc().hasTag(_tagName);
!         }
!         else if (_attributeName != null && _attributeValue != null) {
              // see if the tag attribute is there with the right value
!             return 
_attributeValue.equals(programElement.getDoc().getTagAttributeValue( _tagName, 
_attributeName)  );
              /*
              for( Iterator tags = 
programElement.getDoc().getTags(_tagName).iterator(); tags.hasNext(); ) {
--- 34,65 ----
      }
  
!     public void setTagName(String tagName) {
          _tagName = tagName;
      }
  
!     public void setAttributeName(String attributeName) {
          _attributeName = attributeName;
      }
  
!     public void setAttributeValue(String attributeValue) {
          _attributeValue = attributeValue;
      }
  
!     protected boolean evaluate(XProgramElement programElement) {
          assert programElement != null;
  
          boolean result = false;
+ 
          if (_tagName == null) {
              throw new IllegalStateException("tagName must be specified for 
has-class-tag");
          }
  
!         if ((_attributeName == null) && (_attributeValue == null)) {
              // just see if the tag is there
!             result = programElement.getDoc().hasTag(_tagName);
!         } else if ((_attributeName != null) && (_attributeValue != null)) {
              // see if the tag attribute is there with the right value
!             return 
_attributeValue.equals(programElement.getDoc().getTagAttributeValue(_tagName, 
_attributeName));
! 
              /*
              for( Iterator tags = 
programElement.getDoc().getTags(_tagName).iterator(); tags.hasNext(); ) {
***************
*** 75,81 ****
              }
              */
!         }
!         else {
!             throw new IllegalStateException("Both or none of _attributeName and 
_attributeValue must be specified for has-class-tag");
          }
  
--- 71,77 ----
              }
              */
!         } else {
!             throw new IllegalStateException(
!                 "Both or none of _attributeName and _attributeValue must be 
specified for has-class-tag");
          }
  

Index: IsA.java
===================================================================
RCS file: /cvsroot/xdoclet/xdoclet2/src/java/xdoclet/util/predicates/IsA.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** IsA.java    4 Mar 2003 23:44:05 -0000       1.2
--- IsA.java    5 Mar 2003 22:27:11 -0000       1.3
***************
*** 2,5 ****
--- 2,6 ----
  
  import org.apache.commons.collections.Predicate;
+ 
  import xjavadoc.XClass;
  
***************
*** 10,19 ****
   * @version $Revision$
   */
! public class IsA implements Predicate
! {
      private String _className;
  
      /** Constructs a new IsA. */
!     public IsA(){}
  
      /**
--- 11,20 ----
   * @version $Revision$
   */
! public class IsA implements Predicate {
      private String _className;
  
      /** Constructs a new IsA. */
!     public IsA() {
!     }
  
      /**
***************
*** 22,28 ****
       * @param className the name of the class to evaluate against
       */
!     public IsA(String className)
!     {
!         setClassName( className );
      }
  
--- 23,28 ----
       * @param className the name of the class to evaluate against
       */
!     public IsA(String className) {
!         setClassName(className);
      }
  
***************
*** 31,41 ****
       * @param className the name of the class to evaluate against
       */
!     public void setClassName(String className)
!     {
          _className = className;
      }
  
!     public final boolean evaluate(Object o)
!     {
          if (!(o instanceof XClass)) {
              throw new IllegalArgumentException("o must be of type XClass, but was: " 
+ o.getClass().getName());
--- 31,39 ----
       * @param className the name of the class to evaluate against
       */
!     public void setClassName(String className) {
          _className = className;
      }
  
!     public final boolean evaluate(Object o) {
          if (!(o instanceof XClass)) {
              throw new IllegalArgumentException("o must be of type XClass, but was: " 
+ o.getClass().getName());
***************
*** 43,46 ****
--- 41,45 ----
  
          XClass clazz = (XClass) o;
+ 
          return clazz.isA(_className);
      }

Index: Not.java
===================================================================
RCS file: /cvsroot/xdoclet/xdoclet2/src/java/xdoclet/util/predicates/Not.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** Not.java    27 Feb 2003 00:13:05 -0000      1.1.1.1
--- Not.java    5 Mar 2003 22:27:11 -0000       1.2
***************
*** 3,7 ****
   * All rights reserved.
   */
- 
  package xdoclet.util.predicates;
  
--- 3,6 ----
***************
*** 15,22 ****
   * @author <a href="aslak.hellesoy at netcom.no">Aslak Helles&oslash;y</a>
   */
! public class Not extends CompositePredicate
! {
!     public void add(Predicate predicate)
!     {
          if (getChildren().hasNext()) {
              throw new IllegalStateException("Only one sub-predicate allowed for 
not");
--- 14,19 ----
   * @author <a href="aslak.hellesoy at netcom.no">Aslak Helles&oslash;y</a>
   */
! public class Not extends CompositePredicate {
!     public void add(Predicate predicate) {
          if (getChildren().hasNext()) {
              throw new IllegalStateException("Only one sub-predicate allowed for 
not");
***************
*** 26,31 ****
      }
  
!     public boolean evaluate(Object o)
!     {
          if (!getChildren().hasNext()) {
              throw new IllegalStateException("Not requires one sub-predicate");
--- 23,27 ----
      }
  
!     public boolean evaluate(Object o) {
          if (!getChildren().hasNext()) {
              throw new IllegalStateException("Not requires one sub-predicate");
***************
*** 34,36 ****
          return !((Predicate) getChildren().next()).evaluate(o);
      }
! }
\ No newline at end of file
--- 30,32 ----
          return !((Predicate) getChildren().next()).evaluate(o);
      }
! }

Index: Or.java
===================================================================
RCS file: /cvsroot/xdoclet/xdoclet2/src/java/xdoclet/util/predicates/Or.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** Or.java     27 Feb 2003 00:13:05 -0000      1.1.1.1
--- Or.java     5 Mar 2003 22:27:11 -0000       1.2
***************
*** 3,15 ****
   * All rights reserved.
   */
- 
  package xdoclet.util.predicates;
  
- import java.util.Iterator;
- 
  import org.apache.commons.collections.Predicate;
  
  import xdoclet.util.predicates.CompositePredicate;
  
  /**
   * Logical and between one or more predicates.
--- 3,14 ----
   * All rights reserved.
   */
  package xdoclet.util.predicates;
  
  import org.apache.commons.collections.Predicate;
  
  import xdoclet.util.predicates.CompositePredicate;
  
+ import java.util.Iterator;
+ 
  /**
   * Logical and between one or more predicates.
***************
*** 17,24 ****
   * @author <a href="[EMAIL PROTECTED]">Aslak Helles�y</a>
   */
! public class Or extends CompositePredicate
! {
!     public boolean evaluate(Object o)
!     {
          for (Iterator children = getChildren(); children.hasNext();) {
              Predicate child = (Predicate) children.next();
--- 16,21 ----
   * @author <a href="[EMAIL PROTECTED]">Aslak Helles�y</a>
   */
! public class Or extends CompositePredicate {
!     public boolean evaluate(Object o) {
          for (Iterator children = getChildren(); children.hasNext();) {
              Predicate child = (Predicate) children.next();
***************
*** 31,33 ****
          return false;
      }
! }
\ No newline at end of file
--- 28,30 ----
          return false;
      }
! }

Index: PredicateException.java
===================================================================
RCS file: 
/cvsroot/xdoclet/xdoclet2/src/java/xdoclet/util/predicates/PredicateException.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** PredicateException.java     27 Feb 2003 00:13:05 -0000      1.1.1.1
--- PredicateException.java     5 Mar 2003 22:27:11 -0000       1.2
***************
*** 3,7 ****
   * All rights reserved.
   */
- 
  package xdoclet.util.predicates;
  
--- 3,6 ----
***************
*** 15,38 ****
   * @author <a href="aslak.hellesoy at netcom.no">Aslak Helles&oslash;y</a>
   */
! public class PredicateException extends XDocletException
! {
!     public PredicateException()
!     {
          super();
      }
  
!     public PredicateException(String message)
!     {
          super(message);
      }
  
!     public PredicateException(String message, Throwable cause)
!     {
          super(message, cause);
      }
  
!     public PredicateException(Throwable cause)
!     {
          super(cause);
      }
! }
\ No newline at end of file
--- 14,32 ----
   * @author <a href="aslak.hellesoy at netcom.no">Aslak Helles&oslash;y</a>
   */
! public class PredicateException extends XDocletException {
!     public PredicateException() {
          super();
      }
  
!     public PredicateException(String message) {
          super(message);
      }
  
!     public PredicateException(String message, Throwable cause) {
          super(message, cause);
      }
  
!     public PredicateException(Throwable cause) {
          super(cause);
      }
! }

Index: PredicateFactory.java
===================================================================
RCS file: 
/cvsroot/xdoclet/xdoclet2/src/java/xdoclet/util/predicates/PredicateFactory.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** PredicateFactory.java       27 Feb 2003 00:13:05 -0000      1.1.1.1
--- PredicateFactory.java       5 Mar 2003 22:27:11 -0000       1.2
***************
*** 3,7 ****
   * All rights reserved.
   */
- 
  package xdoclet.util.predicates;
  
--- 3,6 ----
***************
*** 17,22 ****
   * @author <a href="aslak.hellesoy at netcom.no">Aslak Helles&oslash;y</a>
   */
! public interface PredicateFactory
! {
      /**
       * Creates a Predicate by name.
--- 16,20 ----
   * @author <a href="aslak.hellesoy at netcom.no">Aslak Helles&oslash;y</a>
   */
! public interface PredicateFactory {
      /**
       * Creates a Predicate by name.
***************
*** 26,29 ****
       * @exception PredicateException If there is no registered Predicate for name.
       */
!     Predicate createPredicate(String name) throws PredicateException;
! }
\ No newline at end of file
--- 24,28 ----
       * @exception PredicateException If there is no registered Predicate for name.
       */
!     Predicate createPredicate(String name)
!         throws PredicateException;
! }

Index: SimplePredicateFactory.java
===================================================================
RCS file: 
/cvsroot/xdoclet/xdoclet2/src/java/xdoclet/util/predicates/SimplePredicateFactory.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** SimplePredicateFactory.java 27 Feb 2003 00:13:05 -0000      1.1.1.1
--- SimplePredicateFactory.java 5 Mar 2003 22:27:11 -0000       1.2
***************
*** 3,16 ****
   * All rights reserved.
   */
- 
  package xdoclet.util.predicates;
  
- import java.util.HashMap;
- import java.util.Map;
- 
  import org.apache.commons.collections.Predicate;
  
  import xdoclet.util.predicates.*;
  
  /**
   * Simple predicate factory. Should be subclassed to add domain-specific predicates.
--- 3,15 ----
   * All rights reserved.
   */
  package xdoclet.util.predicates;
  
  import org.apache.commons.collections.Predicate;
  
  import xdoclet.util.predicates.*;
  
+ import java.util.HashMap;
+ import java.util.Map;
+ 
  /**
   * Simple predicate factory. Should be subclassed to add domain-specific predicates.
***************
*** 26,31 ****
   * @author <a href="aslak.hellesoy at netcom.no">Aslak Helles&oslash;y</a>
   */
! public class SimplePredicateFactory implements PredicateFactory
! {
      private final Map _predicates = new HashMap(7);
  
--- 25,29 ----
   * @author <a href="aslak.hellesoy at netcom.no">Aslak Helles&oslash;y</a>
   */
! public class SimplePredicateFactory implements PredicateFactory {
      private final Map _predicates = new HashMap(7);
  
***************
*** 33,38 ****
       * Constructs a new SimplePredicateFactory.
       */
!     public SimplePredicateFactory()
!     {
          // general predicates
          register("and", And.class);
--- 31,35 ----
       * Constructs a new SimplePredicateFactory.
       */
!     public SimplePredicateFactory() {
          // general predicates
          register("and", And.class);
***************
*** 56,62 ****
       * @throws PredicateException If the requested predicate is not registered.
       */
!     public Predicate createPredicate(String name) throws PredicateException
!     {
!         if (name == null) throw new IllegalArgumentException("name cannot be null");
  
          try {
--- 53,61 ----
       * @throws PredicateException If the requested predicate is not registered.
       */
!     public Predicate createPredicate(String name)
!         throws PredicateException {
!         if (name == null) {
!             throw new IllegalArgumentException("name cannot be null");
!         }
  
          try {
***************
*** 70,78 ****
              // Instantiate the predicate and return it
              return (Predicate) clazz.newInstance();
!         }
!         catch (IllegalAccessException e) {
              throw new PredicateException(e.getMessage(), e);
!         }
!         catch (InstantiationException e) {
              throw new PredicateException(e.getMessage(), e);
          }
--- 69,75 ----
              // Instantiate the predicate and return it
              return (Predicate) clazz.newInstance();
!         } catch (IllegalAccessException e) {
              throw new PredicateException(e.getMessage(), e);
!         } catch (InstantiationException e) {
              throw new PredicateException(e.getMessage(), e);
          }
***************
*** 85,92 ****
       * @param predicateClass the class used for this predicate
       */
!     private void register(String name, Class predicateClass)
!     {
!         assert name != null && predicateClass != null;
          _predicates.put(name, predicateClass);
      }
! }
\ No newline at end of file
--- 82,88 ----
       * @param predicateClass the class used for this predicate
       */
!     private void register(String name, Class predicateClass) {
!         assert (name != null) && (predicateClass != null);
          _predicates.put(name, predicateClass);
      }
! }

Index: True.java
===================================================================
RCS file: /cvsroot/xdoclet/xdoclet2/src/java/xdoclet/util/predicates/True.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** True.java   27 Feb 2003 00:13:05 -0000      1.1.1.1
--- True.java   5 Mar 2003 22:27:11 -0000       1.2
***************
*** 3,7 ****
   * All rights reserved.
   */
- 
  package xdoclet.util.predicates;
  
--- 3,6 ----
***************
*** 13,21 ****
   * @author <a href="aslak.hellesoy at netcom.no">Aslak Helles&oslash;y</a>
   */
! public class True implements Predicate
! {
!     public boolean evaluate(Object o)
!     {
          return true;
      }
! }
\ No newline at end of file
--- 12,18 ----
   * @author <a href="aslak.hellesoy at netcom.no">Aslak Helles&oslash;y</a>
   */
! public class True implements Predicate {
!     public boolean evaluate(Object o) {
          return true;
      }
! }



-------------------------------------------------------
This SF.net email is sponsored by: Etnus, makers of TotalView, The debugger 
for complex code. Debugging C/C++ programs can leave you feeling lost and 
disoriented. TotalView can help you find your way. Available on major UNIX 
and Linux platforms. Try it free. www.etnus.com
_______________________________________________
xdoclet-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-devel

Reply via email to