Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 55981 invoked from network); 28 Jul 2009 09:31:15 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 28 Jul 2009 09:31:15 -0000 Received: (qmail 64469 invoked by uid 500); 28 Jul 2009 09:32:32 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 64422 invoked by uid 500); 28 Jul 2009 09:32:32 -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 64347 invoked by uid 99); 28 Jul 2009 09:32:32 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Jul 2009 09:32:32 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Jul 2009 09:32:18 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 3DE2723889FA; Tue, 28 Jul 2009 09:31:00 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r798469 [23/28] - in /harmony/enhanced/classlib/branches/java6: ./ depends/build/platform/ depends/files/ depends/jars/ depends/manifests/icu4j_4.0/ depends/manifests/icu4j_4.2.1/ depends/manifests/icu4j_4.2.1/META-INF/ make/ modules/access... Date: Tue, 28 Jul 2009 09:30:48 -0000 To: commits@harmony.apache.org From: hindessm@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090728093100.3DE2723889FA@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/LdapUrlParser.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/LdapUrlParser.java?rev=798469&r1=798468&r2=798469&view=diff ============================================================================== --- harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/LdapUrlParser.java (original) +++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/LdapUrlParser.java Tue Jul 28 09:30:33 2009 @@ -666,24 +666,58 @@ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case SCHEME: parseURL(); - jj_consume_token(17); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case 17: + jj_consume_token(17); + break; + case 18: + jj_consume_token(18); + break; + default: + jj_la1[29] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } test(); break; default: - jj_la1[29] = jj_gen; + jj_la1[32] = jj_gen; if (jj_2_1(2)) { - jj_consume_token(17); - } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 17: jj_consume_token(17); + break; + case 18: + jj_consume_token(18); + break; + default: + jj_la1[30] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } else { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case 17: + case 18: + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case 17: + jj_consume_token(17); + break; + case 18: + jj_consume_token(18); + break; + default: + jj_la1[31] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } jj_consume_token(0); break; case 0: jj_consume_token(0); break; default: - jj_la1[30] = jj_gen; + jj_la1[33] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -691,94 +725,115 @@ } } - final private boolean jj_2_1(int xla) { + private boolean jj_2_1(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_1(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(0, xla); } } - final private boolean jj_3_1() { - if (jj_scan_token(17)) return true; + private boolean jj_3_1() { + Token xsp; + xsp = jj_scanpos; + if (jj_scan_token(17)) { + jj_scanpos = xsp; + if (jj_scan_token(18)) return true; + } return false; } + /** Generated Token Manager. */ public LdapUrlParserTokenManager token_source; SimpleCharStream jj_input_stream; - public Token token, jj_nt; + /** Current token. */ + public Token token; + /** Next token. */ + public Token jj_nt; private int jj_ntk; private Token jj_scanpos, jj_lastpos; private int jj_la; - public boolean lookingAhead = false; - private boolean jj_semLA; private int jj_gen; - final private int[] jj_la1 = new int[31]; + final private int[] jj_la1 = new int[34]; static private int[] jj_la1_0; static { - jj_la1_0(); + jj_la1_init_0(); } - private static void jj_la1_0() { - jj_la1_0 = new int[] {0x1fe8e,0x20,0x1fe8e,0x40,0xc000,0xc000,0xc000,0xd000,0xd000,0x1fe8e,0x1fe8e,0x1fe8e,0x100,0x10,0x10,0x10,0x10,0x1fe8e,0x20,0x8,0x20,0x1fe8e,0x20,0x10,0x10,0x400,0xc004,0x800,0x200,0x2,0x20001,}; + private static void jj_la1_init_0() { + jj_la1_0 = new int[] {0x1fe8e,0x20,0x1fe8e,0x40,0xc000,0xc000,0xc000,0xd000,0xd000,0x1fe8e,0x1fe8e,0x1fe8e,0x100,0x10,0x10,0x10,0x10,0x1fe8e,0x20,0x8,0x20,0x1fe8e,0x20,0x10,0x10,0x400,0xc004,0x800,0x200,0x60000,0x60000,0x60000,0x2,0x60001,}; } final private JJCalls[] jj_2_rtns = new JJCalls[1]; private boolean jj_rescan = false; private int jj_gc = 0; + /** Constructor with InputStream. */ public LdapUrlParser(java.io.InputStream stream) { - jj_input_stream = new SimpleCharStream(stream, 1, 1); + this(stream, null); + } + /** Constructor with InputStream and supplied encoding */ + public LdapUrlParser(java.io.InputStream stream, String encoding) { + try { jj_input_stream = new SimpleCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); } token_source = new LdapUrlParserTokenManager(jj_input_stream); token = new Token(); jj_ntk = -1; jj_gen = 0; - for (int i = 0; i < 31; i++) jj_la1[i] = -1; + for (int i = 0; i < 34; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } + /** Reinitialise. */ public void ReInit(java.io.InputStream stream) { - jj_input_stream.ReInit(stream, 1, 1); + ReInit(stream, null); + } + /** Reinitialise. */ + public void ReInit(java.io.InputStream stream, String encoding) { + try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); } token_source.ReInit(jj_input_stream); token = new Token(); jj_ntk = -1; jj_gen = 0; - for (int i = 0; i < 31; i++) jj_la1[i] = -1; + for (int i = 0; i < 34; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } + /** Constructor. */ public LdapUrlParser(java.io.Reader stream) { jj_input_stream = new SimpleCharStream(stream, 1, 1); token_source = new LdapUrlParserTokenManager(jj_input_stream); token = new Token(); jj_ntk = -1; jj_gen = 0; - for (int i = 0; i < 31; i++) jj_la1[i] = -1; + for (int i = 0; i < 34; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } + /** Reinitialise. */ public void ReInit(java.io.Reader stream) { jj_input_stream.ReInit(stream, 1, 1); token_source.ReInit(jj_input_stream); token = new Token(); jj_ntk = -1; jj_gen = 0; - for (int i = 0; i < 31; i++) jj_la1[i] = -1; + for (int i = 0; i < 34; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } + /** Constructor with generated Token Manager. */ public LdapUrlParser(LdapUrlParserTokenManager tm) { token_source = tm; token = new Token(); jj_ntk = -1; jj_gen = 0; - for (int i = 0; i < 31; i++) jj_la1[i] = -1; + for (int i = 0; i < 34; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } + /** Reinitialise. */ public void ReInit(LdapUrlParserTokenManager tm) { token_source = tm; token = new Token(); jj_ntk = -1; jj_gen = 0; - for (int i = 0; i < 31; i++) jj_la1[i] = -1; + for (int i = 0; i < 34; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } @@ -829,6 +884,8 @@ return false; } + +/** Get the next Token. */ final public Token getNextToken() { if (token.next != null) token = token.next; else token = token.next = token_source.getNextToken(); @@ -837,8 +894,9 @@ return token; } +/** Get the specific Token. */ final public Token getToken(int index) { - Token t = lookingAhead ? jj_scanpos : token; + Token t = token; for (int i = 0; i < index; i++) { if (t.next != null) t = t.next; else t = t.next = token_source.getNextToken(); @@ -853,7 +911,7 @@ return (jj_ntk = jj_nt.kind); } - private java.util.Vector jj_expentries = new java.util.Vector(); + private java.util.List jj_expentries = new java.util.ArrayList(); private int[] jj_expentry; private int jj_kind = -1; private int[] jj_lasttokens = new int[100]; @@ -868,36 +926,31 @@ for (int i = 0; i < jj_endpos; i++) { jj_expentry[i] = jj_lasttokens[i]; } - boolean exists = false; - for (java.util.Enumeration e = jj_expentries.elements(); e.hasMoreElements();) { - int[] oldentry = (int[])(e.nextElement()); + jj_entries_loop: for (java.util.Iterator it = jj_expentries.iterator(); it.hasNext();) { + int[] oldentry = (int[])(it.next()); if (oldentry.length == jj_expentry.length) { - exists = true; for (int i = 0; i < jj_expentry.length; i++) { if (oldentry[i] != jj_expentry[i]) { - exists = false; - break; + continue jj_entries_loop; } } - if (exists) break; + jj_expentries.add(jj_expentry); + break jj_entries_loop; } } - if (!exists) jj_expentries.addElement(jj_expentry); if (pos != 0) jj_lasttokens[(jj_endpos = pos) - 1] = kind; } } + /** Generate ParseException. */ public ParseException generateParseException() { - jj_expentries.removeAllElements(); - boolean[] la1tokens = new boolean[18]; - for (int i = 0; i < 18; i++) { - la1tokens[i] = false; - } + jj_expentries.clear(); + boolean[] la1tokens = new boolean[19]; if (jj_kind >= 0) { la1tokens[jj_kind] = true; jj_kind = -1; } - for (int i = 0; i < 31; i++) { + for (int i = 0; i < 34; i++) { if (jj_la1[i] == jj_gen) { for (int j = 0; j < 32; j++) { if ((jj_la1_0[i] & (1< jj_gen) { @@ -942,6 +998,7 @@ } p = p.next; } while (p != null); + } catch(LookaheadSuccess ls) { } } jj_rescan = false; } Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/LdapUrlParserConstants.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/LdapUrlParserConstants.java?rev=798469&r1=798468&r2=798469&view=diff ============================================================================== --- harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/LdapUrlParserConstants.java (original) +++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/LdapUrlParserConstants.java Tue Jul 28 09:30:33 2009 @@ -15,31 +15,54 @@ * limitations under the License. */ /* Generated By:JavaCC: Do not edit this line. LdapUrlParserConstants.java */ - package org.apache.harmony.jndi.provider.ldap.parser; + +/** + * Token literal values and constants. + * Generated by org.javacc.parser.OtherFilesGen#start() + */ public interface LdapUrlParserConstants { + /** End of File. */ int EOF = 0; + /** RegularExpression Id. */ int SCHEME = 1; + /** RegularExpression Id. */ int PRE_XTOKEN = 2; + /** RegularExpression Id. */ int SCOPE = 3; + /** RegularExpression Id. */ int COMMA = 4; + /** RegularExpression Id. */ int QUESTION_MARK = 5; + /** RegularExpression Id. */ int SLASH = 6; + /** RegularExpression Id. */ int PERCENT = 7; + /** RegularExpression Id. */ int COLON = 8; + /** RegularExpression Id. */ int PERIOD = 9; + /** RegularExpression Id. */ int EXCLAM_MARK = 10; + /** RegularExpression Id. */ int EQUAL = 11; + /** RegularExpression Id. */ int HEX_CHAR = 12; + /** RegularExpression Id. */ int NOHEX_CHAR = 13; + /** RegularExpression Id. */ int DIGIT = 14; + /** RegularExpression Id. */ int ZERO = 15; + /** RegularExpression Id. */ int CHAR = 16; + /** Lexical state. */ int DEFAULT = 0; + /** Literal token values. */ String[] tokenImage = { "", "", @@ -59,6 +82,7 @@ "\"0\"", "", "\"\\n\"", + "\"\\u0085\"", }; } Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/LdapUrlParserTokenManager.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/LdapUrlParserTokenManager.java?rev=798469&r1=798468&r2=798469&view=diff ============================================================================== --- harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/LdapUrlParserTokenManager.java (original) +++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/LdapUrlParserTokenManager.java Tue Jul 28 09:30:33 2009 @@ -15,7 +15,6 @@ * 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; @@ -26,9 +25,13 @@ import org.apache.harmony.jndi.provider.ldap.Filter; import org.apache.harmony.jndi.provider.ldap.asn1.Utils; +/** Token Manager. */ public class LdapUrlParserTokenManager implements LdapUrlParserConstants { + + /** Debug output. */ public java.io.PrintStream debugStream = System.out; + /** Set debug output. */ public void setDebugStream(java.io.PrintStream ds) { debugStream = ds; } private final int jjStopStringLiteralDfa_0(int pos, long active0) { @@ -48,15 +51,7 @@ 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() +private int jjMoveStringLiteralDfa0_0() { switch(curChar) { @@ -80,51 +75,22 @@ return jjStopAtPos(0, 11); case 63: return jjStopAtPos(0, 5); + case 133: + return jjStopAtPos(0, 18); 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 + 0x0L, 0x0L, 0xffffffffffffffdfL, 0xffffffffffffffffL }; -private final int jjMoveNfa_0(int startState, int curPos) +private int jjMoveNfa_0(int startState, int curPos) { - int[] nextStates; int startsAt = 0; jjnewStateCnt = 29; int i = 1; jjstateSet[0] = startState; - int j, kind = 0x7fffffff; + int kind = 0x7fffffff; for (;;) { if (++jjround == 0x7fffffff) @@ -132,7 +98,7 @@ if (curChar < 64) { long l = 1L << curChar; - MatchLoop: do + do { switch(jjstateSet[--i]) { @@ -184,7 +150,7 @@ else if (curChar < 128) { long l = 1L << (curChar & 077); - MatchLoop: do + do { switch(jjstateSet[--i]) { @@ -306,7 +272,7 @@ { int i2 = (curChar & 0xff) >> 6; long l2 = 1L << (curChar & 077); - MatchLoop: do + do { switch(jjstateSet[--i]) { @@ -334,27 +300,34 @@ static final int[] jjnextStates = { 22, 28, }; + +/** Token literal values. */ public static final String[] jjstrLiteralImages = { "", null, null, null, "\54", "\77", "\57", "\45", "\72", "\56", "\41", "\75", -null, null, null, "\60", null, "\12", }; +null, null, null, "\60", null, "\12", "\205", }; + +/** Lexer state names. */ public static final String[] lexStateNames = { - "DEFAULT", + "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) -{ +/** Constructor. */ +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) -{ + +/** Constructor. */ +public LdapUrlParserTokenManager(SimpleCharStream stream, int lexState){ this(stream); SwitchTo(lexState); } + +/** Reinitialise parser. */ public void ReInit(SimpleCharStream stream) { jjmatchedPos = jjnewStateCnt = 0; @@ -369,11 +342,15 @@ for (i = 29; i-- > 0;) jjrounds[i] = 0x80000000; } + +/** Reinitialise parser. */ public void ReInit(SimpleCharStream stream, int lexState) { ReInit(stream); SwitchTo(lexState); } + +/** Switch to specified lex state. */ public void SwitchTo(int lexState) { if (lexState >= 1 || lexState < 0) @@ -384,14 +361,25 @@ protected Token jjFillToken() { - Token t = Token.newToken(jjmatchedKind); - t.kind = jjmatchedKind; + final Token t; + final String curTokenImage; + final int beginLine; + final int endLine; + final int beginColumn; + final int endColumn; 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(); + curTokenImage = (im == null) ? input_stream.GetImage() : im; + beginLine = input_stream.getBeginLine(); + beginColumn = input_stream.getBeginColumn(); + endLine = input_stream.getEndLine(); + endColumn = input_stream.getEndColumn(); + t = Token.newToken(jjmatchedKind, curTokenImage); + + t.beginLine = beginLine; + t.endLine = endLine; + t.beginColumn = beginColumn; + t.endColumn = endColumn; + return t; } @@ -402,22 +390,21 @@ int jjmatchedPos; int jjmatchedKind; +/** Get the next Token. */ public Token getNextToken() { - int kind; - Token specialToken = null; Token matchedToken; int curPos = 0; EOFLoop : for (;;) - { - try - { + { + try + { curChar = input_stream.BeginToken(); - } + } catch(java.io.IOException e) - { + { jjmatchedKind = 0; matchedToken = jjFillToken(); return matchedToken; @@ -456,4 +443,24 @@ } } +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 void jjCheckNAddTwoStates(int state1, int state2) +{ + jjCheckNAdd(state1); + jjCheckNAdd(state2); +} + } Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/ParseException.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/ParseException.java?rev=798469&r1=798468&r2=798469&view=diff ============================================================================== --- harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/ParseException.java (original) +++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/ParseException.java Tue Jul 28 09:30:33 2009 @@ -14,7 +14,8 @@ * 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 */ +/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 4.1 */ +/* JavaCCOptions:KEEP_LINE_COL=null */ package org.apache.harmony.jndi.provider.ldap.parser; @@ -30,24 +31,24 @@ public class ParseException extends Exception { /** + * The version identifier for this Serializable class. + * Increment only if the serialized form of the + * class changes. + */ + private static final long serialVersionUID = 1L; + + /** * 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: + * "expectedTokenSequences", and "tokenImage" set. */ public ParseException(Token currentTokenVal, int[][] expectedTokenSequencesVal, String[] tokenImageVal ) { - super(""); - specialConstructor = true; + super(initialise(currentTokenVal, expectedTokenSequencesVal, tokenImageVal)); currentToken = currentTokenVal; expectedTokenSequences = expectedTokenSequencesVal; tokenImage = tokenImageVal; @@ -65,20 +66,13 @@ public ParseException() { super(); - specialConstructor = false; } + /** Constructor with message. */ 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 @@ -102,32 +96,29 @@ 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 + * 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 + * from the parser) the correct error message * gets displayed. */ - public String getMessage() { - if (!specialConstructor) { - return super.getMessage(); - } - String expected = ""; + private static String initialise(Token currentToken, + int[][] expectedTokenSequences, + String[] tokenImage) { + String eol = System.getProperty("line.separator", "\n"); + StringBuffer expected = new StringBuffer(); 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]] + " "; + expected.append(tokenImage[expectedTokenSequences[i][j]]).append(' '); } if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) { - expected += "..."; + expected.append("..."); } - expected += eol + " "; + expected.append(eol).append(" "); } String retval = "Encountered \""; Token tok = currentToken.next; @@ -137,8 +128,11 @@ retval += tokenImage[0]; break; } + retval += " " + tokenImage[tok.kind]; + retval += " \""; retval += add_escapes(tok.image); - tok = tok.next; + retval += " \""; + tok = tok.next; } retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn; retval += "." + eol; @@ -147,7 +141,7 @@ } else { retval += "Was expecting one of:" + eol + " "; } - retval += expected; + retval += expected.toString(); return retval; } @@ -155,14 +149,14 @@ * 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) { - StringBuilder retval = new StringBuilder(); + static String add_escapes(String str) { + StringBuffer retval = new StringBuffer(); char ch; for (int i = 0; i < str.length(); i++) { switch (str.charAt(i)) @@ -207,3 +201,4 @@ } } +/* JavaCC - OriginalChecksum=4c334b6dd8be70ea08da1a0aac4716b8 (do not edit this line) */ Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/SimpleCharStream.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/SimpleCharStream.java?rev=798469&r1=798468&r2=798469&view=diff ============================================================================== --- harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/SimpleCharStream.java (original) +++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/SimpleCharStream.java Tue Jul 28 09:30:33 2009 @@ -14,7 +14,8 @@ * 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 */ +/* Generated By:JavaCC: Do not edit this line. SimpleCharStream.java Version 4.1 */ +/* JavaCCOptions:STATIC=false,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ package org.apache.harmony.jndi.provider.ldap.parser; @@ -25,10 +26,12 @@ public class SimpleCharStream { +/** Whether parser is static. */ public static final boolean staticFlag = false; int bufsize; int available; int tokenBegin; +/** Position in buffer. */ public int bufpos = -1; protected int bufline[]; protected int bufcolumn[]; @@ -44,213 +47,224 @@ protected char[] buffer; protected int maxNextCharInd = 0; protected int inBuf = 0; + protected int tabSize = 8; + + protected void setTabSize(int i) { tabSize = i; } + protected int getTabSize(int i) { return tabSize; } + 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; + char[] newbuffer = new char[bufsize + 2048]; + int newbufline[] = new int[bufsize + 2048]; + int newbufcolumn[] = new int[bufsize + 2048]; - maxNextCharInd = (bufpos += (bufsize - tokenBegin)); - } - else - { - System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); - buffer = newbuffer; + 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(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); + bufline = newbufline; - System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); - bufcolumn = newbufcolumn; + System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); + bufcolumn = newbufcolumn; - maxNextCharInd = (bufpos -= tokenBegin); - } - } - catch (Throwable t) - { - throw new Error(t.getMessage()); - } + maxNextCharInd = (bufpos -= tokenBegin); + } + } + catch (Throwable t) + { + throw new Error(t.getMessage()); + } - bufsize += 2048; - available = bufsize; - tokenBegin = 0; + bufsize += 2048; + available = bufsize; + tokenBegin = 0; } protected void FillBuff() throws java.io.IOException { - if (maxNextCharInd == available) - { - if (available == bufsize) + if (maxNextCharInd == available) + { + if (available == bufsize) + { + if (tokenBegin > 2048) { - if (tokenBegin > 2048) - { - bufpos = maxNextCharInd = 0; - available = tokenBegin; - } - else if (tokenBegin < 0) - bufpos = maxNextCharInd = 0; - else - ExpandBuff(false); + bufpos = maxNextCharInd = 0; + available = tokenBegin; } - else if (available > tokenBegin) - available = bufsize; - else if ((tokenBegin - available) < 2048) - ExpandBuff(true); + else if (tokenBegin < 0) + bufpos = maxNextCharInd = 0; else - available = tokenBegin; - } + 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; - } + 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; + } } +/** Start. */ public char BeginToken() throws java.io.IOException { - tokenBegin = -1; - char c = readChar(); - tokenBegin = bufpos; + tokenBegin = -1; + char c = readChar(); + tokenBegin = bufpos; - return c; + return c; } protected void UpdateLineColumn(char c) { - column++; + column++; - if (prevCharIsLF) - { - prevCharIsLF = false; + if (prevCharIsLF) + { + prevCharIsLF = false; + line += (column = 1); + } + else if (prevCharIsCR) + { + prevCharIsCR = false; + if (c == '\n') + { + prevCharIsLF = true; + } + else 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; - } + switch (c) + { + case '\r' : + prevCharIsCR = true; + break; + case '\n' : + prevCharIsLF = true; + break; + case '\t' : + column--; + column += (tabSize - (column % tabSize)); + break; + default : + break; + } - bufline[bufpos] = line; - bufcolumn[bufpos] = column; + bufline[bufpos] = line; + bufcolumn[bufpos] = column; } +/** Read a character. */ public char readChar() throws java.io.IOException { - if (inBuf > 0) - { - --inBuf; + if (inBuf > 0) + { + --inBuf; - if (++bufpos == bufsize) - bufpos = 0; + if (++bufpos == bufsize) + bufpos = 0; - return buffer[bufpos]; - } + return buffer[bufpos]; + } - if (++bufpos >= maxNextCharInd) - FillBuff(); + if (++bufpos >= maxNextCharInd) + FillBuff(); - char c = buffer[bufpos]; + char c = buffer[bufpos]; - UpdateLineColumn(c); - return (c); + UpdateLineColumn(c); + return c; } /** - * @deprecated + * @deprecated * @see #getEndColumn */ public int getColumn() { - return bufcolumn[bufpos]; + return bufcolumn[bufpos]; } /** - * @deprecated + * @deprecated * @see #getEndLine */ public int getLine() { - return bufline[bufpos]; + return bufline[bufpos]; } + /** Get token end column number. */ public int getEndColumn() { - return bufcolumn[bufpos]; + return bufcolumn[bufpos]; } + /** Get token end line number. */ public int getEndLine() { return bufline[bufpos]; } + /** Get token beginning column number. */ public int getBeginColumn() { - return bufcolumn[tokenBegin]; + return bufcolumn[tokenBegin]; } + /** Get token beginning line number. */ public int getBeginLine() { - return bufline[tokenBegin]; + return bufline[tokenBegin]; } +/** Backup a number of characters. */ public void backup(int amount) { inBuf += amount; if ((bufpos -= amount) < 0) - bufpos += bufsize; + bufpos += bufsize; } + /** Constructor. */ public SimpleCharStream(java.io.Reader dstream, int startline, int startcolumn, int buffersize) { @@ -264,16 +278,20 @@ bufcolumn = new int[buffersize]; } + /** Constructor. */ public SimpleCharStream(java.io.Reader dstream, int startline, - int startcolumn) + int startcolumn) { - this(dstream, startline, startcolumn, 4096); + this(dstream, startline, startcolumn, 4096); } + /** Constructor. */ public SimpleCharStream(java.io.Reader dstream) { - this(dstream, 1, 1, 4096); + this(dstream, 1, 1, 4096); } + + /** Reinitialise. */ public void ReInit(java.io.Reader dstream, int startline, int startcolumn, int buffersize) { @@ -293,78 +311,128 @@ bufpos = -1; } + /** Reinitialise. */ public void ReInit(java.io.Reader dstream, int startline, - int startcolumn) + int startcolumn) { - ReInit(dstream, startline, startcolumn, 4096); + ReInit(dstream, startline, startcolumn, 4096); } + /** Reinitialise. */ public void ReInit(java.io.Reader dstream) { - ReInit(dstream, 1, 1, 4096); + ReInit(dstream, 1, 1, 4096); + } + /** Constructor. */ + public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline, + int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException + { + this(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize); } + + /** Constructor. */ public SimpleCharStream(java.io.InputStream dstream, int startline, int startcolumn, int buffersize) { - this(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096); + this(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize); + } + + /** Constructor. */ + public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline, + int startcolumn) throws java.io.UnsupportedEncodingException + { + this(dstream, encoding, startline, startcolumn, 4096); } + /** Constructor. */ public SimpleCharStream(java.io.InputStream dstream, int startline, - int startcolumn) + int startcolumn) + { + this(dstream, startline, startcolumn, 4096); + } + + /** Constructor. */ + public SimpleCharStream(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException { - this(dstream, startline, startcolumn, 4096); + this(dstream, encoding, 1, 1, 4096); } + /** Constructor. */ public SimpleCharStream(java.io.InputStream dstream) { - this(dstream, 1, 1, 4096); + this(dstream, 1, 1, 4096); } + /** Reinitialise. */ + public void ReInit(java.io.InputStream dstream, String encoding, int startline, + int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException + { + ReInit(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize); + } + + /** Reinitialise. */ public void ReInit(java.io.InputStream dstream, int startline, int startcolumn, int buffersize) { - ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096); + ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize); + } + + /** Reinitialise. */ + public void ReInit(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException + { + ReInit(dstream, encoding, 1, 1, 4096); } + /** Reinitialise. */ public void ReInit(java.io.InputStream dstream) { - ReInit(dstream, 1, 1, 4096); + ReInit(dstream, 1, 1, 4096); + } + /** Reinitialise. */ + public void ReInit(java.io.InputStream dstream, String encoding, int startline, + int startcolumn) throws java.io.UnsupportedEncodingException + { + ReInit(dstream, encoding, startline, startcolumn, 4096); } + /** Reinitialise. */ public void ReInit(java.io.InputStream dstream, int startline, - int startcolumn) + int startcolumn) { - ReInit(dstream, startline, startcolumn, 4096); + ReInit(dstream, startline, startcolumn, 4096); } + /** Get token literal value. */ 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); + 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); } + /** Get the suffix. */ public char[] GetSuffix(int len) { - char[] ret = new char[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); - } + 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; + return ret; } + /** Reset buffer when finished. */ public void Done() { - buffer = null; - bufline = null; - bufcolumn = null; + buffer = null; + bufline = null; + bufcolumn = null; } /** @@ -372,47 +440,47 @@ */ public void adjustBeginLineColumn(int newLine, int newCol) { - int start = tokenBegin; - int len; + 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; + if (bufpos >= tokenBegin) + { + len = bufpos - tokenBegin + inBuf + 1; + } + else + { + len = bufsize - tokenBegin + bufpos + 1 + inBuf; + } - while (i++ < len) - { - if (bufline[j = start % bufsize] != bufline[++start % bufsize]) - bufline[j] = newLine++; - else - bufline[j] = newLine; - } - } + 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]; + line = bufline[j]; + column = bufcolumn[j]; } } +/* JavaCC - OriginalChecksum=c7d7f116917bc9c5d71f4887a60de40d (do not edit this line) */ Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/Token.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/Token.java?rev=798469&r1=798468&r2=798469&view=diff ============================================================================== --- harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/Token.java (original) +++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/Token.java Tue Jul 28 09:30:33 2009 @@ -14,7 +14,8 @@ * 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 */ +/* Generated By:JavaCC: Do not edit this line. Token.java Version 4.1 */ +/* JavaCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COL=null,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ package org.apache.harmony.jndi.provider.ldap.parser; @@ -22,7 +23,14 @@ * Describes the input token stream. */ -public class Token { +public class Token implements java.io.Serializable { + + /** + * The version identifier for this Serializable class. + * Increment only if the serialized form of the + * class changes. + */ + private static final long serialVersionUID = 1L; /** * An integer that describes the kind of this token. This numbering @@ -31,12 +39,14 @@ */ 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 line number of the first character of this Token. */ + public int beginLine; + /** The column number of the first character of this Token. */ + public int beginColumn; + /** The line number of the last character of this Token. */ + public int endLine; + /** The column number of the last character of this Token. */ + public int endColumn; /** * The string image of the token. @@ -68,11 +78,45 @@ public Token specialToken; /** + * An optional attribute value of the Token. + * Tokens which are not used as syntactic sugar will often contain + * meaningful values that will be used later on by the compiler or + * interpreter. This attribute value is often different from the image. + * Any subclass of Token that actually wants to return a non-null value can + * override this method as appropriate. + */ + public Object getValue() { + return null; + } + + /** + * No-argument constructor + */ + public Token() {} + + /** + * Constructs a new token for the specified Image. + */ + public Token(int kind) + { + this(kind, null); + } + + /** + * Constructs a new token for the specified Image and Kind. + */ + public Token(int kind, String image) + { + this.kind = kind; + this.image = image; + } + + /** * Returns the image. */ public String toString() { - return image; + return image; } /** @@ -80,19 +124,25 @@ * 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 : + * you want to create if ofKind is ID, simply add something like : * - * case MyParserConstants.ID : return new IDToken(); + * case MyParserConstants.ID : return new IDToken(ofKind, image); * * to the following switch statement. Then you can cast matchedToken - * variable to the appropriate type and use it in your lexical actions. + * variable to the appropriate type and use sit in your lexical actions. */ - public static final Token newToken(int ofKind) + public static Token newToken(int ofKind, String image) + { + switch(ofKind) + { + default : return new Token(ofKind, image); + } + } + + public static Token newToken(int ofKind) { - switch(ofKind) - { - default : return new Token(); - } + return newToken(ofKind, null); } } +/* JavaCC - OriginalChecksum=19c968a79a3718e11822f400c8623327 (do not edit this line) */ Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/TokenMgrError.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/TokenMgrError.java?rev=798469&r1=798468&r2=798469&view=diff ============================================================================== --- harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/TokenMgrError.java (original) +++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/TokenMgrError.java Tue Jul 28 09:30:33 2009 @@ -1,3 +1,5 @@ +/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 4.1 */ +/* JavaCCOptions: */ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -14,137 +16,151 @@ * 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 */ +/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 4.1 */ +/* JavaCCOptions: */ package org.apache.harmony.jndi.provider.ldap.parser; +/** Token Manager Error. */ 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) { - StringBuilder retval = new StringBuilder(); - 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); - } + /** + * The version identifier for this Serializable class. + * Increment only if the serialized form of the + * class changes. + */ + private static final long serialVersionUID = 1L; + + /* + * Ordinals for various reasons why an Error of this type can be thrown. + */ + + /** + * Lexical error occurred. + */ + static final int LEXICAL_ERROR = 0; + + /** + * An attempt was 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 escaped (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 lexical error + * curLexState : lexical state in which this error occurred + * errorLine : line number when the error occurred + * errorColumn : column number when the error occurred + * errorAfter : prefix that was seen before this error occurred + * 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. + */ + + /** No arg constructor. */ + public TokenMgrError() { + } + + /** Constructor with message and reason. */ + public TokenMgrError(String message, int reason) { + super(message); + errorCode = reason; + } + + /** Full Constructor. */ + 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); + } } +/* JavaCC - OriginalChecksum=6b4a38ce96dcb6e22ad144cf7cbd370c (do not edit this line) */ Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/filter.g URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/filter.g?rev=798469&r1=798468&r2=798469&view=diff ============================================================================== --- harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/filter.g (original) +++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/filter.g Tue Jul 28 09:30:33 2009 @@ -214,7 +214,7 @@ | | - + } String option(): @@ -317,7 +317,7 @@ } } - parse() "\n" test() | LOOKAHEAD(2) "\n" | "\n" | + parse() ("\n" | "\u0085") test() | LOOKAHEAD(2) ("\n" | "\u0085") | ("\n" | "\u0085") | } // FIXME: get string representation of AttributeValue, then use Rdn.unescapeValue(String) to get value String value(): Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/url.g URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/url.g?rev=798469&r1=798468&r2=798469&view=diff ============================================================================== --- harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/url.g (original) +++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/parser/url.g Tue Jul 28 09:30:33 2009 @@ -181,7 +181,7 @@ | | - + } @@ -394,5 +394,5 @@ void test(): {} { - parseURL() "\n" test() | LOOKAHEAD(2) "\n" | "\n" | + parseURL() ("\n" | "\u0085") test() | LOOKAHEAD(2) ("\n" | "\u0085") | ("\n" | "\u0085") | } Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/CompositeNameTest.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/CompositeNameTest.java?rev=798469&r1=798468&r2=798469&view=diff ============================================================================== --- harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/CompositeNameTest.java (original) +++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/CompositeNameTest.java Tue Jul 28 09:30:33 2009 @@ -153,6 +153,66 @@ assertEquals("test's", new CompositeName("test's").toString()); assertEquals("test", new CompositeName("'test'").toString()); + + name = new CompositeName("O=\"s,g"); + assertEquals("O=\"s,g", name.toString()); + + name = new CompositeName("\"O=/s\""); + assertEquals("O=/s", name.get(0)); + + name.add("s/s"); + assertEquals(2, name.size()); + assertEquals("\"O=/s\"/\"s/s\"", name.toString()); + + name.add("ss"); + assertEquals(3, name.size()); + assertEquals("\"O=/s\"/\"s/s\"/ss", name.toString()); + + name = new CompositeName("\"O=\\s\""); + assertEquals("O=\\s", name.toString()); + + CompositeName name = new CompositeName(""); + name.add("abc/abc"); + assertEquals(1, name.size()); + + CompositeName newCompositeName = new CompositeName(name.toString()); + assertEquals(1, newCompositeName.size()); + assertEquals(newCompositeName, name); + + name = new CompositeName("O=\"s,g\""); + assertEquals("O=\"s,g\"", name.toString()); + + name = new CompositeName("O=#"); + assertEquals("O=#", name.toString()); + + name = new CompositeName("O=\\s"); + assertEquals("O=\\s", name.toString()); + + name = new CompositeName("\"O=\\s\""); + assertEquals("O=\\s", name.toString()); + + name = new CompositeName("O=/s"); + assertEquals("O=/s", name.toString()); + + name = new CompositeName("\"O=\"/\"s\""); + assertEquals(2,name.size()); + assertEquals("O=/s", name.toString()); + + name = new CompositeName(""); + assertEquals(0,name.size()); + assertEquals("", name.toString()); + + name = new CompositeName("\"\""); + assertEquals(1,name.size()); + assertEquals("/", name.toString()); + + name = new CompositeName("\"\"/\"\""); + assertEquals(2,name.size()); + assertEquals("//", name.toString()); + + name = new CompositeName("\"O=/s\""); + assertEquals("\"O=/s\"", name.toString()); + } /** Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/LdapNameTest.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/LdapNameTest.java?rev=798469&r1=798468&r2=798469&view=diff ============================================================================== --- harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/LdapNameTest.java (original) +++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/LdapNameTest.java Tue Jul 28 09:30:33 2009 @@ -621,6 +621,14 @@ new LdapName(" =b"); fail("InvalidNameException expected"); } catch (InvalidNameException e) {} + + LdapName ldapName = new LdapName("cn=a+"); + assertEquals("cn=a+", ldapName.toString()); + assertEquals("cn=a", ldapName.getRdns().get(0).toString()); + + ldapName = new LdapName("cn=\\+"); + assertEquals("cn=\\+", ldapName.toString()); + assertEquals("cn=\\+", ldapName.getRdns().get(0).toString()); } /** @@ -646,7 +654,225 @@ fail("InvalidNameException expected"); } catch (InvalidNameException e) {} } + + /** + *

