Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 6716 invoked from network); 5 Nov 2007 09:37:12 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 5 Nov 2007 09:37:12 -0000 Received: (qmail 83712 invoked by uid 500); 5 Nov 2007 09:36:59 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 83623 invoked by uid 500); 5 Nov 2007 09:36:59 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 83614 invoked by uid 99); 5 Nov 2007 09:36:59 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Nov 2007 01:36:59 -0800 X-ASF-Spam-Status: No, hits=-98.5 required=10.0 tests=ALL_TRUSTED,WEIRD_PORT,WHOIS_NETSOLPR X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Nov 2007 09:37:04 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id BCAD81A983E; Mon, 5 Nov 2007 01:36:43 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r591934 [2/2] - in /harmony/enhanced/classlib/trunk/modules/jndi/src: main/java/org/apache/harmony/jndi/provider/ldap/parser/ test/java/org/apache/harmony/jndi/provider/ldap/parser/ test/resources/parser/ Date: Mon, 05 Nov 2007 09:36:37 -0000 To: commits@harmony.apache.org From: leoli@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071105093643.BCAD81A983E@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Added: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/LdapUrlParserTokenManager.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/LdapUrlParserTokenManager.java?rev=591934&view=auto ============================================================================== --- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/LdapUrlParserTokenManager.java (added) +++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/LdapUrlParserTokenManager.java Mon Nov 5 01:36:36 2007 @@ -0,0 +1,459 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file 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. + */ +/* Generated By:JavaCC: Do not edit this line. LdapUrlParserTokenManager.java */ + +package org.apache.harmony.jndi.provider.ldap.parser; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.util.ArrayList; +import java.util.List; +import java.io.StringReader; +import javax.naming.directory.SearchControls; +import org.apache.harmony.jndi.provider.ldap.Filter; +import org.apache.harmony.jndi.provider.ldap.asn1.Utils; + +public class LdapUrlParserTokenManager implements LdapUrlParserConstants +{ + public java.io.PrintStream debugStream = System.out; + public void setDebugStream(java.io.PrintStream ds) { debugStream = ds; } +private final int jjStopStringLiteralDfa_0(int pos, long active0) +{ + switch (pos) + { + default : + return -1; + } +} +private final int jjStartNfa_0(int pos, long active0) +{ + return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0), pos + 1); +} +private final int jjStopAtPos(int pos, int kind) +{ + jjmatchedKind = kind; + jjmatchedPos = pos; + return pos + 1; +} +private final int jjStartNfaWithStates_0(int pos, int kind, int state) +{ + jjmatchedKind = kind; + jjmatchedPos = pos; + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { return pos + 1; } + return jjMoveNfa_0(state, pos + 1); +} +private final int jjMoveStringLiteralDfa0_0() +{ + switch(curChar) + { + case 10: + return jjStopAtPos(0, 17); + case 33: + return jjStopAtPos(0, 10); + case 37: + return jjStopAtPos(0, 7); + case 44: + return jjStopAtPos(0, 4); + case 46: + return jjStopAtPos(0, 9); + case 47: + return jjStopAtPos(0, 6); + case 48: + return jjStopAtPos(0, 15); + case 58: + return jjStopAtPos(0, 8); + case 61: + return jjStopAtPos(0, 11); + case 63: + return jjStopAtPos(0, 5); + default : + return jjMoveNfa_0(1, 0); + } +} +private final void jjCheckNAdd(int state) +{ + if (jjrounds[state] != jjround) + { + jjstateSet[jjnewStateCnt++] = state; + jjrounds[state] = jjround; + } +} +private final void jjAddStates(int start, int end) +{ + do { + jjstateSet[jjnewStateCnt++] = jjnextStates[start]; + } while (start++ != end); +} +private final void jjCheckNAddTwoStates(int state1, int state2) +{ + jjCheckNAdd(state1); + jjCheckNAdd(state2); +} +private final void jjCheckNAddStates(int start, int end) +{ + do { + jjCheckNAdd(jjnextStates[start]); + } while (start++ != end); +} +private final void jjCheckNAddStates(int start) +{ + jjCheckNAdd(jjnextStates[start]); + jjCheckNAdd(jjnextStates[start + 1]); +} +static final long[] jjbitVec0 = { + 0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL +}; +private final int jjMoveNfa_0(int startState, int curPos) +{ + int[] nextStates; + int startsAt = 0; + jjnewStateCnt = 29; + int i = 1; + jjstateSet[0] = startState; + int j, kind = 0x7fffffff; + for (;;) + { + if (++jjround == 0x7fffffff) + ReInitRounds(); + if (curChar < 64) + { + long l = 1L << curChar; + MatchLoop: do + { + switch(jjstateSet[--i]) + { + case 1: + if ((0x7fff7ffffffffbffL & l) != 0L) + { + if (kind > 16) + kind = 16; + } + if ((0x3fe000000000000L & l) != 0L) + { + if (kind > 14) + kind = 14; + } + break; + case 0: + if (curChar == 45 && kind > 2) + kind = 2; + break; + case 14: + if ((0x3fe000000000000L & l) != 0L && kind > 14) + kind = 14; + break; + case 15: + if ((0x7fff7ffffffffbffL & l) != 0L && kind > 16) + kind = 16; + break; + case 17: + if (curChar == 47 && kind > 1) + kind = 1; + break; + case 18: + case 23: + if (curChar == 47) + jjCheckNAdd(17); + break; + case 19: + if (curChar == 58) + jjstateSet[jjnewStateCnt++] = 18; + break; + case 24: + if (curChar == 58) + jjstateSet[jjnewStateCnt++] = 23; + break; + default : break; + } + } while(i != startsAt); + } + else if (curChar < 128) + { + long l = 1L << (curChar & 077); + MatchLoop: do + { + switch(jjstateSet[--i]) + { + case 1: + if (kind > 16) + kind = 16; + if ((0x7ffff8007ffff80L & l) != 0L) + { + if (kind > 13) + kind = 13; + } + else if ((0x7e0000007eL & l) != 0L) + { + if (kind > 12) + kind = 12; + } + if (curChar == 108) + jjAddStates(0, 1); + else if (curChar == 115) + jjstateSet[jjnewStateCnt++] = 10; + else if (curChar == 111) + jjstateSet[jjnewStateCnt++] = 7; + else if (curChar == 98) + jjstateSet[jjnewStateCnt++] = 5; + else if (curChar == 120) + jjCheckNAdd(0); + else if (curChar == 88) + jjCheckNAdd(0); + break; + case 2: + if (curChar == 120) + jjCheckNAdd(0); + break; + case 3: + if (curChar == 101 && kind > 3) + kind = 3; + break; + case 4: + if (curChar == 115) + jjCheckNAdd(3); + break; + case 5: + if (curChar == 97) + jjstateSet[jjnewStateCnt++] = 4; + break; + case 6: + if (curChar == 98) + jjstateSet[jjnewStateCnt++] = 5; + break; + case 7: + if (curChar == 110) + jjCheckNAdd(3); + break; + case 8: + if (curChar == 111) + jjstateSet[jjnewStateCnt++] = 7; + break; + case 9: + if (curChar == 98 && kind > 3) + kind = 3; + break; + case 10: + if (curChar == 117) + jjstateSet[jjnewStateCnt++] = 9; + break; + case 11: + if (curChar == 115) + jjstateSet[jjnewStateCnt++] = 10; + break; + case 12: + if ((0x7e0000007eL & l) != 0L && kind > 12) + kind = 12; + break; + case 13: + if ((0x7ffff8007ffff80L & l) != 0L && kind > 13) + kind = 13; + break; + case 15: + if (kind > 16) + kind = 16; + break; + case 16: + if (curChar == 108) + jjAddStates(0, 1); + break; + case 20: + if (curChar == 112) + jjstateSet[jjnewStateCnt++] = 19; + break; + case 21: + if (curChar == 97) + jjstateSet[jjnewStateCnt++] = 20; + break; + case 22: + if (curChar == 100) + jjstateSet[jjnewStateCnt++] = 21; + break; + case 25: + if (curChar == 115) + jjstateSet[jjnewStateCnt++] = 24; + break; + case 26: + if (curChar == 112) + jjstateSet[jjnewStateCnt++] = 25; + break; + case 27: + if (curChar == 97) + jjstateSet[jjnewStateCnt++] = 26; + break; + case 28: + if (curChar == 100) + jjstateSet[jjnewStateCnt++] = 27; + break; + default : break; + } + } while(i != startsAt); + } + else + { + int i2 = (curChar & 0xff) >> 6; + long l2 = 1L << (curChar & 077); + MatchLoop: do + { + switch(jjstateSet[--i]) + { + case 1: + if ((jjbitVec0[i2] & l2) != 0L && kind > 16) + kind = 16; + break; + default : break; + } + } while(i != startsAt); + } + if (kind != 0x7fffffff) + { + jjmatchedKind = kind; + jjmatchedPos = curPos; + kind = 0x7fffffff; + } + ++curPos; + if ((i = jjnewStateCnt) == (startsAt = 29 - (jjnewStateCnt = startsAt))) + return curPos; + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { return curPos; } + } +} +static final int[] jjnextStates = { + 22, 28, +}; +public static final String[] jjstrLiteralImages = { +"", null, null, null, "\54", "\77", "\57", "\45", "\72", "\56", "\41", "\75", +null, null, null, "\60", null, "\12", }; +public static final String[] lexStateNames = { + "DEFAULT", +}; +protected SimpleCharStream input_stream; +private final int[] jjrounds = new int[29]; +private final int[] jjstateSet = new int[58]; +protected char curChar; +public LdapUrlParserTokenManager(SimpleCharStream stream) +{ + if (SimpleCharStream.staticFlag) + throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer."); + input_stream = stream; +} +public LdapUrlParserTokenManager(SimpleCharStream stream, int lexState) +{ + this(stream); + SwitchTo(lexState); +} +public void ReInit(SimpleCharStream stream) +{ + jjmatchedPos = jjnewStateCnt = 0; + curLexState = defaultLexState; + input_stream = stream; + ReInitRounds(); +} +private final void ReInitRounds() +{ + int i; + jjround = 0x80000001; + for (i = 29; i-- > 0;) + jjrounds[i] = 0x80000000; +} +public void ReInit(SimpleCharStream stream, int lexState) +{ + ReInit(stream); + SwitchTo(lexState); +} +public void SwitchTo(int lexState) +{ + if (lexState >= 1 || lexState < 0) + throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE); + else + curLexState = lexState; +} + +protected Token jjFillToken() +{ + Token t = Token.newToken(jjmatchedKind); + t.kind = jjmatchedKind; + String im = jjstrLiteralImages[jjmatchedKind]; + t.image = (im == null) ? input_stream.GetImage() : im; + t.beginLine = input_stream.getBeginLine(); + t.beginColumn = input_stream.getBeginColumn(); + t.endLine = input_stream.getEndLine(); + t.endColumn = input_stream.getEndColumn(); + return t; +} + +int curLexState = 0; +int defaultLexState = 0; +int jjnewStateCnt; +int jjround; +int jjmatchedPos; +int jjmatchedKind; + +public Token getNextToken() +{ + int kind; + Token specialToken = null; + Token matchedToken; + int curPos = 0; + + EOFLoop : + for (;;) + { + try + { + curChar = input_stream.BeginToken(); + } + catch(java.io.IOException e) + { + jjmatchedKind = 0; + matchedToken = jjFillToken(); + return matchedToken; + } + + jjmatchedKind = 0x7fffffff; + jjmatchedPos = 0; + curPos = jjMoveStringLiteralDfa0_0(); + if (jjmatchedKind != 0x7fffffff) + { + if (jjmatchedPos + 1 < curPos) + input_stream.backup(curPos - jjmatchedPos - 1); + matchedToken = jjFillToken(); + return matchedToken; + } + int error_line = input_stream.getEndLine(); + int error_column = input_stream.getEndColumn(); + String error_after = null; + boolean EOFSeen = false; + try { input_stream.readChar(); input_stream.backup(1); } + catch (java.io.IOException e1) { + EOFSeen = true; + error_after = curPos <= 1 ? "" : input_stream.GetImage(); + if (curChar == '\n' || curChar == '\r') { + error_line++; + error_column = 0; + } + else + error_column++; + } + if (!EOFSeen) { + input_stream.backup(1); + error_after = curPos <= 1 ? "" : input_stream.GetImage(); + } + throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR); + } +} + +} Propchange: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/LdapUrlParserTokenManager.java ------------------------------------------------------------------------------ svn:eol-style = native Added: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/ParseException.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/ParseException.java?rev=591934&view=auto ============================================================================== --- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/ParseException.java (added) +++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/ParseException.java Mon Nov 5 01:36:36 2007 @@ -0,0 +1,209 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file 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. + */ +/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 3.0 */ + +package org.apache.harmony.jndi.provider.ldap.parser; + +/** + * This exception is thrown when parse errors are encountered. + * You can explicitly create objects of this exception type by + * calling the method generateParseException in the generated + * parser. + * + * You can modify this class to customize your error reporting + * mechanisms so long as you retain the public fields. + */ +public class ParseException extends Exception { + + /** + * This constructor is used by the method "generateParseException" + * in the generated parser. Calling this constructor generates + * a new object of this type with the fields "currentToken", + * "expectedTokenSequences", and "tokenImage" set. The boolean + * flag "specialConstructor" is also set to true to indicate that + * this constructor was used to create this object. + * This constructor calls its super class with the empty string + * to force the "toString" method of parent class "Throwable" to + * print the error message in the form: + * ParseException: + */ + public ParseException(Token currentTokenVal, + int[][] expectedTokenSequencesVal, + String[] tokenImageVal + ) + { + super(""); + specialConstructor = true; + currentToken = currentTokenVal; + expectedTokenSequences = expectedTokenSequencesVal; + tokenImage = tokenImageVal; + } + + /** + * The following constructors are for use by you for whatever + * purpose you can think of. Constructing the exception in this + * manner makes the exception behave in the normal way - i.e., as + * documented in the class "Throwable". The fields "errorToken", + * "expectedTokenSequences", and "tokenImage" do not contain + * relevant information. The JavaCC generated code does not use + * these constructors. + */ + + public ParseException() { + super(); + specialConstructor = false; + } + + public ParseException(String message) { + super(message); + specialConstructor = false; + } + + /** + * This variable determines which constructor was used to create + * this object and thereby affects the semantics of the + * "getMessage" method (see below). + */ + protected boolean specialConstructor; + + /** + * This is the last token that has been consumed successfully. If + * this object has been created due to a parse error, the token + * followng this token will (therefore) be the first error token. + */ + public Token currentToken; + + /** + * Each entry in this array is an array of integers. Each array + * of integers represents a sequence of tokens (by their ordinal + * values) that is expected at this point of the parse. + */ + public int[][] expectedTokenSequences; + + /** + * This is a reference to the "tokenImage" array of the generated + * parser within which the parse error occurred. This array is + * defined in the generated ...Constants interface. + */ + public String[] tokenImage; + + /** + * This method has the standard behavior when this object has been + * created using the standard constructors. Otherwise, it uses + * "currentToken" and "expectedTokenSequences" to generate a parse + * error message and returns it. If this object has been created + * due to a parse error, and you do not catch it (it gets thrown + * from the parser), then this method is called during the printing + * of the final stack trace, and hence the correct error message + * gets displayed. + */ + public String getMessage() { + if (!specialConstructor) { + return super.getMessage(); + } + String expected = ""; + int maxSize = 0; + for (int i = 0; i < expectedTokenSequences.length; i++) { + if (maxSize < expectedTokenSequences[i].length) { + maxSize = expectedTokenSequences[i].length; + } + for (int j = 0; j < expectedTokenSequences[i].length; j++) { + expected += tokenImage[expectedTokenSequences[i][j]] + " "; + } + if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) { + expected += "..."; + } + expected += eol + " "; + } + String retval = "Encountered \""; + Token tok = currentToken.next; + for (int i = 0; i < maxSize; i++) { + if (i != 0) retval += " "; + if (tok.kind == 0) { + retval += tokenImage[0]; + break; + } + retval += add_escapes(tok.image); + tok = tok.next; + } + retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn; + retval += "." + eol; + if (expectedTokenSequences.length == 1) { + retval += "Was expecting:" + eol + " "; + } else { + retval += "Was expecting one of:" + eol + " "; + } + retval += expected; + return retval; + } + + /** + * The end of line string for this machine. + */ + protected String eol = System.getProperty("line.separator", "\n"); + + /** + * Used to convert raw characters to their escaped version + * when these raw version cannot be used as part of an ASCII + * string literal. + */ + protected String add_escapes(String str) { + StringBuffer retval = new StringBuffer(); + char ch; + for (int i = 0; i < str.length(); i++) { + switch (str.charAt(i)) + { + case 0 : + continue; + case '\b': + retval.append("\\b"); + continue; + case '\t': + retval.append("\\t"); + continue; + case '\n': + retval.append("\\n"); + continue; + case '\f': + retval.append("\\f"); + continue; + case '\r': + retval.append("\\r"); + continue; + case '\"': + retval.append("\\\""); + continue; + case '\'': + retval.append("\\\'"); + continue; + case '\\': + retval.append("\\\\"); + continue; + default: + if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { + String s = "0000" + Integer.toString(ch, 16); + retval.append("\\u" + s.substring(s.length() - 4, s.length())); + } else { + retval.append(ch); + } + continue; + } + } + return retval.toString(); + } + +} Propchange: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/ParseException.java ------------------------------------------------------------------------------ svn:eol-style = native Added: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/README URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/README?rev=591934&view=auto ============================================================================== --- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/README (added) +++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/README Mon Nov 5 01:36:36 2007 @@ -0,0 +1,64 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file 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. + */ + +This package contains implementation of LDAP Filter parser and URL parser, +which are generated by JavaCC. + +"filter.g" and "url.g" are JavaCC recognized grammar files respectively for LDAP +Filter and LDAP URL, all java files are generated by JavaCC. If you want to +re-generate java files from grammar files or you have modified grammars want to +generate source code from new grammars, you can follow below steps: + + +** INSTALL JavaCC ** + +You should have JavaCC installed. + +1) download JavaCC from: + https://javacc.dev.java.net/ + +2) instanll JavaCC follow the instruments at: + https://javacc.dev.java.net/doc/installhelp.html + + +** GENERATE CODE ** + +If you have installed JavaCC correctly, generating java files is easy, go to +this directory and type something like: + + javacc filter.g + +or + + javacc url.g + +That generates all your needs. + +For more about JavaCC, you can visit: + + https://javacc.dev.java.net/doc/docindex.html + +which has all necessary documents on JavaCC. + + +NOTE: + +All generated java files have first line like this: + + /* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 3.0 */ + +We recommend to move this line below the ASF comment by convention. Propchange: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/README ------------------------------------------------------------------------------ svn:eol-style = native Added: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/SimpleCharStream.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/SimpleCharStream.java?rev=591934&view=auto ============================================================================== --- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/SimpleCharStream.java (added) +++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/SimpleCharStream.java Mon Nov 5 01:36:36 2007 @@ -0,0 +1,418 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file 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. + */ +/* Generated By:JavaCC: Do not edit this line. SimpleCharStream.java Version 3.0 */ + +package org.apache.harmony.jndi.provider.ldap.parser; + +/** + * An implementation of interface CharStream, where the stream is assumed to + * contain only ASCII characters (without unicode processing). + */ + +public class SimpleCharStream +{ + public static final boolean staticFlag = false; + int bufsize; + int available; + int tokenBegin; + public int bufpos = -1; + protected int bufline[]; + protected int bufcolumn[]; + + protected int column = 0; + protected int line = 1; + + protected boolean prevCharIsCR = false; + protected boolean prevCharIsLF = false; + + protected java.io.Reader inputStream; + + protected char[] buffer; + protected int maxNextCharInd = 0; + protected int inBuf = 0; + + protected void ExpandBuff(boolean wrapAround) + { + char[] newbuffer = new char[bufsize + 2048]; + int newbufline[] = new int[bufsize + 2048]; + int newbufcolumn[] = new int[bufsize + 2048]; + + try + { + if (wrapAround) + { + System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); + System.arraycopy(buffer, 0, newbuffer, + bufsize - tokenBegin, bufpos); + buffer = newbuffer; + + System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); + System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos); + bufline = newbufline; + + System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); + System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos); + bufcolumn = newbufcolumn; + + maxNextCharInd = (bufpos += (bufsize - tokenBegin)); + } + else + { + System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); + buffer = newbuffer; + + System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); + bufline = newbufline; + + System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); + bufcolumn = newbufcolumn; + + maxNextCharInd = (bufpos -= tokenBegin); + } + } + catch (Throwable t) + { + throw new Error(t.getMessage()); + } + + + bufsize += 2048; + available = bufsize; + tokenBegin = 0; + } + + protected void FillBuff() throws java.io.IOException + { + if (maxNextCharInd == available) + { + if (available == bufsize) + { + if (tokenBegin > 2048) + { + bufpos = maxNextCharInd = 0; + available = tokenBegin; + } + else if (tokenBegin < 0) + bufpos = maxNextCharInd = 0; + else + ExpandBuff(false); + } + else if (available > tokenBegin) + available = bufsize; + else if ((tokenBegin - available) < 2048) + ExpandBuff(true); + else + available = tokenBegin; + } + + int i; + try { + if ((i = inputStream.read(buffer, maxNextCharInd, + available - maxNextCharInd)) == -1) + { + inputStream.close(); + throw new java.io.IOException(); + } + else + maxNextCharInd += i; + return; + } + catch(java.io.IOException e) { + --bufpos; + backup(0); + if (tokenBegin == -1) + tokenBegin = bufpos; + throw e; + } + } + + public char BeginToken() throws java.io.IOException + { + tokenBegin = -1; + char c = readChar(); + tokenBegin = bufpos; + + return c; + } + + protected void UpdateLineColumn(char c) + { + column++; + + if (prevCharIsLF) + { + prevCharIsLF = false; + line += (column = 1); + } + else if (prevCharIsCR) + { + prevCharIsCR = false; + if (c == '\n') + { + prevCharIsLF = true; + } + else + line += (column = 1); + } + + switch (c) + { + case '\r' : + prevCharIsCR = true; + break; + case '\n' : + prevCharIsLF = true; + break; + case '\t' : + column--; + column += (8 - (column & 07)); + break; + default : + break; + } + + bufline[bufpos] = line; + bufcolumn[bufpos] = column; + } + + public char readChar() throws java.io.IOException + { + if (inBuf > 0) + { + --inBuf; + + if (++bufpos == bufsize) + bufpos = 0; + + return buffer[bufpos]; + } + + if (++bufpos >= maxNextCharInd) + FillBuff(); + + char c = buffer[bufpos]; + + UpdateLineColumn(c); + return (c); + } + + /** + * @deprecated + * @see #getEndColumn + */ + + public int getColumn() { + return bufcolumn[bufpos]; + } + + /** + * @deprecated + * @see #getEndLine + */ + + public int getLine() { + return bufline[bufpos]; + } + + public int getEndColumn() { + return bufcolumn[bufpos]; + } + + public int getEndLine() { + return bufline[bufpos]; + } + + public int getBeginColumn() { + return bufcolumn[tokenBegin]; + } + + public int getBeginLine() { + return bufline[tokenBegin]; + } + + public void backup(int amount) { + + inBuf += amount; + if ((bufpos -= amount) < 0) + bufpos += bufsize; + } + + public SimpleCharStream(java.io.Reader dstream, int startline, + int startcolumn, int buffersize) + { + inputStream = dstream; + line = startline; + column = startcolumn - 1; + + available = bufsize = buffersize; + buffer = new char[buffersize]; + bufline = new int[buffersize]; + bufcolumn = new int[buffersize]; + } + + public SimpleCharStream(java.io.Reader dstream, int startline, + int startcolumn) + { + this(dstream, startline, startcolumn, 4096); + } + + public SimpleCharStream(java.io.Reader dstream) + { + this(dstream, 1, 1, 4096); + } + public void ReInit(java.io.Reader dstream, int startline, + int startcolumn, int buffersize) + { + inputStream = dstream; + line = startline; + column = startcolumn - 1; + + if (buffer == null || buffersize != buffer.length) + { + available = bufsize = buffersize; + buffer = new char[buffersize]; + bufline = new int[buffersize]; + bufcolumn = new int[buffersize]; + } + prevCharIsLF = prevCharIsCR = false; + tokenBegin = inBuf = maxNextCharInd = 0; + bufpos = -1; + } + + public void ReInit(java.io.Reader dstream, int startline, + int startcolumn) + { + ReInit(dstream, startline, startcolumn, 4096); + } + + public void ReInit(java.io.Reader dstream) + { + ReInit(dstream, 1, 1, 4096); + } + public SimpleCharStream(java.io.InputStream dstream, int startline, + int startcolumn, int buffersize) + { + this(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096); + } + + public SimpleCharStream(java.io.InputStream dstream, int startline, + int startcolumn) + { + this(dstream, startline, startcolumn, 4096); + } + + public SimpleCharStream(java.io.InputStream dstream) + { + this(dstream, 1, 1, 4096); + } + + public void ReInit(java.io.InputStream dstream, int startline, + int startcolumn, int buffersize) + { + ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096); + } + + public void ReInit(java.io.InputStream dstream) + { + ReInit(dstream, 1, 1, 4096); + } + public void ReInit(java.io.InputStream dstream, int startline, + int startcolumn) + { + ReInit(dstream, startline, startcolumn, 4096); + } + public String GetImage() + { + if (bufpos >= tokenBegin) + return new String(buffer, tokenBegin, bufpos - tokenBegin + 1); + else + return new String(buffer, tokenBegin, bufsize - tokenBegin) + + new String(buffer, 0, bufpos + 1); + } + + public char[] GetSuffix(int len) + { + char[] ret = new char[len]; + + if ((bufpos + 1) >= len) + System.arraycopy(buffer, bufpos - len + 1, ret, 0, len); + else + { + System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0, + len - bufpos - 1); + System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1); + } + + return ret; + } + + public void Done() + { + buffer = null; + bufline = null; + bufcolumn = null; + } + + /** + * Method to adjust line and column numbers for the start of a token. + */ + public void adjustBeginLineColumn(int newLine, int newCol) + { + int start = tokenBegin; + int len; + + if (bufpos >= tokenBegin) + { + len = bufpos - tokenBegin + inBuf + 1; + } + else + { + len = bufsize - tokenBegin + bufpos + 1 + inBuf; + } + + int i = 0, j = 0, k = 0; + int nextColDiff = 0, columnDiff = 0; + + while (i < len && + bufline[j = start % bufsize] == bufline[k = ++start % bufsize]) + { + bufline[j] = newLine; + nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j]; + bufcolumn[j] = newCol + columnDiff; + columnDiff = nextColDiff; + i++; + } + + if (i < len) + { + bufline[j] = newLine++; + bufcolumn[j] = newCol + columnDiff; + + while (i++ < len) + { + if (bufline[j = start % bufsize] != bufline[++start % bufsize]) + bufline[j] = newLine++; + else + bufline[j] = newLine; + } + } + + line = bufline[j]; + column = bufcolumn[j]; + } + +} Propchange: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/SimpleCharStream.java ------------------------------------------------------------------------------ svn:eol-style = native Added: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/Token.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/Token.java?rev=591934&view=auto ============================================================================== --- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/Token.java (added) +++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/Token.java Mon Nov 5 01:36:36 2007 @@ -0,0 +1,98 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file 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. + */ +/* Generated By:JavaCC: Do not edit this line. Token.java Version 3.0 */ + +package org.apache.harmony.jndi.provider.ldap.parser; + +/** + * Describes the input token stream. + */ + +public class Token { + + /** + * An integer that describes the kind of this token. This numbering + * system is determined by JavaCCParser, and a table of these numbers is + * stored in the file ...Constants.java. + */ + public int kind; + + /** + * beginLine and beginColumn describe the position of the first character + * of this token; endLine and endColumn describe the position of the + * last character of this token. + */ + public int beginLine, beginColumn, endLine, endColumn; + + /** + * The string image of the token. + */ + public String image; + + /** + * A reference to the next regular (non-special) token from the input + * stream. If this is the last token from the input stream, or if the + * token manager has not read tokens beyond this one, this field is + * set to null. This is true only if this token is also a regular + * token. Otherwise, see below for a description of the contents of + * this field. + */ + public Token next; + + /** + * This field is used to access special tokens that occur prior to this + * token, but after the immediately preceding regular (non-special) token. + * If there are no such special tokens, this field is set to null. + * When there are more than one such special token, this field refers + * to the last of these special tokens, which in turn refers to the next + * previous special token through its specialToken field, and so on + * until the first special token (whose specialToken field is null). + * The next fields of special tokens refer to other special tokens that + * immediately follow it (without an intervening regular token). If there + * is no such token, this field is null. + */ + public Token specialToken; + + /** + * Returns the image. + */ + public String toString() + { + return image; + } + + /** + * Returns a new Token object, by default. However, if you want, you + * can create and return subclass objects based on the value of ofKind. + * Simply add the cases to the switch for all those special cases. + * For example, if you have a subclass of Token called IDToken that + * you want to create if ofKind is ID, simlpy add something like : + * + * case MyParserConstants.ID : return new IDToken(); + * + * to the following switch statement. Then you can cast matchedToken + * variable to the appropriate type and use it in your lexical actions. + */ + public static final Token newToken(int ofKind) + { + switch(ofKind) + { + default : return new Token(); + } + } + +} Propchange: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/Token.java ------------------------------------------------------------------------------ svn:eol-style = native Added: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/TokenMgrError.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/TokenMgrError.java?rev=591934&view=auto ============================================================================== --- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/TokenMgrError.java (added) +++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/TokenMgrError.java Mon Nov 5 01:36:36 2007 @@ -0,0 +1,150 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file 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. + */ +/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 3.0 */ + +package org.apache.harmony.jndi.provider.ldap.parser; + +public class TokenMgrError extends Error +{ + /* + * Ordinals for various reasons why an Error of this type can be thrown. + */ + + /** + * Lexical error occured. + */ + static final int LEXICAL_ERROR = 0; + + /** + * An attempt wass made to create a second instance of a static token manager. + */ + static final int STATIC_LEXER_ERROR = 1; + + /** + * Tried to change to an invalid lexical state. + */ + static final int INVALID_LEXICAL_STATE = 2; + + /** + * Detected (and bailed out of) an infinite loop in the token manager. + */ + static final int LOOP_DETECTED = 3; + + /** + * Indicates the reason why the exception is thrown. It will have + * one of the above 4 values. + */ + int errorCode; + + /** + * Replaces unprintable characters by their espaced (or unicode escaped) + * equivalents in the given string + */ + protected static final String addEscapes(String str) { + StringBuffer retval = new StringBuffer(); + char ch; + for (int i = 0; i < str.length(); i++) { + switch (str.charAt(i)) + { + case 0 : + continue; + case '\b': + retval.append("\\b"); + continue; + case '\t': + retval.append("\\t"); + continue; + case '\n': + retval.append("\\n"); + continue; + case '\f': + retval.append("\\f"); + continue; + case '\r': + retval.append("\\r"); + continue; + case '\"': + retval.append("\\\""); + continue; + case '\'': + retval.append("\\\'"); + continue; + case '\\': + retval.append("\\\\"); + continue; + default: + if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { + String s = "0000" + Integer.toString(ch, 16); + retval.append("\\u" + s.substring(s.length() - 4, s.length())); + } else { + retval.append(ch); + } + continue; + } + } + return retval.toString(); + } + + /** + * Returns a detailed message for the Error when it is thrown by the + * token manager to indicate a lexical error. + * Parameters : + * EOFSeen : indicates if EOF caused the lexicl error + * curLexState : lexical state in which this error occured + * errorLine : line number when the error occured + * errorColumn : column number when the error occured + * errorAfter : prefix that was seen before this error occured + * curchar : the offending character + * Note: You can customize the lexical error message by modifying this method. + */ + protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) { + return("Lexical error at line " + + errorLine + ", column " + + errorColumn + ". Encountered: " + + (EOFSeen ? " " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") + + "after : \"" + addEscapes(errorAfter) + "\""); + } + + /** + * You can also modify the body of this method to customize your error messages. + * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not + * of end-users concern, so you can return something like : + * + * "Internal Error : Please file a bug report .... " + * + * from this method for such cases in the release version of your parser. + */ + public String getMessage() { + return super.getMessage(); + } + + /* + * Constructors of various flavors follow. + */ + + public TokenMgrError() { + } + + public TokenMgrError(String message, int reason) { + super(message); + errorCode = reason; + } + + public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) { + this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason); + } +} Propchange: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/TokenMgrError.java ------------------------------------------------------------------------------ svn:eol-style = native Added: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/filter.g URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/filter.g?rev=591934&view=auto ============================================================================== --- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/filter.g (added) +++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/filter.g Mon Nov 5 01:36:36 2007 @@ -0,0 +1,514 @@ + +options { + +STATIC = false; + +} + + +PARSER_BEGIN(FilterParser) +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file 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. + */ + +package org.apache.harmony.jndi.provider.ldap.parser; + +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.util.ArrayList; +import java.util.List; +import java.io.StringReader; +import org.apache.harmony.jndi.provider.ldap.Filter; +import org.apache.harmony.jndi.internal.parser.AttributeTypeAndValuePair; +import org.apache.harmony.jndi.provider.ldap.Filter.MatchingRuleAssertion; +import org.apache.harmony.jndi.provider.ldap.Filter.SubstringFilter; +import org.apache.harmony.jndi.provider.ldap.asn1.Utils; + + +/** + * Ldap filter parser which parse the string representation of Ldap filters to + * instance of org.apache.harmony.jndi.provider.ldap.filter.Filter according + * RFC2254. And It also support parse variables of the form {i}. + * + * @see org.apache.harmony.jndi.provider.ldap.filter.Filter + * @see javax.naming.directory.DirContext#search(javax.naming.Name, String, + * Object[], javax.naming.directory.SearchControls) + */ +public class FilterParser { + + public static void main(String args[]) throws ParseException, FileNotFoundException { + FilterParser parser = new FilterParser(new FileInputStream("parser.filter.test")); + // FilterParser parser = new FilterParser(System.in); + //System.out.println(parser.value()); + parser.test(); + } + + private Object[] args; + + private boolean isEndEOF = false; + + public FilterParser(String filter) { + this(new StringReader(filter)); + isEndEOF = true; + } + + public Object[] getArgs() { + return args; + } + + public void setArgs(Object[] args) { + this.args = args; + } + + private String getArgAttrValue(String index) { + int i = Integer.valueOf(index).intValue(); + if (args == null || args.length <= i || args[i] == null) { + throw new IllegalArgumentException(); + } + + return (String) args[i]; + } + + private String getArgValue(String index) { + int i = Integer.valueOf(index).intValue(); + if (args == null || args.length <= i || args[i] == null) { + throw new IllegalArgumentException(); + } + if (args[i] instanceof String) { + return (String) args[i]; + } + + //FIXME: + throw new RuntimeException("Convert value to corresponding java type."); + } + + private String convertToUtf8Char(String s) { + byte[] bs = new byte[] { (byte)Integer.parseInt(s, 16) }; + return Utils.getString(bs); + } + + private Filter parseSubstring(String des, List list) { + Filter filter = null; + if (list.size() == 1) { + if (list.get(0).equals("*")) { + filter = new Filter(Filter.PRESENT_FILTER); + filter.setValue(des); + } else { + filter = new Filter(Filter.EQUALITY_MATCH_FILTER); + filter + .setValue(new AttributeTypeAndValuePair(des, list + .get(0))); + } + } else { + String initial = null; + String any = ""; + String end = null; + if (list.get(0).equals("*")) { + any = "*"; + } else { + initial = (String) list.get(0); + } + + for (int i = 1; i < list.size(); ++i) { + String value = (String) list.get(i); + if (i == list.size() - 1 && !value.equals("*")) { + end = value; + } else { + any += value; + } + } + filter = new Filter(Filter.SUBSTRINGS_FILTER); + SubstringFilter substring = new SubstringFilter(des); + if (initial != null) { + substring.addInitial(initial); + } + + substring.addAny(any); + + if (end != null) { + substring.addFinal(end); + } + filter.setValue(substring); + } + + return filter; + } +} + +PARSER_END(FilterParser) + + +TOKEN : +{ + +| + +| + +| + +| + +| + +| + +| + +| + +| + +| + +| + +| + +| +"> +| + +| + +| + +| + +| + +| + +| + +| + +} + +String option(): + { + StringBuilder value = new StringBuilder(); + Token t; + } + + { + t = {value.append(t.image);} + (t = {value.append(t.image);} + |t = {value.append(t.image);} + |t = {value.append(t.image);} + |t = {value.append(t.image);} + |t = {value.append(t.image);})+ + + {return value.toString();} + } + +String number(): + { + StringBuilder value = new StringBuilder(); + Token t; + } + { + (t = {value.append(t.image);} + | (t = {value.append(t.image);} + (t = {value.append(t.image);} + |t = {value.append(t.image);})*)) + + {return value.toString();} + } + + +String oid(): + { + StringBuilder value = new StringBuilder(); + String number = null; + Token t = null; + } + { + number = number() {value.append(number);} + (t = {value.append(t.image);} + number = number() {value.append(number);})+ + + {return value.toString();} + } + + + +String matchingrule(): + { + String value = null; + } + { + (value = oid() | value = attrType()) + {return value;} + } + +String argument(): + {String num = null;} + { + ( num = number() ) + + {return getArgAttrValue(num);} + } + +String attrType(): + { + StringBuilder value = new StringBuilder(); + String arg; + Token t; + } + + { + (t = {value.append(t.image);}| t = {value.append(t.image);}| arg = argument() {value.append(arg);}) + ((t = | t = | t = | t = | t = ) {value.append(t.image);} | arg = argument() {value.append(arg);})* + {return value.toString();} + } + +String attrDescr(): + {String type;} + { + (type = attrType() (option())*) + {return type;} + + } + +void test(): + {} + { + { + /* + * initial args for test, so there should not be args index larger than + * 49 in test case + */ + args = new Object[20]; + for (int i = 0; i < args.length; i++) { + args[i] = "{" + i + "}"; + } + } + + parse() "\n" test() | LOOKAHEAD(2) "\n" | "\n" | + } +// FIXME: get string representation of AttributeValue, then use Rdn.unescapeValue(String) to get value +String value(): + { + StringBuilder value = new StringBuilder(); + String hexValue = null; + Token t = null;; + String arg = null; + } + { + // string form of AttributeValue + ((t = {value.append(t.image);} + | t = {value.append(t.image);} + | t = {value.append(t.image);} + | t = {value.append(t.image);} + | t = {value.append(t.image);} + | t = {value.append(t.image);} + | hexValue = backslashValue() {value.append(hexValue);} + | arg = argument() {value.append(arg);} + | t = {value.append(t.image);}))+ + + // TODO: add binary form of AttributeValue + + {return value.toString();} + } + +String backslashValue(): + {String value;} + { + // TODO: ",", "+", """, "\", "<", ">", ";", space at beginning, "#" at beginning, + // space at end prefixed by a backslash + value = hexDigit() {return convertToUtf8Char(value);} + } + +String hexDigit(): + { + String value; + Token t; + } + { + (t = | t = | t = ) {value = t.image;} + (t = | t = | t = ) {value += t.image;} + + {return value;} + } + + +Filter parse(): + { + Filter filter = null; + Filter temp = null; + } + { + + ( + + {filter = new Filter(Filter.AND_FILTER);} + + temp = parse() + {filter.addChild(temp);} + + temp = parse() + {filter.addChild(temp);} + + (temp = parse() + {filter.addChild(temp);} + )* + | + + {filter = new Filter(Filter.OR_FILTER);} + + temp = parse() + {filter.addChild(temp);} + + temp = parse() + {filter.addChild(temp);} + + (temp = parse() + {filter.addChild(temp);} + )* + | + + {filter = new Filter(Filter.NOT_FILTER);} + temp = parse() + {filter.setValue(temp);} + | + filter = item() + ) + + { + return filter; + } + } + +void eof(): + {} + { + + } + +Filter item(): + { + Filter filter = null; + String value = null; + String des = null; + String temp = null; + List list = new ArrayList(); + SubstringFilter substring = null; + MatchingRuleAssertion rule = null; + } + + { + (des = attrDescr() ( + LOOKAHEAD(2) + value = value() + { + filter = new Filter(Filter.APPROX_MATCH_FILTER); filter.setValue(new AttributeTypeAndValuePair(des, value)); + } + | value = value() + { + filter = new Filter(Filter.GREATER_OR_EQUAL_FILTER);filter.setValue(new AttributeTypeAndValuePair(des, value)); + } + | value = value() + { + filter = new Filter(Filter.LESS_OR_EQUAL_FILTER);filter.setValue(new AttributeTypeAndValuePair(des, value)); + } + + | LOOKAHEAD(3) (asterisk_start(list) | value_start(list)) {filter = parseSubstring(des, list);} + + | rule = extensible_1(des) {filter = new Filter(Filter.EXTENSIBLE_MATCH_FILTER); filter.setValue(rule);} ) + | rule = extensible_2() {filter = new Filter(Filter.EXTENSIBLE_MATCH_FILTER); filter.setValue(rule);} ) + + {return filter;} + } + +void asterisk_start(List list): + {} + { + {list.add("*");} [value_start(list)] + } + +void value_start(List list): + { + String value; + } + { + value = value() {list.add(value);} [asterisk_start(list)] + } + +String final_part(): + { + String value; + } + { + value = value() + + {return value;} + } +String tail_part(): + { + String value; + String temp; + } + { + value = any_part() [temp = final_part() {value = value + temp;}] + {return value;} + } + +String any_part(): + { + StringBuilder value = new StringBuilder(); + Token t; + String temp; + } + { + t = {value.append(t.image);} + (LOOKAHEAD(2) temp = value() {value.append(temp);} + t = {value.append(t.image);})+ + + {return value.toString();} + } + +MatchingRuleAssertion extensible_1(String type): + { + MatchingRuleAssertion rule = new MatchingRuleAssertion(); + rule.setType(type); + String value; + } + { + [LOOKAHEAD(2) {rule.setDnAttributes(true);} ] + [LOOKAHEAD(2) value = oid() {rule.setMatchingRule(value);} ] + value = value() {rule.setMatchValue(value);} + {return rule;} + } + +MatchingRuleAssertion extensible_2(): + { + MatchingRuleAssertion rule = new MatchingRuleAssertion(); + String value; + } + { + [LOOKAHEAD(2) ] value = matchingrule() {rule.setMatchingRule(value);} + value = value() {rule.setMatchValue(value);} + {return rule;} + } + +void colon_oid(): + {} + { + oid() + } Propchange: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/filter.g ------------------------------------------------------------------------------ svn:eol-style = native Added: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/url.g URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/url.g?rev=591934&view=auto ============================================================================== --- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/url.g (added) +++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/url.g Mon Nov 5 01:36:36 2007 @@ -0,0 +1,341 @@ +options { + +STATIC = false; + +} + + +PARSER_BEGIN(LdapUrlParser) +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file 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. + */ + +package org.apache.harmony.jndi.provider.ldap.parser; + +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.util.ArrayList; +import java.util.List; +import java.io.StringReader; +import javax.naming.directory.SearchControls; +import org.apache.harmony.jndi.provider.ldap.Filter; +import org.apache.harmony.jndi.provider.ldap.asn1.Utils; + +public class LdapUrlParser { + private SearchControls controls; + + private Filter filter; + + private String baseObject; + + private String host; + + private int port = -1; + + private boolean isEndEOF = false; + + public LdapUrlParser(String url) { + this(new StringReader(url)); + isEndEOF = true; + } + + public SearchControls getControls() { + return controls; + } + + public Filter getFilter() { + return filter; + } + + private String convertToUtf8Char(String s) { + byte[] bs = new byte[] { (byte)Integer.parseInt(s, 16) }; + return Utils.getString(bs); + } + + /** + * get the host part of the url, if host part is omitted, null + * will be return + * + * @return host part of the url or null if it's omitted + */ + public String getHost() { + return host; + } + + /** + * get the port number of the url, if this part is omitted, -1 will be + * return + * + * @return port number of the url or -1 if it's omitted + */ + public int getPort() { + return port; + } + + public String getBaseObject() { + return baseObject; + } + + public static void main(String args[]) throws ParseException, FileNotFoundException { + LdapUrlParser parser = new LdapUrlParser(new FileInputStream("parser.url.test")); +// URLParser parser = new URLParser(System.in); + // FilterParser parser = new FilterParser(System.in); + //System.out.println(parser.value()); + parser.test(); + //parser.value(); + } +} + +PARSER_END(LdapUrlParser) + +TOKEN : +{ + + +| + +| + +| + +| + +| + +| + +| + +| + +| + +| + +| + +| + +| + +| + + +} + + +void parseURL(): + {} + { + + [hostport()] + [ [dn() + [ attributes()]]] + { + if (isEndEOF) { + eof(); + } + } + } + +void eof(): + {} + { + + } + +String number(): + { + StringBuilder value = new StringBuilder(); + Token t; + } + { + (t = {value.append(t.image);} + | (t = {value.append(t.image);} + (t = {value.append(t.image);} + |t = {value.append(t.image);})*)) + + {return value.toString();} + } + +String hexDigit(): + { + String value; + Token t; + } + { + (t = | t = | t = ) {value = t.image;} + (t = | t = | t = ) {value += t.image;} + + {return value;} + } + +String value(): + { + StringBuilder value = new StringBuilder(); + String ch; + } + { + (ch = ch() {value.append(ch);})+ + + {return value.toString();} + } + +String ch(): + { + Token t; + String value; + String temp; + } + { + (t = {value = t.image;} + | t = value = hexDigit() {value = convertToUtf8Char(value);} + | t = {value = t.image;} + | t = {value = t.image;} + | t = {value = t.image;} + | t = {value = t.image;} + | t = {value = t.image;} + | t = {value = t.image;} + | t = {value = t.image;} + | t = {value = t.image;} + | t = {value = t.image;} + | t = {value = t.image;}) + + {return value;} + } + +void hostport(): + { + String ch; + StringBuilder h = new StringBuilder(); + + } + { + (ch = ch() {h.append(ch);})+ {host = h.toString();} + [ ch = number() {port = Integer.valueOf(ch);}] + } + +void dn(): + { + Token t; + String value; + StringBuilder dn = new StringBuilder(); + } + { + (value = value() {dn.append(value);} + [(t = {dn.append(t.image);} value = value() {dn.append(value);})+]) + { + baseObject = dn.toString(); + } + } + +void attributes(): + { + String value; + List attrs = new ArrayList(); + } + { + [value = value() {attrs.add(value);} + [( value = value() {attrs.add(value);})+]] + { + if (attrs.size() != 0) { + if (controls == null) { + // FIXME: test what default search parameter value is + controls = new SearchControls(SearchControls.OBJECT_SCOPE, 0, 0, null, false, false); + } + controls.setReturningAttributes((String[]) attrs.toArray(new String[0])); + } + } + [ scope()] + } + +void attrDescr(): + {} + { + value() + } + +void scope(): + { + Token t; + String scope; + } + { + [t = + { + scope = t.image; + if (controls == null) { + // FIXME: test what default search parameter value is + controls = new SearchControls(SearchControls.OBJECT_SCOPE, 0, 0, null, false, false); + } + if (scope.equals("base")) { + controls.setSearchScope(SearchControls.OBJECT_SCOPE); + } else if (scope.equals("one")) { + controls.setSearchScope(SearchControls.ONELEVEL_SCOPE); + } else { + controls.setSearchScope(SearchControls.SUBTREE_SCOPE); + } + }] + + [ filter()] + + } + +void filter(): + { + String value; + } + { + [value = value() + { + FilterParser parser = new FilterParser(new StringReader(value)); + filter = parser.parse(); + }] + [ extensions()] + } +void extensions(): + {} + { + extension() [( extension())+] + } + +void extension(): + {} + { + [] (oid() | oid()) ["=" value()] + } + +String oid(): + { + StringBuilder value = new StringBuilder(); + String number = null; + Token t = null; + } + { + number = number() {value.append(number);} + (t = {value.append(t.image);} + number = number() {value.append(number);})+ + + {return value.toString();} + } + +void test(): + {} + { + parseURL() "\n" test() | LOOKAHEAD(2) "\n" | "\n" | + } Propchange: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/url.g ------------------------------------------------------------------------------ svn:eol-style = native Added: harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/parser/FilterParserTest.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/parser/FilterParserTest.java?rev=591934&view=auto ============================================================================== --- harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/parser/FilterParserTest.java (added) +++ harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/parser/FilterParserTest.java Mon Nov 5 01:36:36 2007 @@ -0,0 +1,110 @@ +package org.apache.harmony.jndi.provider.ldap.parser; + +import java.util.List; + +import org.apache.harmony.jndi.internal.parser.AttributeTypeAndValuePair; +import org.apache.harmony.jndi.provider.ldap.Filter; +import org.apache.harmony.jndi.provider.ldap.Filter.SubstringFilter; +import org.apache.harmony.jndi.provider.ldap.asn1.ASN1ChoiceWrap.ChosenValue; +import org.apache.harmony.jndi.provider.ldap.parser.FilterParser; + +import junit.framework.TestCase; + +public class FilterParserTest extends TestCase { + + private static final String TEST_FILE = "/parser/parser.filter.test"; + + private FilterParser parser; + + private Filter filter; + + /** + * test whether correct filters can be accepted by the parser + * + * @throws Exception + */ + public void test_grammar() throws Exception { + parser = new FilterParser(getClass().getClassLoader() + .getResourceAsStream(TEST_FILE)); + parser.test(); + } + + public void test_parse() throws Exception { + parser = new FilterParser("(cn=Babs Jensen)"); + filter = parser.parse(); + assertEquals(Filter.EQUALITY_MATCH_FILTER, filter.getType()); + assertAttributeValueAssertion("cn", "Babs Jensen", filter.getValue()); + + parser = new FilterParser("(!(cn=Tim Howes))"); + filter = parser.parse(); + assertEquals(Filter.NOT_FILTER, filter.getType()); + assertTrue(filter.getValue() instanceof Filter); + filter = (Filter) filter.getValue(); + assertEquals(Filter.EQUALITY_MATCH_FILTER, filter.getType()); + assertAttributeValueAssertion("cn", "Tim Howes", filter.getValue()); + + parser = new FilterParser( + "(&(objectClass=Person)(|(sn=Jensen)(cn=Babs J*)))"); + filter = parser.parse(); + assertEquals(Filter.AND_FILTER, filter.getType()); + assertFalse(filter.isLeaf()); + List children = filter.getChildren(); + assertEquals(2, children.size()); + assertEquals(Filter.EQUALITY_MATCH_FILTER, children.get(0).getType()); + assertAttributeValueAssertion("objectClass", "Person", children.get(0) + .getValue()); + filter = children.get(1); + assertEquals(Filter.OR_FILTER, filter.getType()); + assertFalse(filter.isLeaf()); + children = filter.getChildren(); + assertEquals(2, children.size()); + assertAttributeValueAssertion("sn", "Jensen", children.get(0) + .getValue()); + filter = children.get(1); + assertEquals(Filter.SUBSTRINGS_FILTER, filter.getType()); + assertEquals(SubstringFilter.class, filter.getValue().getClass()); + SubstringFilter sub = (SubstringFilter) filter.getValue(); + assertEquals("cn", sub.getType()); + // TODO: not sure whether '*' should be part of 'any' + // assertEquals(1, sub.getSubstrings().size()); + ChosenValue chosen = sub.getSubstrings().get(0); + assertEquals("Babs J", chosen.getValue()); + assertEquals(0, chosen.getIndex()); + } + + public void test_parse_special_char() throws Exception { + parser = new FilterParser("(cn=\\2Atest)"); + filter = parser.parse(); + assertEquals(Filter.EQUALITY_MATCH_FILTER, filter.getType()); + assertAttributeValueAssertion("cn", "*test", filter.getValue()); + } + + public void test_parse_argument() throws Exception { + parser = new FilterParser("(cn={0})"); + parser.setArgs(new Object[] { "value" }); + filter = parser.parse(); + assertEquals(Filter.EQUALITY_MATCH_FILTER, filter.getType()); + assertAttributeValueAssertion("cn", "value", filter.getValue()); + + parser = new FilterParser("(cn=start{0}end)"); + parser.setArgs(new Object[] { "value" }); + filter = parser.parse(); + assertEquals(Filter.EQUALITY_MATCH_FILTER, filter.getType()); + assertAttributeValueAssertion("cn", "startvalueend", filter.getValue()); + + parser = new FilterParser("({2}cn{1}=test{0})"); + parser.setArgs(new Object[] { "value0", "value1", "value2" }); + filter = parser.parse(); + assertEquals(Filter.EQUALITY_MATCH_FILTER, filter.getType()); + assertAttributeValueAssertion("value2cnvalue1", "testvalue0", filter + .getValue()); + } + + private void assertAttributeValueAssertion(String attrType, + String attrValue, Object filterValue) { + assertTrue(filterValue instanceof AttributeTypeAndValuePair); + AttributeTypeAndValuePair pair = (AttributeTypeAndValuePair) filterValue; + assertEquals(attrType, pair.getType()); + assertEquals(attrValue, pair.getValue()); + } +} Propchange: harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/parser/FilterParserTest.java ------------------------------------------------------------------------------ svn:eol-style = native Added: harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/parser/LdapUrlParserTest.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/parser/LdapUrlParserTest.java?rev=591934&view=auto ============================================================================== --- harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/parser/LdapUrlParserTest.java (added) +++ harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/parser/LdapUrlParserTest.java Mon Nov 5 01:36:36 2007 @@ -0,0 +1,115 @@ +package org.apache.harmony.jndi.provider.ldap.parser; + +import javax.naming.directory.SearchControls; + +import junit.framework.TestCase; + +public class LdapUrlParserTest extends TestCase { + private static final String TEST_FILE = "/parser/parser.url.test"; + + private LdapUrlParser parser; + + private SearchControls controls; + + private org.apache.harmony.jndi.provider.ldap.Filter filter; + + public void test_grammar() throws Exception { + parser = new LdapUrlParser(getClass().getClassLoader() + .getResourceAsStream(TEST_FILE)); + parser.test(); + } + + public void test_parseURL() throws Exception { + parser = new LdapUrlParser("ldap://192.168.1.3:389"); + parser.parseURL(); + assertNull(parser.getBaseObject()); + assertNull(parser.getFilter()); + assertNull(parser.getControls()); + assertEquals("192.168.1.3", parser.getHost()); + assertEquals(389, parser.getPort()); + + parser = new LdapUrlParser("ldap://192.168.1.3/o=University,c=US"); + parser.parseURL(); + assertEquals("o=University,c=US", parser.getBaseObject()); + assertNull(parser.getFilter()); + assertNull(parser.getControls()); + assertEquals("192.168.1.3", parser.getHost()); + + parser = new LdapUrlParser( + "ldap://192.168.1.3/o=University,c=US?postalAddress"); + parser.parseURL(); + assertEquals("o=University,c=US", parser.getBaseObject()); + assertEquals("192.168.1.3", parser.getHost()); + assertNotNull(parser.getControls()); + controls = parser.getControls(); + assertEquals(SearchControls.OBJECT_SCOPE, controls.getSearchScope()); + assertEquals(1, controls.getReturningAttributes().length); + assertEquals("postalAddress", controls.getReturningAttributes()[0]); + assertNull(parser.getFilter()); + + parser = new LdapUrlParser( + "ldap://192.168.1.3/o=University,c=US?postalAddress,o"); + parser.parseURL(); + assertEquals("o=University,c=US", parser.getBaseObject()); + assertEquals("192.168.1.3", parser.getHost()); + assertNotNull(parser.getControls()); + controls = parser.getControls(); + assertEquals(SearchControls.OBJECT_SCOPE, controls.getSearchScope()); + assertEquals(2, controls.getReturningAttributes().length); + assertEquals("postalAddress", controls.getReturningAttributes()[0]); + assertEquals("o", controls.getReturningAttributes()[1]); + assertNull(parser.getFilter()); + + parser = new LdapUrlParser("ldap:///o=University,c=US"); + parser.parseURL(); + assertEquals("o=University,c=US", parser.getBaseObject()); + assertNull(parser.getFilter()); + assertNull(parser.getControls()); + assertNull(parser.getHost()); + + parser = new LdapUrlParser("ldap://192.168.1.3/o=University,c=US??sub"); + parser.parseURL(); + assertEquals("o=University,c=US", parser.getBaseObject()); + assertEquals("192.168.1.3", parser.getHost()); + assertNotNull(parser.getControls()); + controls = parser.getControls(); + assertEquals(SearchControls.SUBTREE_SCOPE, controls.getSearchScope()); + + parser = new LdapUrlParser( + "ldap://192.168.1.3/o=University,c=US??wrong"); + try { + parser.parseURL(); + fail("Should raise ParseException"); + } catch (ParseException e) { + // expected + } + + parser = new LdapUrlParser( + "ldap://192.168.1.3/c=US?o=University?sub?(objectClass=*)"); + parser.parseURL(); + assertEquals("c=US", parser.getBaseObject()); + assertEquals("192.168.1.3", parser.getHost()); + assertNotNull(parser.getControls()); + controls = parser.getControls(); + assertEquals(SearchControls.SUBTREE_SCOPE, controls.getSearchScope()); + assertNotNull(parser.getFilter()); + + parser = new LdapUrlParser( + "ldap://192.168.1.3/c=US?o=University?sub?(objectClass=*)"); + parser.parseURL(); + assertEquals("c=US", parser.getBaseObject()); + assertEquals("192.168.1.3", parser.getHost()); + assertNotNull(parser.getControls()); + controls = parser.getControls(); + assertEquals(SearchControls.SUBTREE_SCOPE, controls.getSearchScope()); + assertNotNull(parser.getFilter()); + + } + + public void test_parseURL_special_char() throws Exception { + parser = new LdapUrlParser("ldap:///o=University%20of%20Michigan,c=US"); + parser.parseURL(); + assertEquals("o=University of Michigan,c=US", parser.getBaseObject()); + + } +} Propchange: harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/parser/LdapUrlParserTest.java ------------------------------------------------------------------------------ svn:eol-style = native Added: harmony/enhanced/classlib/trunk/modules/jndi/src/test/resources/parser/parser.filter.test URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/test/resources/parser/parser.filter.test?rev=591934&view=auto ============================================================================== --- harmony/enhanced/classlib/trunk/modules/jndi/src/test/resources/parser/parser.filter.test (added) +++ harmony/enhanced/classlib/trunk/modules/jndi/src/test/resources/parser/parser.filter.test Mon Nov 5 01:36:36 2007 @@ -0,0 +1,28 @@ +(cn=dn) +(cn=Babs Jensen) +(!(cn=Tim Howes)) +(&(objectClass=Person)(|(sn=Jensen)(cn=Babs J*))) +(cn=*) +(cn=hele*heheh) +(cn=*hello) +(cn=*hello*) +(o=univ*of*mich*) +(cn:1.2.3.4.5:=Fred Flintstone) +(sn:dn:2.4.6.8.10:=Barney Rubble) +(o:dn:=Ace Industry) +(:dn:2.4.6.8.10:=Dino) +(&(a=A)(|(b=B)(c=C))) +(&(a=A)(|(c=C)(b=B))) +(&(ou=Human Resources)(uid=akarasulu)(|(ou=Human Resources)(uid=akarasulu))) +(&(uid=akarasulu)(ou=Human Resources)(|(uid=akarasulu)(ou=Human Resources))) +(&(ou=Human Resources)(uid=akarasulu)) +(ou=Human Resources) +(o=Parens R Us \28for all your parenthetical needs\29) +(cn=*\2A*) +(filename=C:\5cMyFile) +(bin=\00\00\00\04) +(sn=Lu\c4\8di\c4\87) +({0}=*hello) +(cn=*{10}) +(:dn:{3}:=Dino) +(:{11}:=Dino) Added: harmony/enhanced/classlib/trunk/modules/jndi/src/test/resources/parser/parser.url.test URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/test/resources/parser/parser.url.test?rev=591934&view=auto ============================================================================== --- harmony/enhanced/classlib/trunk/modules/jndi/src/test/resources/parser/parser.url.test (added) +++ harmony/enhanced/classlib/trunk/modules/jndi/src/test/resources/parser/parser.url.test Mon Nov 5 01:36:36 2007 @@ -0,0 +1,13 @@ +ldap:///o=University%20of%20Michigan,c=US +ldap://ldap.itd.umich.edu/o=University%20of%20Michigan,c=US +ldap://ldap.itd.umich.edu/o=University%20of%20Michigan,c=US?postalAddress +ldap://ldap.itd.umich.edu/o=University%20of%20Michigan,c=US?postalAddress,objectClass +ldap://host.com:6666/o=University%20of%20Michigan,c=US??sub?(cn=Babs%20Jensen) +ldap://ldap.itd.umich.edu/c=GB?objectClass?one +ldap://ldap.question.com/o=Question%3f,c=US?mail +ldap://ldap.netscape.com/o=Babsco,c=US???(int=%5c00%5c00%5c00%5c04) +ldap://ldap.question.com/cn=hello????2.3.3=sdfsf +ldap://ldap.question.com/cn=hello????2.3.3=sdfsf,3.2.2=dfdfdf +ldaps://host.com:6666/o=University%20of%20Michigan,c=US??sub?(cn=Babs%20Jensen) +ldaps://ldap.question.com/cn=hello????2.3.3=sdfsf +