directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r225421 - /directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/filters/
Date Tue, 26 Jul 2005 23:40:20 GMT
Author: elecharny
Date: Tue Jul 26 16:40:14 2005
New Revision: 225421

URL: http://svn.apache.org/viewcvs?rev=225421&view=rev
Log:
Added the computeLength() methods

Modified:
    directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/filters/AndFilter.java
    directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/filters/AttributeValueAssertionFilter.java
    directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/filters/ConnectorFilter.java
    directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/filters/ExtensibleMatchFilter.java
    directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/filters/NotFilter.java
    directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/filters/OrFilter.java
    directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/filters/PresentFilter.java
    directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/filters/SubstringFilter.java

Modified: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/filters/AndFilter.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/filters/AndFilter.java?rev=225421&r1=225420&r2=225421&view=diff
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/filters/AndFilter.java
(original)
+++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/filters/AndFilter.java
Tue Jul 26 16:40:14 2005
@@ -18,6 +18,8 @@
 
 import java.util.ArrayList;
 
+import org.apache.asn1.ber.tlv.Length;
+
 /**
  * And Filter Object to store the And filter.
  * 
@@ -43,6 +45,23 @@
     public ArrayList getAndFilter()
     {
         return filterSet;
+    }
+    
+    /**
+     * Compute the AndFilter length
+     * 
+     * AndFilter :
+     * 
+     * 0xA0 L1 super.computeLength()
+     * 
+     * Length(AndFilter) = Length(0xA0) + Length(super.computeLength()) + super.computeLength()
+     * 
+     */
+    public int computeLength()
+    {
+        int filtersLength = super.computeLength();
+        
+        return 1 + Length.getNbBytes( filtersLength ) + filtersLength;
     }
     
     /**

Modified: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/filters/AttributeValueAssertionFilter.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/filters/AttributeValueAssertionFilter.java?rev=225421&r1=225420&r2=225421&view=diff
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/filters/AttributeValueAssertionFilter.java
(original)
+++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/filters/AttributeValueAssertionFilter.java
Tue Jul 26 16:40:14 2005
@@ -16,6 +16,7 @@
  */
 package org.apache.asn1.ldap.pojo.filters;
 
+import org.apache.asn1.ber.tlv.Length;
 import org.apache.asn1.ldap.pojo.AttributeValueAssertion;
 
 
@@ -87,6 +88,41 @@
         this.filterType = filterType;
     }
 
+    /**
+     * Compute the AttributeValueFilter length
+     * 
+     * AttributeValueFilter :
+     * 
+     * 0xA(3, 5, 6, 8) L1
+     *  |
+     *  +--> 0x04 L2 attributeDesc
+     *  +--> 0x04 L3 assertionValue
+     *  
+     * 
+     * L2 = Length(attributeDesc)
+     * L3 = Length(assertionValue)
+     * L1 = 1 + Length(L2) + L2 
+     *      + 1 + Length(L3) + L3
+     * 
+     * Length(AttributeValueFilter) = Length(0xA?) + Length(L1)
+     *                                + 1 + Length(L2) + L2 
+     *                                + 1 + Length(L3) + L3 
+     * 
+     */
+    public int computeLength()
+    {
+        int avaLength = 0;
+        int attributeDescLength = assertion.getAttributeDesc().length();
+        
+        avaLength = 1 + Length.getNbBytes( attributeDescLength ) + attributeDescLength;
+        
+        int assertionValueLength = assertion.getAssertionValue().getLength();
+        
+        avaLength += 1 + Length.getNbBytes( assertionValueLength ) + assertionValueLength;
+        
+        return 1 + Length.getNbBytes( avaLength ) + avaLength;
+    }
+    
     /**
      * Return a string compliant with RFC 2254 representing an item filter
      *

Modified: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/filters/ConnectorFilter.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/filters/ConnectorFilter.java?rev=225421&r1=225420&r2=225421&view=diff
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/filters/ConnectorFilter.java
(original)
+++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/filters/ConnectorFilter.java
Tue Jul 26 16:40:14 2005
@@ -72,6 +72,31 @@
     }
 
     /**
+     * Compute the ConnectorFilter length
+     * 
+     * Length(ConnectorFilter) = sum(filterSet.computeLength())
+     * 
+     */
+    public int computeLength()
+    {
+        int connectorFilterLength = 0;
+        
+        if ( ( filterSet != null ) && ( filterSet.size() != 0 ) )
+        {
+            Iterator filterIterator = filterSet.iterator();
+            
+            while ( filterIterator.hasNext() )
+            {
+                Filter filter = (Filter)filterIterator.next();
+                
+                connectorFilterLength += filter.computeLength();
+            }
+        }
+        
+        return connectorFilterLength;
+    }
+
+    /**
      * Return a string compliant with RFC 2254 representing a composite
      * filter, one of AND, OR and NOT
      *

Modified: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/filters/ExtensibleMatchFilter.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/filters/ExtensibleMatchFilter.java?rev=225421&r1=225420&r2=225421&view=diff
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/filters/ExtensibleMatchFilter.java
(original)
+++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/filters/ExtensibleMatchFilter.java
Tue Jul 26 16:40:14 2005
@@ -16,6 +16,7 @@
  */
 package org.apache.asn1.ldap.pojo.filters;
 
