[prev in list] [next in list] [prev in thread] [next in thread] 

List:       slide-dev
Subject:    cvs commit: jakarta-slide/src/share/org/apache/slide/search/basic IsPrincipalExpression.java Contain
From:       wam () apache ! org
Date:       2002-03-28 9:55:04
[Download RAW message or body]

wam         02/03/28 01:55:04

  Modified:    src/share/org/apache/slide/search RequestedResourceImpl.java
                        RequestedResource.java
               src/share/org/apache/slide/search/basic LTExpression.java
                        LTEExpression.java Literals.java
                        IsDefinedExpression.java
                        IsCollectionExpression.java GTExpression.java
                        GTEExpression.java EQExpression.java
                        CompareExpression.java BasicExpression.java
  Added:       src/share/org/apache/slide/search/basic
                        IsPrincipalExpression.java ContainsExpression.java
                        ComparePropertyExpression.java
                        CheckResourceTypeExpression.java
  Log:
  added first prototype of CONTAINS operator
  restructured hierarchy of search expressions
  added non-DASL operator is-principal
  
  Revision  Changes    Path
  1.4       +63 -6     \
jakarta-slide/src/share/org/apache/slide/search/RequestedResourceImpl.java  
  Index: RequestedResourceImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/search/RequestedResourceImpl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- RequestedResourceImpl.java	28 Mar 2002 06:23:15 -0000	1.3
  +++ RequestedResourceImpl.java	28 Mar 2002 09:55:03 -0000	1.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/search/RequestedResourceImpl.java,v \
                1.3 2002/03/28 06:23:15 jericho Exp $
  - * $Revision: 1.3 $
  - * $Date: 2002/03/28 06:23:15 $
  + * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/search/RequestedResourceImpl.java,v \
