You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by er...@apache.org on 2007/01/07 16:09:19 UTC
svn commit: r493734 - in /directory/trunks/shared/ldap/src:
main/antlr/SubtreeSpecificationChecker.g
test/java/org/apache/directory/shared/ldap/schema/syntax/SubtreeSpecificationSyntaxCheckerTest.java
Author: ersiner
Date: Sun Jan 7 07:09:19 2007
New Revision: 493734
URL: http://svn.apache.org/viewvc?view=rev&rev=493734
Log:
Updated SubtreeSpecification Syntax Checker so that it allows Filters as specificationFilter.
Modified:
directory/trunks/shared/ldap/src/main/antlr/SubtreeSpecificationChecker.g
directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/SubtreeSpecificationSyntaxCheckerTest.java
Modified: directory/trunks/shared/ldap/src/main/antlr/SubtreeSpecificationChecker.g
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/antlr/SubtreeSpecificationChecker.g?view=diff&rev=493734&r1=493733&r2=493734
==============================================================================
--- directory/trunks/shared/ldap/src/main/antlr/SubtreeSpecificationChecker.g (original)
+++ directory/trunks/shared/ldap/src/main/antlr/SubtreeSpecificationChecker.g Sun Jan 7 07:09:19 2007
@@ -30,6 +30,7 @@
import org.apache.directory.shared.ldap.name.LdapDN;
import org.apache.directory.shared.ldap.filter.AssertionEnum;
+import org.apache.directory.shared.ldap.filter.FilterParserImpl;
import org.apache.directory.shared.ldap.util.ComponentsMonitor;
import org.apache.directory.shared.ldap.util.OptionalComponentsMonitor;
@@ -71,6 +72,8 @@
private static final Logger log = LoggerFactory.getLogger( AntlrSubtreeSpecificationChecker.class );
private ComponentsMonitor subtreeSpecificationComponentsMonitor = null;
+
+ private final FilterParserImpl filterParser = new FilterParserImpl();
/**
* Does nothing.
@@ -229,9 +232,30 @@
log.debug( "entered ss_specificationFilter()" );
}
:
- ID_specificationFilter ( SP )+ refinement
+ ID_specificationFilter
+ ( SP )+
+ (
+ ( refinement )
+ |
+ ( filter )
+ )
;
+
+filter
+{
+ log.debug( "entered filter()" );
+}
+ :
+ ( filterToken:FILTER { filterParser.parse( filterToken.getText() ); } )
+ ;
+ exception
+ catch [Exception e]
+ {
+ throw new RecognitionException( "filterParser failed. " + e.getMessage() );
+ }
+
+
distinguishedName
{
log.debug( "entered distinguishedName()" );
@@ -434,3 +458,7 @@
'\u3400'..'\u3d2d' |
'\u4e00'..'\u9fff' |
'\uf900'..'\ufaff' ;
+
+FILTER : '(' ( ( '&' (FILTER)+ ) | ( '|' (FILTER)+ ) | ( '!' FILTER ) | FILTER_VALUE ) ')' ;
+
+protected FILTER_VALUE : (options{greedy=true;}: ~( ')' | '(' | '&' | '|' | '!' ) ( ~(')') )* ) ;
Modified: directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/SubtreeSpecificationSyntaxCheckerTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/SubtreeSpecificationSyntaxCheckerTest.java?view=diff&rev=493734&r1=493733&r2=493734
==============================================================================
--- directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/SubtreeSpecificationSyntaxCheckerTest.java (original)
+++ directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/SubtreeSpecificationSyntaxCheckerTest.java Sun Jan 7 07:09:19 2007
@@ -99,6 +99,9 @@
/** An invalid specification with completely unrelated content */
private static final String INVALID_SILLY_THING = "How much wood would a wood chuck chuck if a wood chuck would chuck wood?";
+ /** A valid specification with filter expression */
+ private static final String SPEC_WITH_FILTER = "{ base \"ou=system\", specificationFilter (&(cn=test)(sn=test)) }";
+
/**
* Tests the parser with a valid empty specification.
*/
@@ -227,5 +230,14 @@
public void testBadAssertion() throws Exception
{
assertFalse( checker.isValidSyntax( INVALID_SILLY_THING ) );
+ }
+
+
+ /**
+ * Tests the parser with a valid specification with refinement set.
+ */
+ public void testSpecWithFilter() throws Exception
+ {
+ assertTrue( checker.isValidSyntax( SPEC_WITH_FILTER ) );
}
}