+import org.apache.asn1.ber.tlv.Length;
 import org.apache.asn1.ldap.codec.primitives.LdapString;
 import org.apache.asn1.primitives.OctetString;
 
@@ -158,6 +159,51 @@
         this.expectedMatchingRuleLength = expectedMatchingRuleLength;
     }
 
+    /**
+     * Compute the ExtensibleMatchFilter length
+     * 
+     * ExtensibleMatchFilter :
+     * 
+     * 0xA9 L1
+     *  |
+     *  +--> 0x30 L2
+     *        |
+     *       [+--> 0x81 L3 matchingRule]
+     *       [+--> 0x82 L4 type]
+     *       [+--> 0x83 L5 matchValue]
+     *       [+--> 0x01 0x01 dnAttributes]
+     *  
+     */
+    public int computeLength()
+    {
+        // The type
+        int extensibleMatchLength = 0;
+        
+        if ( matchingRule != null )
+        {
+            extensibleMatchLength += 1 + Length.getNbBytes( matchingRule.getLength() ) +
matchingRule.getLength(); 
+        }
+        
+        if ( type != null )
+        {
+            extensibleMatchLength += 1 + Length.getNbBytes( type.getLength() ) + type.getLength();

+        }
+        
+        if ( matchValue != null )
+        {
+            extensibleMatchLength += 1 + Length.getNbBytes( matchValue.getLength() ) + matchValue.getLength();

+        }
+        
+        if ( dnAttributes == true )
+        {
+            extensibleMatchLength += 1 + 1 + 1;
+        }
+
+        extensibleMatchLength += 1 + Length.getNbBytes( extensibleMatchLength );
+        
+        return 1 + Length.getNbBytes( extensibleMatchLength ) + extensibleMatchLength;
+    }
+    
     /**
      * Return a String representing an extended filter as of RFC 2254
      *

Modified: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/filters/NotFilter.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/filters/NotFilter.java?rev=225421&r1=225420&r2=225421&view=diff
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/filters/NotFilter.java
(original)
+++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/filters/NotFilter.java
Tue Jul 26 16:40:14 2005
@@ -17,6 +17,7 @@
 package org.apache.asn1.ldap.pojo.filters;
 
 import org.apache.asn1.DecoderException;
+import org.apache.asn1.ber.tlv.Length;
 
 /**
  * Not Filter Object to store the Not filter.
@@ -74,6 +75,23 @@
         super.addFilter( notFilter );
     }
     
+    /**
+     * Compute the NotFilter length
+     * 
+     * NotFilter :
+     * 
+     * 0xA2 L1 super.computeLength()
+     * 
+     * Length(NotFilter) = Length(0xA2) + Length(super.computeLength()) + super.computeLength()
+     * 
+     */
+    public int computeLength()
+    {
+        int filtersLength = super.computeLength();
+        
+        return 1 + Length.getNbBytes( filtersLength ) + filtersLength;
+    }
+
     /**
      * Return a string compliant with RFC 2254 representing a NOT filter
      *

Modified: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/filters/OrFilter.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/filters/OrFilter.java?rev=225421&r1=225420&r2=225421&view=diff
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/filters/OrFilter.java
(original)
+++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/filters/OrFilter.java
Tue Jul 26 16:40:14 2005
@@ -18,6 +18,8 @@
 
 import java.util.ArrayList;
 
+import org.apache.asn1.ber.tlv.Length;
+
 
 /**
  * Or Filter Object to store the Or filter.
@@ -47,6 +49,23 @@
         return filterSet;
     }
 
+    /**
+     * Compute the OrFilter length
+     * 
+     * OrFilter :
+     * 
+     * 0xA1 L1 super.computeLength()
+     * 
+     * Length(OrFilter) = Length(0xA1) + Length(super.computeLength()) + super.computeLength()
+     * 
+     */
+    public int computeLength()
+    {
+        int filtersLength = super.computeLength();
+        
+        return 1 + Length.getNbBytes( filtersLength ) + filtersLength;
+    }
+    
     /**
      * Return a string compliant with RFC 2254 representing an OR filter
      *

Modified: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/filters/PresentFilter.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/filters/PresentFilter.java?rev=225421&r1=225420&r2=225421&view=diff
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/filters/PresentFilter.java
(original)
+++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/filters/PresentFilter.java
Tue Jul 26 16:40:14 2005
@@ -16,6 +16,7 @@
  */
 package org.apache.asn1.ldap.pojo.filters;
 
