You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by se...@apache.org on 2007/04/22 00:24:47 UTC
svn commit: r531120 -
/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/subtree/BaseSubtreeSpecification.java
Author: seelmann
Date: Sat Apr 21 15:24:41 2007
New Revision: 531120
URL: http://svn.apache.org/viewvc?view=rev&rev=531120
Log:
Modified printToBuffer method to print the ExprNode either as refinement or as LDAP filter.
Modified:
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/subtree/BaseSubtreeSpecification.java
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/subtree/BaseSubtreeSpecification.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/subtree/BaseSubtreeSpecification.java?view=diff&rev=531120&r1=531119&r2=531120
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/subtree/BaseSubtreeSpecification.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/subtree/BaseSubtreeSpecification.java Sat Apr 21 15:24:41 2007
@@ -6,16 +6,16 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
- *
+ * under the License.
+ *
*/
package org.apache.directory.shared.ldap.subtree;
@@ -30,7 +30,7 @@
/**
* A simple implementation of the SubtreeSpecification interface.
- *
+ *
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
@@ -87,7 +87,7 @@
* Creates a simple subtree refinement whose administrative point is
* necessarily the base and only those subordinates selected by the
* refinement filter are included.
- *
+ *
* @param refinement
* the filter expression only composed of objectClass attribute
* value assertions
@@ -112,7 +112,7 @@
* Creates a simple subtree whose administrative point above the base and
* all subordinates underneath the base (excluding those that are part of
* inner areas) are part of the the subtree.
- *
+ *
* @param base
* the base of the subtree relative to the administrative point
*/
@@ -135,7 +135,7 @@
/**
* Creates a subtree without a refinement filter where all other aspects can
* be varied.
- *
+ *
* @param base
* the base of the subtree relative to the administrative point
* @param minBaseDistance
@@ -159,7 +159,7 @@
* Creates a subtree which may be a refinement filter where all aspects of
* the specification can be set. If the refinement filter is null this
* defaults to {@link #BaseSubtreeSpecification(LdapDN, int, int, Set, Set)}.
- *
+ *
* @param base
* the base of the subtree relative to the administrative point
* @param minBaseDistance
@@ -239,7 +239,7 @@
return this.refinement;
}
-
+
/**
* Converts this item into its string representation as stored
* in directory.
@@ -249,7 +249,7 @@
public void printToBuffer( StringBuffer buffer )
{
buffer.append( '{' );
-
+
if(!base.isEmpty()) {
buffer.append( ' ' );
buffer.append( "base" );
@@ -259,7 +259,7 @@
buffer.append( '"' );
buffer.append( ',' );
}
-
+
if(minBaseDistance > 0) {
buffer.append( ' ' );
buffer.append( "minimum" );
@@ -267,7 +267,7 @@
buffer.append( minBaseDistance );
buffer.append( ',' );
}
-
+
if(maxBaseDistance > UNBOUNDED_MAX) {
buffer.append( ' ' );
buffer.append( "maximum" );
@@ -275,8 +275,8 @@
buffer.append( maxBaseDistance );
buffer.append( ',' );
}
-
- if ( !chopBefore.isEmpty() || !chopAfter.isEmpty() )
+
+ if ( !chopBefore.isEmpty() || !chopAfter.isEmpty() )
{
buffer.append( ' ' );
buffer.append( "specificExclusions" );
@@ -293,20 +293,20 @@
buffer.append( '"' );
buffer.append( dn.getUpName() );
buffer.append( '"' );
-
+
if(it.hasNext())
{
buffer.append( ',' );
buffer.append( ' ' );
}
}
-
+
if ( !chopBefore.isEmpty() && !chopAfter.isEmpty() )
{
buffer.append( ',' );
buffer.append( ' ' );
}
-
+
for ( Iterator it = chopAfter.iterator(); it.hasNext(); )
{
LdapDN dn = ( LdapDN ) it.next();
@@ -317,36 +317,49 @@
buffer.append( '"' );
buffer.append( dn.getUpName() );
buffer.append( '"' );
-
+
if(it.hasNext())
{
buffer.append( ',' );
buffer.append( ' ' );
}
}
-
+
buffer.append( ' ' );
buffer.append( '}' );
-
+
buffer.append( ',' );
}
-
- if(refinement != null)
+
+ if ( refinement != null )
{
buffer.append( ' ' );
buffer.append( "specificationFilter" );
buffer.append( ' ' );
- refinement.printRefinementToBuffer( buffer );
+
+ // The ExprNode could represent both, a refinement
+ // or a filter. First we try to print the ExprNode
+ // as refinement. If that fails it is printed as
+ // LDAP filter.
+ try
+ {
+ refinement.printRefinementToBuffer( buffer );
+ }
+ catch ( UnsupportedOperationException e )
+ {
+ refinement.printToBuffer( buffer );
+ }
+
buffer.append( ',' );
}
-
+
if(buffer.charAt( buffer.length()-1 ) == ',') {
buffer.deleteCharAt( buffer.length()-1 );
}
-
+
buffer.append( ' ' );
buffer.append( '}' );
}
-
+
}