+ * Test method for 'javax.naming.ldap.LdapName(String)' + *

+ *

+ * Here we are testing the constructor, this method should accept a + * String notice here that here that we are testing the special case + * in which the name is quoted and the meta characters in it are ignored. + *

+ *

+ * The expected result is an instance of the class. + *

+ */ + public void testLdapNameString054() throws Exception { + LdapName ldapName; + String stringName; + + stringName = "dc=apacheorg\""; + ldapName = new LdapName(stringName); + assertEquals(stringName, ldapName.toString()); + + stringName = "dc=\"apache,org\""; + ldapName = new LdapName(stringName); + assertEquals(stringName, ldapName.toString()); + + stringName = "dc=\"apache;org\""; + ldapName = new LdapName(stringName); + assertEquals(stringName, ldapName.toString()); + + stringName = "dc=\"apache\\\";org\""; + ldapName = new LdapName(stringName); + assertEquals(stringName, ldapName.toString()); + + stringName = "dc=apache\\\"org,O=org"; + ldapName = new LdapName(stringName); + assertEquals(stringName, ldapName.toString()); + + stringName = "\"az=a,O=a\""; + try{ + new LdapName(stringName); + fail("Should throw InvalidNameException"); + }catch(InvalidNameException e){ + //expected + } + + stringName = "dc=apache\\\";org,O=org"; + try{ + new LdapName(stringName); + fail("Should throw InvalidNameException"); + }catch(InvalidNameException e){ + //expected + } + + try{ + new LdapName("dc=apache,org"); + fail("Should throw InvalidNameException"); + }catch(InvalidNameException e){ + //expected + } + + try{ + new LdapName("dc=apache;org"); + fail("Should throw InvalidNameException"); + }catch(InvalidNameException e){ + //expected + } + + try{ + new LdapName("dc=\"apache\"harmony\"org\""); + fail("Should throw InvalidNameException"); + }catch(InvalidNameException e){ + //expected + } + + stringName = "DC=\"Apache,org\",DC=\"Apacheorg\""; + String expectedRdnsName = "DC=\"Apache,org\",DC=\"Apacheorg\""; + ldapName = new LdapName(stringName); + List rdns = ldapName.getRdns(); + assertEquals(2, rdns.size()); + assertEquals(expectedRdnsName, ldapName.toString()); + + stringName= "abc=\"DC:O=ab,DC=COM\",cn=apache\"org,O=harmony"; + new LdapName(stringName); + try { + stringName = "DC=A\"pache,org\",DC=\"Apacheorg\""; + ldapName = new LdapName(stringName); + fail("Should throw InvalidNameException"); + } catch (InvalidNameException e) { + // expected + } + + try { + stringName = "DC=\"Apache,org,DC=\"Apacheorg\""; + ldapName = new LdapName(stringName); + fail("Should throw InvalidNameException"); + } catch (InvalidNameException e) { + // expected + } + + try { + stringName = "DC=\"Apache,org,DC=\"Apacheorg"; + ldapName = new LdapName(stringName); + fail("Should throw InvalidNameException"); + } catch (InvalidNameException e) { + // expected + } + + try { + stringName = "+"; + ldapName = new LdapName(stringName); + fail("Should throw InvalidNameException"); + } catch (InvalidNameException e) { + // expected + } + + try { + stringName = ";"; + ldapName = new LdapName(stringName); + fail("Should throw InvalidNameException"); + } catch (InvalidNameException e) { + // expected + } + } + + /** + *

+ * Test method for 'javax.naming.ldap.LdapName(String)' + *

+ *

+ * Here we are testing the constructor, this method should accept a + * String notice here that here that we are testing the special case + * in which the name contains \\*, \\%, \\_ + *

+ *

+ * The expected result is an instance of the class. + *

+ */ + public void testLdapNameString055() throws Exception { + LdapName ldapName; + String stringName; + String expectedName; + String expectedRndName; + List rdns; + + // Test \\* + stringName = "dc=\\*"; + expectedName = "dc=\\*"; + expectedRndName = "dc=*"; + ldapName = new LdapName(stringName); + assertEquals(expectedName, ldapName.toString()); + rdns = ldapName.getRdns(); + assertEquals(expectedRndName, rdns.get(0).toString()); + + stringName = "dc=\"\\*\""; + expectedName = "dc=\"\\*\""; + expectedRndName = "dc=*"; + ldapName = new LdapName(stringName); + assertEquals(expectedName, ldapName.toString()); + rdns = ldapName.getRdns(); + assertEquals(expectedRndName, rdns.get(0).toString()); + + stringName = "dc=\\\\*"; + expectedName = "dc=\\\\*"; + ldapName = new LdapName(stringName); + assertEquals(expectedName, ldapName.toString()); + rdns = ldapName.getRdns(); + assertEquals(expectedName, rdns.get(0).toString()); + + // Test \\% + stringName = "dc=\\%"; + expectedName = "dc=\\%"; + expectedRndName = "dc=%"; + ldapName = new LdapName(stringName); + assertEquals(expectedName, ldapName.toString()); + rdns = ldapName.getRdns(); + assertEquals(expectedRndName, rdns.get(0).toString()); + + stringName = "dc=\"\\%\""; + expectedName = "dc=\"\\%\""; + expectedRndName = "dc=%"; + ldapName = new LdapName(stringName); + assertEquals(expectedName, ldapName.toString()); + rdns = ldapName.getRdns(); + assertEquals(expectedRndName, rdns.get(0).toString()); + + stringName = "dc=\\\\%"; + expectedName = "dc=\\\\%"; + ldapName = new LdapName(stringName); + assertEquals(expectedName, ldapName.toString()); + rdns = ldapName.getRdns(); + assertEquals(expectedName, rdns.get(0).toString()); + + // Test \\_ + stringName = "dc=\\_"; + expectedName = "dc=\\_"; + expectedRndName = "dc=_"; + ldapName = new LdapName(stringName); + assertEquals(expectedName, ldapName.toString()); + rdns = ldapName.getRdns(); + assertEquals(expectedRndName, rdns.get(0).toString()); + + stringName = "dc=\"\\_\""; + expectedName = "dc=\"\\_\""; + expectedRndName = "dc=_"; + ldapName = new LdapName(stringName); + assertEquals(expectedName, ldapName.toString()); + rdns = ldapName.getRdns(); + assertEquals(expectedRndName, rdns.get(0).toString()); + + stringName = "dc=\\\\_"; + expectedName = "dc=\\\\_"; + ldapName = new LdapName(stringName); + assertEquals(expectedName, ldapName.toString()); + rdns = ldapName.getRdns(); + assertEquals(expectedName, rdns.get(0).toString()); + } + /** *

* Test method for 'javax.naming.ldap.LdapName.LdapName(List)' Modified: harmony/enhanced/classlib/branches/java6/modules/lang-management/build.xml URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/lang-management/build.xml?rev=798469&r1=798468&r2=798469&view=diff ============================================================================== --- harmony/enhanced/classlib/branches/java6/modules/lang-management/build.xml (original) +++ harmony/enhanced/classlib/branches/java6/modules/lang-management/build.xml Tue Jul 28 09:30:33 2009 @@ -19,25 +19,11 @@ Build for LANG-MANAGEMENT component - + - - - - - - - - - - - - - - - + @@ -53,11 +39,12 @@ - + - - + + + @@ -67,11 +54,11 @@ - + - @@ -99,8 +86,8 @@ - - + + @@ -108,158 +95,61 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - + - - - - - - - - - + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + - - lang-management${line.separator} + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - lang-management${line.separator} + + Propchange: harmony/enhanced/classlib/branches/java6/modules/lang-management/src/test/api/java/org/apache/harmony/lang/management/tests/java/util/logging/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Tue Jul 28 09:30:33 2009 @@ -1 +1 @@ -/harmony/enhanced/classlib/trunk/modules/lang-management/src/test/api/java/org/apache/harmony/lang/management/tests/java/util/logging:768152-790471 +/harmony/enhanced/classlib/trunk/modules/lang-management/src/test/api/java/org/apache/harmony/lang/management/tests/java/util/logging:768152-798021