+import org.apache.asn1.ber.tlv.Length;
 import org.apache.asn1.ldap.codec.primitives.LdapString;
 
 
@@ -62,6 +63,21 @@
         this.attributeDescription = attributeDescription;
     }
 
+    /**
+     * Compute the PresentFilter length
+     * 
+     * PresentFilter :
+     * 
+     * 0x87 L1 present
+     * 
+     * Length(PresentFilter) = Length(0x87) + Length(super.computeLength()) + super.computeLength()
+     * 
+     */
+    public int computeLength()
+    {
+        return 1 + Length.getNbBytes( attributeDescription.getLength() ) + attributeDescription.getLength();
+    }
+    
     /**
      * Return a string compliant with RFC 2254 representing a Present filter
      *

Modified: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/filters/SubstringFilter.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/filters/SubstringFilter.java?rev=225421&r1=225420&r2=225421&view=diff
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/filters/SubstringFilter.java
(original)
+++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/filters/SubstringFilter.java
Tue Jul 26 16:40:14 2005
@@ -19,6 +19,7 @@
 import java.util.ArrayList;
 import java.util.Iterator;
 
+import org.apache.asn1.ber.tlv.Length;
 import org.apache.asn1.ldap.codec.primitives.LdapString;
 
 
@@ -156,6 +157,57 @@
     public void setSubstringsLength(int substringsLength) 
     {
         this.substringsLength = substringsLength;
+    }
+    
+    /**
+     * Compute the SubstringFilter length
+     * 
+     * SubstringFilter :
+     * 
+     * 0xA4 L1
+     *  |
+     *  +--> 0x04 L2 type
+     *  +--> 0x30 L3
+     *        |
+     *       [+--> 0x80 L4 initial]
+     *       [+--> 0x81 L5-1 any]
+     *       [+--> 0x81 L5-2 any]
+     *       [+--> ... 
+     *       [+--> 0x81 L5-i any]
+     *       [+--> ... 
+     *       [+--> 0x81 L5-n any]
+     *       [+--> 0x82 L6 final]
+     *  
+     */
+    public int computeLength()
+    {
+        // The type
+        int substringsFilterLength = 1 + Length.getNbBytes( type.getLength() ) + type.getLength();
+        
+        if ( initialSubstrings != null )
+        {
+            substringsFilterLength += 1 + Length.getNbBytes( initialSubstrings.getLength()
) + initialSubstrings.getLength(); 
+        }
+        
+        if ( anySubstrings != null)
+        {
+            Iterator anyIterator = anySubstrings.iterator();
+            
+            while ( anyIterator.hasNext() )
+            {
+                LdapString any = (LdapString)anyIterator.next();
+                substringsFilterLength += 1 + Length.getNbBytes( any.getLength() ) + any.getLength();
+            }
+        }
+        
+        if ( finalSubstrings != null )
+        {
+            substringsFilterLength += 1 + Length.getNbBytes( finalSubstrings.getLength()
) + finalSubstrings.getLength(); 
+        }
+        
+        substringsFilterLength += 1 + Length.getNbBytes( substringsFilterLength );
+        
+        return 1 + Length.getNbBytes( substringsFilterLength ) + substringsFilterLength;
     }
     
     /**



Mime
View raw message