1.4 2002/03/28 09:55:03 wam Exp $  + * $Revision: 1.4 $
  + * $Date: 2002/03/28 09:55:03 $
    *
    * ====================================================================
    *
  @@ -68,13 +68,17 @@
   import org.apache.slide.common.SlideException;
   import org.apache.slide.common.SlideToken;
   import org.apache.slide.content.NodeProperty;
  +import org.apache.slide.content.NodeRevisionContent;
   import org.apache.slide.content.NodeRevisionDescriptor;
   import org.apache.slide.content.NodeRevisionDescriptors;
   import org.apache.slide.content.Content;
  -
  +import org.apache.slide.common.SlideException;
   //??
   import org.apache.slide.search.basic.Literals;
   
  +import java.util.Set;
  +import java.util.HashSet;
  +
   import java.util.Enumeration;
   import java.util.Date;
   
  @@ -83,7 +87,7 @@
    * equals, ...
    *
    * @author <a href="mailto:martin.wallmer@softwareag.com">Martin Wallmer</a>
  - * @version $Revision: 1.3 $
  + * @version $Revision: 1.4 $
    */
   public class RequestedResourceImpl implements RequestedResource {
       
  @@ -96,6 +100,16 @@
       /** the latest revision of this resource */
       private NodeRevisionDescriptor revisionDescriptor;
       
  +    private Content contentHelper;
  +    private NodeRevisionDescriptors revisionDescriptors;
  +    private SlideToken slideToken;
  +    
  +    /** coantains allowed on */
  +    static final private Set containsAllowedOn = new HashSet();
  +    static {
  +        containsAllowedOn.add ("text/xml");
  +        containsAllowedOn.add ("application/text");
  +    };
       
       private static final int EQ =  1;
       private static final int GT =  2;
  @@ -103,6 +117,8 @@
       private static final int GTE = 4;
       private static final int LTE = 5;
       
  +    
  +    
       // private boolean isCollection;
       
       /**
  @@ -120,7 +136,8 @@
           throws SlideException
       {
           this.objectNode = objectNode;
  -        NodeRevisionDescriptors revisionDescriptors;
  +        this.contentHelper = contentHelper;
  +        this.slideToken = slideToken;
           
           try {
               revisionDescriptors =
  @@ -129,6 +146,7 @@
               try {
                   revisionDescriptor =
                       contentHelper.retrieve (slideToken, revisionDescriptors);
  +                
               }
               catch (org.apache.slide.content.RevisionDescriptorNotFoundException e) \
                {
                   // The object doesn't have any revision, we create a dummy
  @@ -293,6 +311,45 @@
        */
       public boolean isDefined (String propName) {
           return getThisValue (propName) == null ? false : true;
  +    }
  +    
  +    /**
  +     * Checks, if the content of the resource contains a specific literal.
  +     *
  +     * @param    literal             a  String
  +     *
  +     * @return   true if literal is contained in this resources' content
  +     *
  +     */
  +    public int contains (String literal) {
  +        int result = Literals.UNKNOWN;
  +        
  +        NodeProperty property = revisionDescriptor.getProperty ("getcontenttype");
  +        
  +        if (property != null) {
  +            String contentType = (String) property.getValue();
  +            if (containsAllowedOn.contains (contentType)) {
  +                
  +                try {
  +                    NodeRevisionContent revisionContent = contentHelper.retrieve \
(slideToken, revisionDescriptors, revisionDescriptor);  +                    
  +                    // TODO: be aware of I18N
  +                    
  +                    String content = new String \
(revisionContent.getContentBytes());  +                    
  +                    if (content.indexOf (literal) > -1)
  +                        result = Literals.TRUE;
  +                    else
  +                        result = Literals.FALSE;
  +                }
  +                catch (org.apache.slide.common.SlideException e) {
  +                    // error handling ???
  +                }
  +                
  +            }
  +        }
  +        
  +        return result;
       }
       
       
  
  
  
  1.4       +15 -4     \
jakarta-slide/src/share/org/apache/slide/search/RequestedResource.java  
  Index: RequestedResource.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/search/RequestedResource.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- RequestedResource.java	28 Mar 2002 06:23:15 -0000	1.3
  +++ RequestedResource.java	28 Mar 2002 09:55:03 -0000	1.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/search/RequestedResource.java,v \
                1.3 2002/03/28 06:23:15 jericho Exp $
  - * $Revision: 1.3 $
  - * $Date: 2002/03/28 06:23:15 $
  + * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/search/RequestedResource.java,v \
1.4 2002/03/28 09:55:03 wam Exp $  + * $Revision: 1.4 $
  + * $Date: 2002/03/28 09:55:03 $
    *
    * ====================================================================
    *
  @@ -85,7 +85,7 @@
    * TODO: Namespace awareness!!
    *
    * @author <a href="mailto:martin.wallmer@softwareag.com">Martin Wallmer</a>
  - * @version $Revision: 1.3 $
  + * @version $Revision: 1.4 $
    */
   public interface RequestedResource {
       
  @@ -191,6 +191,17 @@
        *
        */
       public boolean isDefined (String propName);
  +    
  +    
  +    /**
  +     * Checks, if the content of the resource contains a specific literal.
  +     *
  +     * @param    literal             a  String
  +     *
  +     * @return   true if literal is contained in this resources' content
  +     *
  +     */
  +    public int contains (String literal);
       
   }
   
  
  
  
  1.3       +5 -5      \
jakarta-slide/src/share/org/apache/slide/search/basic/LTExpression.java  
  Index: LTExpression.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/search/basic/LTExpression.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LTExpression.java	28 Mar 2002 06:23:16 -0000	1.2
  +++ LTExpression.java	28 Mar 2002 09:55:03 -0000	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/search/basic/LTExpression.java,v \
                1.2 2002/03/28 06:23:16 jericho Exp $
  - * $Revision: 1.2 $
  - * $Date: 2002/03/28 06:23:16 $
  + * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/search/basic/LTExpression.java,v \
1.3 2002/03/28 09:55:03 wam Exp $  + * $Revision: 1.3 $
  + * $Date: 2002/03/28 09:55:03 $
    *
    * ====================================================================
    *
  @@ -73,9 +73,9 @@
    * Represents an EQUALS expression.
    *
    * @author <a href="mailto:martin.wallmer@softwareag.com">Martin Wallmer</a>
  - * @version $Revision: 1.2 $
  + * @version $Revision: 1.3 $
    */
  -public class LTExpression extends CompareExpression {
  +public class LTExpression extends ComparePropertyExpression {
       
       /**
        * Creates an EQ expression according to Element e
  
  
  
  1.3       +5 -5      \
jakarta-slide/src/share/org/apache/slide/search/basic/LTEExpression.java  
  Index: LTEExpression.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/search/basic/LTEExpression.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LTEExpression.java	28 Mar 2002 06:23:16 -0000	1.2
  +++ LTEExpression.java	28 Mar 2002 09:55:04 -0000	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/search/basic/LTEExpression.java,v \
                1.2 2002/03/28 06:23:16 jericho Exp $
  - * $Revision: 1.2 $
  - * $Date: 2002/03/28 06:23:16 $
  + * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/search/basic/LTEExpression.java,v \
1.3 2002/03/28 09:55:04 wam Exp $  + * $Revision: 1.3 $
  + * $Date: 2002/03/28 09:55:04 $
    *
    * ====================================================================
    *
  @@ -73,9 +73,9 @@
    * Represents an EQUALS expression.
    *
    * @author <a href="mailto:martin.wallmer@softwareag.com">Martin Wallmer</a>
  - * @version $Revision: 1.2 $
  + * @version $Revision: 1.3 $
    */
  -public class LTEExpression extends CompareExpression {
  +public class LTEExpression extends ComparePropertyExpression {
       
       /**
        * Creates an EQ expression according to Element e
  
  
  
  1.5       +6 -4      \
jakarta-slide/src/share/org/apache/slide/search/basic/Literals.java  
  Index: Literals.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/search/basic/Literals.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Literals.java	28 Mar 2002 06:23:16 -0000	1.4
  +++ Literals.java	28 Mar 2002 09:55:04 -0000	1.5
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/search/basic/Literals.java,v \
                1.4 2002/03/28 06:23:16 jericho Exp $
  - * $Revision: 1.4 $
  - * $Date: 2002/03/28 06:23:16 $
  + * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/search/basic/Literals.java,v \
1.5 2002/03/28 09:55:04 wam Exp $  + * $Revision: 1.5 $
  + * $Date: 2002/03/28 09:55:04 $
    *
    * ====================================================================
    *
  @@ -67,7 +67,7 @@
    * static container for some literals.
    *
    * @author <a href="mailto:martin.wallmer@softwareag.com">Martin Wallmer</a>
  - * @version $Revision: 1.4 $
  + * @version $Revision: 1.5 $
    */
   public class Literals {
   
  @@ -77,6 +77,7 @@
       public static final String ASCENDING     = "ascending";
       public static final String BASICSEARCH   = "basicsearch";
       public static final String CASESENSITIVE = "casesensitive";
  +    public static final String CONTAINS      = "contains";
       public static final String DEPTH         = "depth";
       public static final String DESCENDING    = "descending";
       public static final String EQ            = "eq";
  @@ -86,6 +87,7 @@
       public static final String INFINITY      = "infinity";
       public static final String ISCOLLECTION  = "is-collection";
       public static final String ISDEFINED     = "isdefined";
  +    public static final String ISPRINCIPAL   = "is-principal";
       public static final String LIMIT         = "limit";
       public static final String LITERAL       = "literal";
       public static final String LT            = "lt";
  
  
  
  1.4       +5 -5      \
jakarta-slide/src/share/org/apache/slide/search/basic/IsDefinedExpression.java  
  Index: IsDefinedExpression.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/search/basic/IsDefinedExpression.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- IsDefinedExpression.java	28 Mar 2002 06:23:16 -0000	1.3
  +++ IsDefinedExpression.java	28 Mar 2002 09:55:04 -0000	1.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/search/basic/IsDefinedExpression.java,v \
                1.3 2002/03/28 06:23:16 jericho Exp $
  - * $Revision: 1.3 $
  - * $Date: 2002/03/28 06:23:16 $
  + * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/search/basic/IsDefinedExpression.java,v \
1.4 2002/03/28 09:55:04 wam Exp $  + * $Revision: 1.4 $
  + * $Date: 2002/03/28 09:55:04 $
    *
    * ====================================================================
    *
  @@ -73,9 +73,9 @@
    * Represents an isdefined expression.
    *
    * @author <a href="mailto:martin.wallmer@softwareag.com">Martin Wallmer</a>
  - * @version $Revision: 1.3 $
  + * @version $Revision: 1.4 $
    */
  -public class IsDefinedExpression extends CompareExpression {
  +public class IsDefinedExpression extends ComparePropertyExpression {
       
       /**
        * Creates an isdefined expression according to Element e
  
  
  
  1.4       +9 -23     \
jakarta-slide/src/share/org/apache/slide/search/basic/IsCollectionExpression.java  
  Index: IsCollectionExpression.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/search/basic/IsCollectionExpression.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- IsCollectionExpression.java	28 Mar 2002 06:23:16 -0000	1.3
  +++ IsCollectionExpression.java	28 Mar 2002 09:55:04 -0000	1.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/search/basic/IsCollectionExpression.java,v \
                1.3 2002/03/28 06:23:16 jericho Exp $
  - * $Revision: 1.3 $
  - * $Date: 2002/03/28 06:23:16 $
  + * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/search/basic/IsCollectionExpression.java,v \
1.4 2002/03/28 09:55:04 wam Exp $  + * $Revision: 1.4 $
  + * $Date: 2002/03/28 09:55:04 $
    *
    * ====================================================================
    *
  @@ -70,38 +70,24 @@
   import java.util.Set;
   
   /**
  - * Represents an EQUALS expression.
  + * Represents an is-collection expression.
    *
    * @author <a href="mailto:martin.wallmer@softwareag.com">Martin Wallmer</a>
  - * @version $Revision: 1.3 $
  + * @version $Revision: 1.4 $
    */
  -public class IsCollectionExpression extends CompareExpression {
  +public class IsCollectionExpression extends CheckResourceTypeExpression {
       
       /**
  -     * Creates an EQ expression according to Element e
  +     * Creates an is-collection expression
        *
        * @param e jdom element, that describes the expression
        *
        */
       protected IsCollectionExpression (Element e) throws InvalidQueryException {
  -        this.expressionElement = e;
  -        property = Literals.RESOURCETYPE;
  -        literal = "<collection/>";
  +        super (e);
  +        literal = "collection";
       }
          
  -    /**
  -     * Checks item for equality against <prop><literal> of this expression.
  -     *
  -     * @param    item                a  BasicDataItem
  -     *
  -     * @return   a boolean
  -     *
  -     */
  -    protected boolean compare (RequestedResource item) {
  -        return item.equals (property, literal) == Literals.TRUE;
  -    }
  -    
  -
       /**
        * For debugging purpose.
        *
  
  
  
  1.4       +5 -5      \
jakarta-slide/src/share/org/apache/slide/search/basic/GTExpression.java  
  Index: GTExpression.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/search/basic/GTExpression.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- GTExpression.java	28 Mar 2002 06:23:16 -0000	1.3
  +++ GTExpression.java	28 Mar 2002 09:55:04 -0000	1.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/search/basic/GTExpression.java,v \
                1.3 2002/03/28 06:23:16 jericho Exp $
  - * $Revision: 1.3 $
  - * $Date: 2002/03/28 06:23:16 $
  + * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/search/basic/GTExpression.java,v \
1.4 2002/03/28 09:55:04 wam Exp $  + * $Revision: 1.4 $
  + * $Date: 2002/03/28 09:55:04 $
    *
    * ====================================================================
    *
  @@ -74,9 +74,9 @@
    * Represents an GREATER_THAN expression.
    *
    * @author <a href="mailto:martin.wallmer@softwareag.com">Martin Wallmer</a>
  - * @version $Revision: 1.3 $
  + * @version $Revision: 1.4 $
    */
  -public class GTExpression extends CompareExpression {
  +public class GTExpression extends ComparePropertyExpression {
       
       
       /**
  
  
  
  1.3       +5 -5      \
jakarta-slide/src/share/org/apache/slide/search/basic/GTEExpression.java  
  Index: GTEExpression.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/search/basic/GTEExpression.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- GTEExpression.java	28 Mar 2002 06:23:16 -0000	1.2
  +++ GTEExpression.java	28 Mar 2002 09:55:04 -0000	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/search/basic/GTEExpression.java,v \
                1.2 2002/03/28 06:23:16 jericho Exp $
  - * $Revision: 1.2 $
  - * $Date: 2002/03/28 06:23:16 $
  + * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/search/basic/GTEExpression.java,v \
1.3 2002/03/28 09:55:04 wam Exp $  + * $Revision: 1.3 $
  + * $Date: 2002/03/28 09:55:04 $
    *
    * ====================================================================
    *
  @@ -73,9 +73,9 @@
    * Represents an EQUALS expression.
    *
    * @author <a href="mailto:martin.wallmer@softwareag.com">Martin Wallmer</a>
  - * @version $Revision: 1.2 $
  + * @version $Revision: 1.3 $
    */
  -public class GTEExpression extends CompareExpression {
  +public class GTEExpression extends ComparePropertyExpression {
       
       /**
        * Creates an EQ expression according to Element e
  
  
  
  1.4       +5 -5      \
jakarta-slide/src/share/org/apache/slide/search/basic/EQExpression.java  
  Index: EQExpression.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/search/basic/EQExpression.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- EQExpression.java	28 Mar 2002 06:23:16 -0000	1.3
  +++ EQExpression.java	28 Mar 2002 09:55:04 -0000	1.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/search/basic/EQExpression.java,v \
                1.3 2002/03/28 06:23:16 jericho Exp $
  - * $Revision: 1.3 $
  - * $Date: 2002/03/28 06:23:16 $
  + * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/search/basic/EQExpression.java,v \
1.4 2002/03/28 09:55:04 wam Exp $  + * $Revision: 1.4 $
  + * $Date: 2002/03/28 09:55:04 $
    *
    * ====================================================================
    *
  @@ -73,9 +73,9 @@
    * Represents an EQUALS expression.
    *
    * @author <a href="mailto:martin.wallmer@softwareag.com">Martin Wallmer</a>
  - * @version $Revision: 1.3 $
  + * @version $Revision: 1.4 $
    */
  -public class EQExpression extends CompareExpression {
  +public class EQExpression extends ComparePropertyExpression {
       
       /**
        * Creates an EQ expression according to Element e
  
  
  
  1.5       +4 -67     \
jakarta-slide/src/share/org/apache/slide/search/basic/CompareExpression.java  
  Index: CompareExpression.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/search/basic/CompareExpression.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- CompareExpression.java	28 Mar 2002 06:23:16 -0000	1.4
  +++ CompareExpression.java	28 Mar 2002 09:55:04 -0000	1.5
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/search/basic/CompareExpression.java,v \
                1.4 2002/03/28 06:23:16 jericho Exp $
  - * $Revision: 1.4 $
  - * $Date: 2002/03/28 06:23:16 $
  + * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/search/basic/CompareExpression.java,v \
1.5 2002/03/28 09:55:04 wam Exp $  + * $Revision: 1.5 $
  + * $Date: 2002/03/28 09:55:04 $
    *
    * ====================================================================
    *
  @@ -77,16 +77,10 @@
    * Abstract base class for compare expressions (GT, EQ, is-collection ...).
    *
    * @author <a href="mailto:martin.wallmer@softwareag.com">Martin Wallmer</a>
  - * @version $Revision: 1.4 $
  + * @version $Revision: 1.5 $
    */
   public abstract class CompareExpression extends BasicExpression {
       
  -    /** the property name <prop> */
  -    protected String property;
  -    
  -    /** the property's value <literal> */
  -    protected String literal;
  -    
       /**
        * dummy constructor, called by is-collection (as no prop / literal
        * is passed).
  @@ -101,54 +95,6 @@
        */
       CompareExpression (Element e) throws InvalidQueryException {
           super (e);
  -        property = getPropName(e);
  -        literal  = getLiteral (e);
  -    }
  -    
  -    /**
  -     * extracs the value of <literal> of an expression
  -     *
  -     * @param    e                   an Expression
  -     *
  -     * @return   the literal as string
  -     *
  -     * @throws   InvalidQueryException if no <literal> found in e
  -     *
  -     */
  -    private String  getLiteral(Element e) throws InvalidQueryException {
  -        Element lit = e.getChild (Literals.LITERAL, e.getNamespace());
  -        if (lit == null)
  -            throw new InvalidQueryException
  -                ("No literal element supplied");
  -        
  -        return lit.getText ();
  -    }
  -    
  -    /**
  -     * extracts the property name of this expression
  -     *
  -     * @param    e                   an Expression
  -     *
  -     * @return   the property name as string
  -     *
  -     * @throws   InvalidQueryException if no or more than one
  -     *           property was supplied
  -     *
  -     */
  -    protected String getPropName(Element e) throws InvalidQueryException {
  -        Element propListElement = e.getChild (Literals.PROP, e.getNamespace());
  -        if (propListElement == null)
  -            throw new InvalidQueryException
  -                ("No property element supplied");
  -        
  -        List propList = propListElement.getChildren();
  -        
  -        if (propList.size() != 1)
  -            throw new InvalidQueryException
  -                ("Expected exactly 1 prop element, found " + propList.size());
  -        
  -        
  -        return ((Element)propList.get(0)).getName();
       }
       
       /**
  @@ -184,14 +130,5 @@
        *
        */
       protected abstract boolean compare (RequestedResource item);
  -    
  -    /**
  -     * String representation for debugging purposes.
  -     *
  -     * @return   this expression as String
  -     */
  -    protected String toString (String op) {
  -        return "(" +property + " " + op + " " + literal + ")";
  -    }
   }
   
  
  
  
  1.5       +10 -4     \
jakarta-slide/src/share/org/apache/slide/search/basic/BasicExpression.java  
  Index: BasicExpression.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/search/basic/BasicExpression.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- BasicExpression.java	28 Mar 2002 06:23:16 -0000	1.4
  +++ BasicExpression.java	28 Mar 2002 09:55:04 -0000	1.5
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/search/basic/BasicExpression.java,v \
                1.4 2002/03/28 06:23:16 jericho Exp $
  - * $Revision: 1.4 $
  - * $Date: 2002/03/28 06:23:16 $
  + * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/search/basic/BasicExpression.java,v \
1.5 2002/03/28 09:55:04 wam Exp $  + * $Revision: 1.5 $
  + * $Date: 2002/03/28 09:55:04 $
    *
    * ====================================================================
    *
  @@ -81,7 +81,7 @@
    *
    *
    * @author <a href="mailto:martin.wallmer@softwareag.com">Martin Wallmer</a>
  - * @version $Revision: 1.4 $
  + * @version $Revision: 1.5 $
    */
   public abstract class BasicExpression {
       
  @@ -144,8 +144,14 @@
               else if (name.equals (Literals.EQ))
                   result = new EQExpression (e);
                   
  +            else if (name.equals (Literals.CONTAINS))
  +                result = new ContainsExpression (e);
  +                
               else if (name.equals (Literals.ISCOLLECTION))
                   result = new IsCollectionExpression (e);
  +                
  +            else if (name.equals (Literals.ISPRINCIPAL))
  +                result = new IsPrincipalExpression (e);
                   
               else if (name.equals (Literals.ISDEFINED))
                   result = new IsDefinedExpression (e);
  
  
  
  1.1                  \
jakarta-slide/src/share/org/apache/slide/search/basic/IsPrincipalExpression.java  
  Index: IsPrincipalExpression.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/search/basic/IsPrincipalExpression.java,v \
                1.1 2002/03/28 09:55:04 wam Exp $
   * $Revision: 1.1 $
   * $Date: 2002/03/28 09:55:04 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * [Additional notices, if required by prior licensing conditions]
   *
   */
  
  
  package org.apache.slide.search.basic;
  
  import org.jdom.Element;
  import org.apache.slide.search.InvalidQueryException;
  
  /**
   * Represents an is-principal expression. is-principal is an extension to DASL,
   * usefull for SECURITY issues.
   *
   * @author <a href="mailto:martin.wallmer@softwareag.com">Martin Wallmer</a>
   * @version $Revision: 1.1 $
   */
  public class IsPrincipalExpression extends CheckResourceTypeExpression {
      
      /**
       * Creates an is-principal expression
       *
       * @param e jdom element, that describes the expression
       *
       */
      protected IsPrincipalExpression (Element e) throws InvalidQueryException {
          super (e);
          literal = "principal";
      }
         
      /**
       * For debugging purpose.
       *
       * @return   This expression as string
       *
       */
      public String toString () {
          return (Literals.ISPRINCIPAL);
      }
  }
  
  
  
  
  1.1                  \
jakarta-slide/src/share/org/apache/slide/search/basic/ContainsExpression.java  
  Index: ContainsExpression.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/search/basic/ContainsExpression.java,v \
                1.1 2002/03/28 09:55:04 wam Exp $
   * $Revision: 1.1 $
   * $Date: 2002/03/28 09:55:04 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Slide", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * [Additional notices, if required by prior licensing conditions]
   *
   */
  
  
  package org.apache.slide.search.basic;
  import org.apache.slide.search.*;
  
  import org.jdom.Element;
  import org.apache.slide.search.InvalidQueryException;
  import java.util.Set;
  import java.util.Iterator;
  
  /**
   * Represents a CONTAINS expression.
   *
   * @author <a href="mailto:martin.wallmer@softwareag.com">Martin Wallmer</a>
   * @version $Revision: 1.1 $
   */
  public class ContainsExpression extends CompareExpression {
      
      private String searchedText;
      
      /**
       * Creates a CONTAINS expression according to Element e
       *
       * @param e jdom element, that describes the expression
       *
       */
      protected ContainsExpression (Element e) throws InvalidQueryException {
          super (e);
          searchedText = e.getTextTrim();
      }
         
      /**
       * Checks if the content of item contains searchedText
       *
       * @param    item                the reuquestedResource to be searched
       *
       * @return   a boolean
       *
       */
      protected boolean compare (RequestedResource item) {
          return item.contains (searchedText) == Literals.TRUE;
      }
      
  
      /**
       * For debugging purpose.
       *
       * @return   This expression as string
       *
       */
      public String toString () {
          return (Literals.CONTAINS + " (" + searchedText + ")");
      }
  }
  
  
  
  
  1.1                  \
jakarta-slide/src/share/org/apache/slide/search/basic/ComparePropertyExpression.java  \
  Index: ComparePropertyExpression.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/search/basic/ComparePropertyExpression.java,v \
                1.1 2002/03/28 09:55:04 wam Exp $
   * $Revision: 1.1 $
   * $Date: 2002/03/28 09:55:04 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Slide", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * [Additional notices, if required by prior licensing conditions]
   *
   */
  
  package org.apache.slide.search.basic;
  import org.apache.slide.search.*;
  
  import java.util.Iterator;
  import java.util.Set;
  import java.util.List;
  import java.util.ArrayList;
  import org.jdom.Namespace;
  import org.jdom.Element;
  
  import org.apache.slide.search.InvalidQueryException;
  
  /**
   * Abstract base class for compare expressions (GT, EQ, is-collection ...).
   *
   * @author <a href="mailto:martin.wallmer@softwareag.com">Martin Wallmer</a>
   * @version $Revision: 1.1 $
   */
  public abstract class ComparePropertyExpression extends CompareExpression {
      
      /** the property's value <literal> */
      protected String literal;
  
      /** the property name <prop> */
      protected String property;
      
      /**
       * dummy constructor, called by is-collection (as no prop / literal
       * is passed).
       */
      ComparePropertyExpression () {}
      
      /**
       * Creates a compare expression according to Element e
       *
       * @param e jdom element, that describes the expression
       *
       */
      ComparePropertyExpression (Element e) throws InvalidQueryException {
          super (e);
          property = getPropName(e);
          literal  = getLiteral (e);
      }
      
      /**
       * extracts the property name of this expression
       *
       * @param    e                   an Expression
       *
       * @return   the property name as string
       *
       * @throws   InvalidQueryException if no or more than one
       *           property was supplied
       *
       */
      protected String getPropName(Element e) throws InvalidQueryException {
          Element propListElement = e.getChild (Literals.PROP, e.getNamespace());
          if (propListElement == null)
              throw new InvalidQueryException
                  ("No property element supplied");
          
          List propList = propListElement.getChildren();
          
          if (propList.size() != 1)
              throw new InvalidQueryException
                  ("Expected exactly 1 prop element, found " + propList.size());
          
          
          return ((Element)propList.get(0)).getName();
      }
      
      /**
       * The concrete CompareExpression must overwrite this.
       *
       * @param    item    one BasicDataItem out of pool
       *
       * @return   a boolean
       *
       */
      protected abstract boolean compare (RequestedResource item);
      
      /**
       * String representation for debugging purposes.
       *
       * @return   this expression as String
       */
      protected String toString (String op) {
          return "(" +property + " " + op + " " + literal + ")";
      }
      
      /**
       * extracs the value of <literal> of an expression
       *
       * @param    e                   an Expression
       *
       * @return   the literal as string
       *
       * @throws   InvalidQueryException if no <literal> found in e
       *
       */
      protected String  getLiteral(Element e) throws InvalidQueryException {
          Element lit = e.getChild (Literals.LITERAL, e.getNamespace());
          if (lit == null)
              throw new InvalidQueryException
                  ("No literal element supplied");
          
          return lit.getText ();
      }
  }
  
  
  
  
  1.1                  \
jakarta-slide/src/share/org/apache/slide/search/basic/CheckResourceTypeExpression.java
  
  Index: CheckResourceTypeExpression.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/search/basic/CheckResourceTypeExpression.java,v \
                1.1 2002/03/28 09:55:04 wam Exp $
   * $Revision: 1.1 $
   * $Date: 2002/03/28 09:55:04 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Slide", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * [Additional notices, if required by prior licensing conditions]
   *
   */
  
  
  package org.apache.slide.search.basic;
  import org.apache.slide.search.*;
  
  import org.jdom.Element;
  import org.apache.slide.search.InvalidQueryException;
  import java.util.Set;
  
  /**
   * Represents an expression that check for a specific resourcetype.
   *
   * @author <a href="mailto:martin.wallmer@softwareag.com">Martin Wallmer</a>
   * @version $Revision: 1.1 $
   */
  public abstract class CheckResourceTypeExpression extends ComparePropertyExpression \
{  
      /**
       * Creates an is-collection expression
       *
       * @param e jdom element, that describes the expression
       *
       */
      protected CheckResourceTypeExpression (Element e) throws InvalidQueryException \
{  this.expressionElement = e;
          property = Literals.RESOURCETYPE;
      }
         
      /**
       * checks, if the value of resourcetype contains the specified literal
       *
       * @param    item                a  BasicDataItem
       *
       * @return   true, if item is a collection
       *
       */
      protected boolean compare (RequestedResource item) {
          String  resourceTypeValue =
              (String) item.getThisValue (property);
          
          int index = resourceTypeValue.indexOf (literal);
          
          return index > -1;
      }
  }
  
  
  
  
  

--
To unsubscribe, e-mail:   <mailto:slide-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:slide-dev-help@jakarta.apache.org>


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic