lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From markrmil...@apache.org
Subject svn commit: r827772 [2/6] - in /lucene/java/branches/flex_1458: ./ contrib/ contrib/instantiated/src/java/org/apache/lucene/store/instantiated/ contrib/misc/src/java/org/apache/lucene/queryParser/precedence/ contrib/queries/src/java/org/apache/lucene/s...
Date Tue, 20 Oct 2009 19:58:22 GMT
Modified: lucene/java/branches/flex_1458/src/demo/org/apache/lucene/demo/html/HTMLParserTokenManager.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/demo/org/apache/lucene/demo/html/HTMLParserTokenManager.java?rev=827772&r1=827771&r2=827772&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/demo/org/apache/lucene/demo/html/HTMLParserTokenManager.java (original)
+++ lucene/java/branches/flex_1458/src/demo/org/apache/lucene/demo/html/HTMLParserTokenManager.java Tue Oct 20 19:58:18 2009
@@ -3,9 +3,13 @@
 import java.io.*;
 import java.util.Properties;
 
+/** Token Manager. */
 public class HTMLParserTokenManager implements HTMLParserConstants
 {
+
+  /** 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)
 {
@@ -68,21 +72,13 @@
 {
    return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0), pos + 1);
 }
-private final int jjStopAtPos(int pos, int kind)
+private 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()
+private int jjMoveStringLiteralDfa0_0()
 {
    switch(curChar)
    {
@@ -92,7 +88,7 @@
          return jjMoveNfa_0(11, 0);
    }
 }
-private final int jjMoveStringLiteralDfa1_0(long active0)
+private int jjMoveStringLiteralDfa1_0(long active0)
 {
    try { curChar = input_stream.readChar(); }
    catch(java.io.IOException e) {
@@ -115,10 +111,10 @@
    }
    return jjStartNfa_0(0, active0);
 }
-private final int jjMoveStringLiteralDfa2_0(long old0, long active0)
+private int jjMoveStringLiteralDfa2_0(long old0, long active0)
 {
    if (((active0 &= old0)) == 0L)
-      return jjStartNfa_0(0, old0); 
+      return jjStartNfa_0(0, old0);
    try { curChar = input_stream.readChar(); }
    catch(java.io.IOException e) {
       jjStopStringLiteralDfa_0(1, active0);
@@ -135,10 +131,10 @@
    }
    return jjStartNfa_0(1, active0);
 }
-private final int jjMoveStringLiteralDfa3_0(long old0, long active0)
+private int jjMoveStringLiteralDfa3_0(long old0, long active0)
 {
    if (((active0 &= old0)) == 0L)
-      return jjStartNfa_0(1, old0); 
+      return jjStartNfa_0(1, old0);
    try { curChar = input_stream.readChar(); }
    catch(java.io.IOException e) {
       jjStopStringLiteralDfa_0(2, active0);
@@ -157,10 +153,10 @@
    }
    return jjStartNfa_0(2, active0);
 }
-private final int jjMoveStringLiteralDfa4_0(long old0, long active0)
+private int jjMoveStringLiteralDfa4_0(long old0, long active0)
 {
    if (((active0 &= old0)) == 0L)
-      return jjStartNfa_0(2, old0); 
+      return jjStartNfa_0(2, old0);
    try { curChar = input_stream.readChar(); }
    catch(java.io.IOException e) {
       jjStopStringLiteralDfa_0(3, active0);
@@ -175,10 +171,10 @@
    }
    return jjStartNfa_0(3, active0);
 }
-private final int jjMoveStringLiteralDfa5_0(long old0, long active0)
+private int jjMoveStringLiteralDfa5_0(long old0, long active0)
 {
    if (((active0 &= old0)) == 0L)
-      return jjStartNfa_0(3, old0); 
+      return jjStartNfa_0(3, old0);
    try { curChar = input_stream.readChar(); }
    catch(java.io.IOException e) {
       jjStopStringLiteralDfa_0(4, active0);
@@ -193,10 +189,10 @@
    }
    return jjStartNfa_0(4, active0);
 }
-private final int jjMoveStringLiteralDfa6_0(long old0, long active0)
+private int jjMoveStringLiteralDfa6_0(long old0, long active0)
 {
    if (((active0 &= old0)) == 0L)
-      return jjStartNfa_0(4, old0); 
+      return jjStartNfa_0(4, old0);
    try { curChar = input_stream.readChar(); }
    catch(java.io.IOException e) {
       jjStopStringLiteralDfa_0(5, active0);
@@ -213,47 +209,24 @@
    }
    return jjStartNfa_0(5, active0);
 }
-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)
+private int jjStartNfaWithStates_0(int pos, int kind, int state)
 {
-   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]);
+   jjmatchedKind = kind;
+   jjmatchedPos = pos;
+   try { curChar = input_stream.readChar(); }
+   catch(java.io.IOException e) { return pos + 1; }
+   return jjMoveNfa_0(state, pos + 1);
 }
 static final long[] jjbitVec0 = {
    0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL
 };
-private final int jjMoveNfa_0(int startState, int curPos)
+private int jjMoveNfa_0(int startState, int curPos)
 {
-   int[] nextStates;
    int startsAt = 0;
    jjnewStateCnt = 28;
    int i = 1;
    jjstateSet[0] = startState;
-   int j, kind = 0x7fffffff;
+   int kind = 0x7fffffff;
    for (;;)
    {
       if (++jjround == 0x7fffffff)
@@ -261,7 +234,7 @@
       if (curChar < 64)
       {
          long l = 1L << curChar;
-         MatchLoop: do
+         do
          {
             switch(jjstateSet[--i])
             {
@@ -417,7 +390,7 @@
       else if (curChar < 128)
       {
          long l = 1L << (curChar & 077);
-         MatchLoop: do
+         do
          {
             switch(jjstateSet[--i])
             {
@@ -489,7 +462,7 @@
       {
          int i2 = (curChar & 0xff) >> 6;
          long l2 = 1L << (curChar & 077);
-         MatchLoop: do
+         do
          {
             switch(jjstateSet[--i])
             {
@@ -526,18 +499,17 @@
       catch(java.io.IOException e) { return curPos; }
    }
 }
-private final int jjMoveStringLiteralDfa0_5()
+private int jjMoveStringLiteralDfa0_5()
 {
    return jjMoveNfa_5(1, 0);
 }
-private final int jjMoveNfa_5(int startState, int curPos)
+private int jjMoveNfa_5(int startState, int curPos)
 {
-   int[] nextStates;
    int startsAt = 0;
    jjnewStateCnt = 2;
    int i = 1;
    jjstateSet[0] = startState;
-   int j, kind = 0x7fffffff;
+   int kind = 0x7fffffff;
    for (;;)
    {
       if (++jjround == 0x7fffffff)
@@ -545,7 +517,7 @@
       if (curChar < 64)
       {
          long l = 1L << curChar;
-         MatchLoop: do
+         do
          {
             switch(jjstateSet[--i])
             {
@@ -575,7 +547,7 @@
       else if (curChar < 128)
       {
          long l = 1L << (curChar & 077);
-         MatchLoop: do
+         do
          {
             switch(jjstateSet[--i])
             {
@@ -592,7 +564,7 @@
       {
          int i2 = (curChar & 0xff) >> 6;
          long l2 = 1L << (curChar & 077);
-         MatchLoop: do
+         do
          {
             switch(jjstateSet[--i])
             {
@@ -633,15 +605,7 @@
 {
    return jjMoveNfa_7(jjStopStringLiteralDfa_7(pos, active0), pos + 1);
 }
-private final int jjStartNfaWithStates_7(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_7(state, pos + 1);
-}
-private final int jjMoveStringLiteralDfa0_7()
+private int jjMoveStringLiteralDfa0_7()
 {
    switch(curChar)
    {
@@ -651,14 +615,13 @@
          return jjMoveNfa_7(0, 0);
    }
 }
-private final int jjMoveNfa_7(int startState, int curPos)
+private int jjMoveNfa_7(int startState, int curPos)
 {
-   int[] nextStates;
    int startsAt = 0;
    jjnewStateCnt = 1;
    int i = 1;
    jjstateSet[0] = startState;
-   int j, kind = 0x7fffffff;
+   int kind = 0x7fffffff;
    for (;;)
    {
       if (++jjround == 0x7fffffff)
@@ -666,7 +629,7 @@
       if (curChar < 64)
       {
          long l = 1L << curChar;
-         MatchLoop: do
+         do
          {
             switch(jjstateSet[--i])
             {
@@ -683,7 +646,7 @@
       else if (curChar < 128)
       {
          long l = 1L << (curChar & 077);
-         MatchLoop: do
+         do
          {
             switch(jjstateSet[--i])
             {
@@ -699,7 +662,7 @@
       {
          int i2 = (curChar & 0xff) >> 6;
          long l2 = 1L << (curChar & 077);
-         MatchLoop: do
+         do
          {
             switch(jjstateSet[--i])
             {
@@ -727,18 +690,17 @@
       catch(java.io.IOException e) { return curPos; }
    }
 }
-private final int jjMoveStringLiteralDfa0_4()
+private int jjMoveStringLiteralDfa0_4()
 {
    return jjMoveNfa_4(1, 0);
 }
-private final int jjMoveNfa_4(int startState, int curPos)
+private int jjMoveNfa_4(int startState, int curPos)
 {
-   int[] nextStates;
    int startsAt = 0;
    jjnewStateCnt = 2;
    int i = 1;
    jjstateSet[0] = startState;
-   int j, kind = 0x7fffffff;
+   int kind = 0x7fffffff;
    for (;;)
    {
       if (++jjround == 0x7fffffff)
@@ -746,7 +708,7 @@
       if (curChar < 64)
       {
          long l = 1L << curChar;
-         MatchLoop: do
+         do
          {
             switch(jjstateSet[--i])
             {
@@ -776,7 +738,7 @@
       else if (curChar < 128)
       {
          long l = 1L << (curChar & 077);
-         MatchLoop: do
+         do
          {
             switch(jjstateSet[--i])
             {
@@ -793,7 +755,7 @@
       {
          int i2 = (curChar & 0xff) >> 6;
          long l2 = 1L << (curChar & 077);
-         MatchLoop: do
+         do
          {
             switch(jjstateSet[--i])
             {
@@ -834,15 +796,7 @@
 {
    return jjMoveNfa_3(jjStopStringLiteralDfa_3(pos, active0), pos + 1);
 }
-private final int jjStartNfaWithStates_3(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_3(state, pos + 1);
-}
-private final int jjMoveStringLiteralDfa0_3()
+private int jjMoveStringLiteralDfa0_3()
 {
    switch(curChar)
    {
@@ -854,14 +808,13 @@
          return jjMoveNfa_3(0, 0);
    }
 }
-private final int jjMoveNfa_3(int startState, int curPos)
+private int jjMoveNfa_3(int startState, int curPos)
 {
-   int[] nextStates;
    int startsAt = 0;
    jjnewStateCnt = 3;
    int i = 1;
    jjstateSet[0] = startState;
-   int j, kind = 0x7fffffff;
+   int kind = 0x7fffffff;
    for (;;)
    {
       if (++jjround == 0x7fffffff)
@@ -869,7 +822,7 @@
       if (curChar < 64)
       {
          long l = 1L << curChar;
-         MatchLoop: do
+         do
          {
             switch(jjstateSet[--i])
             {
@@ -907,7 +860,7 @@
       else if (curChar < 128)
       {
          long l = 1L << (curChar & 077);
-         MatchLoop: do
+         do
          {
             switch(jjstateSet[--i])
             {
@@ -925,7 +878,7 @@
       {
          int i2 = (curChar & 0xff) >> 6;
          long l2 = 1L << (curChar & 077);
-         MatchLoop: do
+         do
          {
             switch(jjstateSet[--i])
             {
@@ -984,15 +937,7 @@
 {
    return jjMoveNfa_6(jjStopStringLiteralDfa_6(pos, active0), pos + 1);
 }
-private final int jjStartNfaWithStates_6(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_6(state, pos + 1);
-}
-private final int jjMoveStringLiteralDfa0_6()
+private int jjMoveStringLiteralDfa0_6()
 {
    switch(curChar)
    {
@@ -1002,7 +947,7 @@
          return jjMoveNfa_6(1, 0);
    }
 }
-private final int jjMoveStringLiteralDfa1_6(long active0)
+private int jjMoveStringLiteralDfa1_6(long active0)
 {
    try { curChar = input_stream.readChar(); }
    catch(java.io.IOException e) {
@@ -1018,10 +963,10 @@
    }
    return jjStartNfa_6(0, active0);
 }
-private final int jjMoveStringLiteralDfa2_6(long old0, long active0)
+private int jjMoveStringLiteralDfa2_6(long old0, long active0)
 {
    if (((active0 &= old0)) == 0L)
-      return jjStartNfa_6(0, old0); 
+      return jjStartNfa_6(0, old0);
    try { curChar = input_stream.readChar(); }
    catch(java.io.IOException e) {
       jjStopStringLiteralDfa_6(1, active0);
@@ -1038,14 +983,13 @@
    }
    return jjStartNfa_6(1, active0);
 }
-private final int jjMoveNfa_6(int startState, int curPos)
+private int jjMoveNfa_6(int startState, int curPos)
 {
-   int[] nextStates;
    int startsAt = 0;
    jjnewStateCnt = 2;
    int i = 1;
    jjstateSet[0] = startState;
-   int j, kind = 0x7fffffff;
+   int kind = 0x7fffffff;
    for (;;)
    {
       if (++jjround == 0x7fffffff)
@@ -1053,7 +997,7 @@
       if (curChar < 64)
       {
          long l = 1L << curChar;
-         MatchLoop: do
+         do
          {
             switch(jjstateSet[--i])
             {
@@ -1083,7 +1027,7 @@
       else if (curChar < 128)
       {
          long l = 1L << (curChar & 077);
-         MatchLoop: do
+         do
          {
             switch(jjstateSet[--i])
             {
@@ -1100,7 +1044,7 @@
       {
          int i2 = (curChar & 0xff) >> 6;
          long l2 = 1L << (curChar & 077);
-         MatchLoop: do
+         do
          {
             switch(jjstateSet[--i])
             {
@@ -1129,18 +1073,17 @@
       catch(java.io.IOException e) { return curPos; }
    }
 }
-private final int jjMoveStringLiteralDfa0_1()
+private int jjMoveStringLiteralDfa0_1()
 {
    return jjMoveNfa_1(1, 0);
 }
-private final int jjMoveNfa_1(int startState, int curPos)
+private int jjMoveNfa_1(int startState, int curPos)
 {
-   int[] nextStates;
    int startsAt = 0;
    jjnewStateCnt = 12;
    int i = 1;
    jjstateSet[0] = startState;
-   int j, kind = 0x7fffffff;
+   int kind = 0x7fffffff;
    for (;;)
    {
       if (++jjround == 0x7fffffff)
@@ -1148,7 +1091,7 @@
       if (curChar < 64)
       {
          long l = 1L << curChar;
-         MatchLoop: do
+         do
          {
             switch(jjstateSet[--i])
             {
@@ -1197,7 +1140,7 @@
       else if (curChar < 128)
       {
          long l = 1L << (curChar & 077);
-         MatchLoop: do
+         do
          {
             switch(jjstateSet[--i])
             {
@@ -1242,7 +1185,7 @@
       {
          int i2 = (curChar & 0xff) >> 6;
          long l2 = 1L << (curChar & 077);
-         MatchLoop: do
+         do
          {
             switch(jjstateSet[--i])
             {
@@ -1287,15 +1230,7 @@
 {
    return jjMoveNfa_2(jjStopStringLiteralDfa_2(pos, active0), pos + 1);
 }
-private final int jjStartNfaWithStates_2(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_2(state, pos + 1);
-}
-private final int jjMoveStringLiteralDfa0_2()
+private int jjMoveStringLiteralDfa0_2()
 {
    switch(curChar)
    {
@@ -1309,14 +1244,21 @@
          return jjMoveNfa_2(0, 0);
    }
 }
-private final int jjMoveNfa_2(int startState, int curPos)
+private int jjStartNfaWithStates_2(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_2(state, pos + 1);
+}
+private int jjMoveNfa_2(int startState, int curPos)
 {
-   int[] nextStates;
    int startsAt = 0;
    jjnewStateCnt = 6;
    int i = 1;
    jjstateSet[0] = startState;
-   int j, kind = 0x7fffffff;
+   int kind = 0x7fffffff;
    for (;;)
    {
       if (++jjround == 0x7fffffff)
@@ -1324,7 +1266,7 @@
       if (curChar < 64)
       {
          long l = 1L << curChar;
-         MatchLoop: do
+         do
          {
             switch(jjstateSet[--i])
             {
@@ -1378,7 +1320,7 @@
       else if (curChar < 128)
       {
          long l = 1L << (curChar & 077);
-         MatchLoop: do
+         do
          {
             switch(jjstateSet[--i])
             {
@@ -1396,7 +1338,7 @@
       {
          int i2 = (curChar & 0xff) >> 6;
          long l2 = 1L << (curChar & 077);
-         MatchLoop: do
+         do
          {
             switch(jjstateSet[--i])
             {
@@ -1429,20 +1371,26 @@
    20, 21, 24, 12, 14, 16, 5, 8, 0, 4, 6, 0, 4, 6, 5, 0, 
    4, 6, 3, 4, 
 };
+
+/** Token literal values. */
 public static final String[] jjstrLiteralImages = {
 "", "\74\163\143\162\151\160\164", null, null, "\74\41\55\55", "\74\41", null, 
 null, null, null, null, null, null, null, null, null, null, "\75", null, null, 
 "\47", "\42", null, null, null, null, null, null, "\55\55\76", null, "\76", };
+
+/** Lexer state names. */
 public static final String[] lexStateNames = {
-   "DEFAULT", 
-   "WithinScript", 
-   "WithinTag", 
-   "AfterEquals", 
-   "WithinQuote1", 
-   "WithinQuote2", 
-   "WithinComment1", 
-   "WithinComment2", 
+   "DEFAULT",
+   "WithinScript",
+   "WithinTag",
+   "AfterEquals",
+   "WithinQuote1",
+   "WithinQuote2",
+   "WithinComment1",
+   "WithinComment2",
 };
+
+/** Lex State array. */
 public static final int[] jjnewLexState = {
    -1, 1, 2, 2, 6, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 3, 0, 2, 4, 5, -1, -1, 2, 
    -1, 2, -1, 0, -1, 0, 
@@ -1457,15 +1405,20 @@
 private final int[] jjrounds = new int[28];
 private final int[] jjstateSet = new int[56];
 protected char curChar;
+/** Constructor. */
 public HTMLParserTokenManager(SimpleCharStream stream){
    if (SimpleCharStream.staticFlag)
       throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer.");
    input_stream = stream;
 }
+
+/** Constructor. */
 public HTMLParserTokenManager(SimpleCharStream stream, int lexState){
    this(stream);
    SwitchTo(lexState);
 }
+
+/** Reinitialise parser. */
 public void ReInit(SimpleCharStream stream)
 {
    jjmatchedPos = jjnewStateCnt = 0;
@@ -1473,18 +1426,22 @@
    input_stream = stream;
    ReInitRounds();
 }
-private final void ReInitRounds()
+private void ReInitRounds()
 {
    int i;
    jjround = 0x80000001;
    for (i = 28; 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 >= 8 || lexState < 0)
@@ -1495,14 +1452,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;
 }
 
@@ -1513,22 +1481,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;
@@ -1622,4 +1589,31 @@
   }
 }
 
+private void jjCheckNAdd(int state)
+{
+   if (jjrounds[state] != jjround)
+   {
+      jjstateSet[jjnewStateCnt++] = state;
+      jjrounds[state] = jjround;
+   }
+}
+private 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);
+}
+
+private void jjCheckNAddStates(int start, int end)
+{
+   do {
+      jjCheckNAdd(jjnextStates[start]);
+   } while (start++ != end);
+}
+
 }

Modified: lucene/java/branches/flex_1458/src/demo/org/apache/lucene/demo/html/ParseException.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/demo/org/apache/lucene/demo/html/ParseException.java?rev=827772&r1=827771&r2=827772&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/demo/org/apache/lucene/demo/html/ParseException.java (original)
+++ lucene/java/branches/flex_1458/src/demo/org/apache/lucene/demo/html/ParseException.java Tue Oct 20 19:58:18 2009
@@ -1,4 +1,5 @@
-/* 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.lucene.demo.html;
 
 /**
@@ -51,6 +52,7 @@
     specialConstructor = false;
   }
 
+  /** Constructor with message. */
   public ParseException(String message) {
     super(message);
     specialConstructor = false;
@@ -105,7 +107,7 @@
         maxSize = expectedTokenSequences[i].length;
       }
       for (int j = 0; j < expectedTokenSequences[i].length; j++) {
-        expected.append(tokenImage[expectedTokenSequences[i][j]]).append(" ");
+        expected.append(tokenImage[expectedTokenSequences[i][j]]).append(' ');
       }
       if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) {
         expected.append("...");
@@ -120,8 +122,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;
@@ -138,7 +143,7 @@
    * 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
@@ -190,3 +195,4 @@
    }
 
 }
+/* JavaCC - OriginalChecksum=63b2008c66e199b79536447c26bee2ab (do not edit this line) */

Modified: lucene/java/branches/flex_1458/src/demo/org/apache/lucene/demo/html/SimpleCharStream.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/demo/org/apache/lucene/demo/html/SimpleCharStream.java?rev=827772&r1=827771&r2=827772&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/demo/org/apache/lucene/demo/html/SimpleCharStream.java (original)
+++ lucene/java/branches/flex_1458/src/demo/org/apache/lucene/demo/html/SimpleCharStream.java Tue Oct 20 19:58:18 2009
@@ -1,4 +1,5 @@
-/* Generated By:JavaCC: Do not edit this line. SimpleCharStream.java Version 4.0 */
+/* Generated By:JavaCC: Do not edit this line. SimpleCharStream.java Version 4.1 */
+/* JavaCCOptions:STATIC=false */
 package org.apache.lucene.demo.html;
 
 /**
@@ -8,10 +9,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[];
@@ -128,6 +131,7 @@
      }
   }
 
+/** Start. */
   public char BeginToken() throws java.io.IOException
   {
      tokenBegin = -1;
@@ -177,6 +181,7 @@
      bufcolumn[bufpos] = column;
   }
 
+/** Read a character. */
   public char readChar() throws java.io.IOException
   {
      if (inBuf > 0)
@@ -195,11 +200,11 @@
      char c = buffer[bufpos];
 
      UpdateLineColumn(c);
-     return (c);
+     return c;
   }
 
   /**
-   * @deprecated 
+   * @deprecated
    * @see #getEndColumn
    */
 
@@ -208,7 +213,7 @@
   }
 
   /**
-   * @deprecated 
+   * @deprecated
    * @see #getEndLine
    */
 
@@ -216,22 +221,27 @@
      return bufline[bufpos];
   }
 
+  /** Get token end column number. */
   public int getEndColumn() {
      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];
   }
 
+  /** Get token beginning line number. */
   public int getBeginLine() {
      return bufline[tokenBegin];
   }
 
+/** Backup a number of characters. */
   public void backup(int amount) {
 
     inBuf += amount;
@@ -239,6 +249,7 @@
        bufpos += bufsize;
   }
 
+  /** Constructor. */
   public SimpleCharStream(java.io.Reader dstream, int startline,
   int startcolumn, int buffersize)
   {
@@ -252,16 +263,20 @@
     bufcolumn = new int[buffersize];
   }
 
+  /** Constructor. */
   public SimpleCharStream(java.io.Reader dstream, int startline,
                           int startcolumn)
   {
      this(dstream, startline, startcolumn, 4096);
   }
 
+  /** Constructor. */
   public SimpleCharStream(java.io.Reader dstream)
   {
      this(dstream, 1, 1, 4096);
   }
+
+  /** Reinitialise. */
   public void ReInit(java.io.Reader dstream, int startline,
   int startcolumn, int buffersize)
   {
@@ -281,81 +296,96 @@
     bufpos = -1;
   }
 
+  /** Reinitialise. */
   public void ReInit(java.io.Reader dstream, int startline,
                      int startcolumn)
   {
      ReInit(dstream, startline, startcolumn, 4096);
   }
 
+  /** Reinitialise. */
   public void ReInit(java.io.Reader dstream)
   {
      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, 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)
   {
      this(dstream, startline, startcolumn, 4096);
   }
 
+  /** Constructor. */
   public SimpleCharStream(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException
   {
      this(dstream, encoding, 1, 1, 4096);
   }
 
+  /** Constructor. */
   public SimpleCharStream(java.io.InputStream dstream)
   {
      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, 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);
   }
+  /** 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)
   {
      ReInit(dstream, startline, startcolumn, 4096);
   }
+  /** Get token literal value. */
   public String GetImage()
   {
      if (bufpos >= tokenBegin)
@@ -365,6 +395,7 @@
                               new String(buffer, 0, bufpos + 1);
   }
 
+  /** Get the suffix. */
   public char[] GetSuffix(int len)
   {
      char[] ret = new char[len];
@@ -381,6 +412,7 @@
      return ret;
   }
 
+  /** Reset buffer when finished. */
   public void Done()
   {
      buffer = null;
@@ -416,7 +448,7 @@
         bufcolumn[j] = newCol + columnDiff;
         columnDiff = nextColDiff;
         i++;
-     } 
+     }
 
      if (i < len)
      {
@@ -437,3 +469,4 @@
   }
 
 }
+/* JavaCC - OriginalChecksum=7393ed4ac2709e2de22d164f9db78b65 (do not edit this line) */

Modified: lucene/java/branches/flex_1458/src/demo/org/apache/lucene/demo/html/Token.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/demo/org/apache/lucene/demo/html/Token.java?rev=827772&r1=827771&r2=827772&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/demo/org/apache/lucene/demo/html/Token.java (original)
+++ lucene/java/branches/flex_1458/src/demo/org/apache/lucene/demo/html/Token.java Tue Oct 20 19:58:18 2009
@@ -1,4 +1,5 @@
-/* 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 */
 package org.apache.lucene.demo.html;
 
 /**
@@ -14,12 +15,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.
@@ -51,6 +54,40 @@
   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()
@@ -63,19 +100,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();
+       default : return new Token(ofKind, image);
      }
   }
 
+  public static Token newToken(int ofKind)
+  {
+     return newToken(ofKind, null);
+  }
+
 }
+/* JavaCC - OriginalChecksum=7bf8bdbb1c45bccd8162cdd48316d5e0 (do not edit this line) */

Modified: lucene/java/branches/flex_1458/src/demo/org/apache/lucene/demo/html/TokenMgrError.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/demo/org/apache/lucene/demo/html/TokenMgrError.java?rev=827772&r1=827771&r2=827772&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/demo/org/apache/lucene/demo/html/TokenMgrError.java (original)
+++ lucene/java/branches/flex_1458/src/demo/org/apache/lucene/demo/html/TokenMgrError.java Tue Oct 20 19:58:18 2009
@@ -1,19 +1,23 @@
-/* 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.lucene.demo.html;
 
+/** Token Manager Error. */
+@SuppressWarnings("serial")
 public class TokenMgrError extends Error
 {
+
    /*
     * Ordinals for various reasons why an Error of this type can be thrown.
     */
 
    /**
-    * Lexical error occured.
+    * Lexical error occurred.
     */
    static final int LEXICAL_ERROR = 0;
 
    /**
-    * An attempt wass made to create a second instance of a static token manager.
+    * An attempt was made to create a second instance of a static token manager.
     */
    static final int STATIC_LEXER_ERROR = 1;
 
@@ -34,7 +38,7 @@
    int errorCode;
 
    /**
-    * Replaces unprintable characters by their espaced (or unicode escaped)
+    * Replaces unprintable characters by their escaped (or unicode escaped)
     * equivalents in the given string
     */
    protected static final String addEscapes(String str) {
@@ -85,12 +89,12 @@
    /**
     * 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
+    * 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.
     */
@@ -105,7 +109,7 @@
    /**
     * 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 : 
+    * of end-users concern, so you can return something like :
     *
     *     "Internal Error : Please file a bug report .... "
     *
@@ -119,15 +123,19 @@
     * 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=5ffb7e46d5ae93d8d59e6f4ae7eb36d1 (do not edit this line) */

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/Analyzer.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/Analyzer.java?rev=827772&r1=827771&r2=827772&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/Analyzer.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/Analyzer.java Tue Oct 20 19:58:18 2009
@@ -19,6 +19,7 @@
 
 import java.io.Reader;
 import java.io.IOException;
+import java.io.Closeable;
 import java.lang.reflect.Method;
 
 import org.apache.lucene.util.CloseableThreadLocal;
@@ -33,7 +34,7 @@
  *  characters from the Reader into raw Tokens.  One or more TokenFilters may
  *  then be applied to the output of the Tokenizer.
  */
-public abstract class Analyzer {
+public abstract class Analyzer implements Closeable {
   /** Creates a TokenStream which tokenizes all the text in the provided
    * Reader.  Must be able to handle null field name for
    * backward compatibility.
@@ -51,7 +52,7 @@
     return tokenStream(fieldName, reader);
   }
 
-  private CloseableThreadLocal tokenStreams = new CloseableThreadLocal();
+  private CloseableThreadLocal<Object> tokenStreams = new CloseableThreadLocal<Object>();
 
   /** Used by Analyzers that implement reusableTokenStream
    *  to retrieve previously saved TokenStreams for re-use

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/BaseCharFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/BaseCharFilter.java?rev=827772&r1=827771&r2=827772&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/BaseCharFilter.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/BaseCharFilter.java Tue Oct 20 19:58:18 2009
@@ -33,8 +33,7 @@
  */
 public abstract class BaseCharFilter extends CharFilter {
 
-  //private List<OffCorrectMap> pcmList;
-  private List pcmList;
+  private List<OffCorrectMap> pcmList;
   
   public BaseCharFilter(CharStream in) {
     super(in);
@@ -64,7 +63,7 @@
 
   protected void addOffCorrectMap(int off, int cumulativeDiff) {
     if (pcmList == null) {
-      pcmList = new ArrayList();
+      pcmList = new ArrayList<OffCorrectMap>();
     }
     pcmList.add(new OffCorrectMap(off, cumulativeDiff));
   }

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/CachingTokenFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/CachingTokenFilter.java?rev=827772&r1=827771&r2=827772&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/CachingTokenFilter.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/CachingTokenFilter.java Tue Oct 20 19:58:18 2009
@@ -34,8 +34,8 @@
  * stream to the first Token. 
  */
 public final class CachingTokenFilter extends TokenFilter {
-  private List cache = null;
-  private Iterator iterator = null; 
+  private List<AttributeSource.State> cache = null;
+  private Iterator<AttributeSource.State> iterator = null; 
   private AttributeSource.State finalState;
   
   public CachingTokenFilter(TokenStream input) {
@@ -45,7 +45,7 @@
   public final boolean incrementToken() throws IOException {
     if (cache == null) {
       // fill cache lazily
-      cache = new LinkedList();
+      cache = new LinkedList<AttributeSource.State>();
       fillCache();
       iterator = cache.iterator();
     }
@@ -55,7 +55,7 @@
       return false;
     }
     // Since the TokenFilter can be reset, the tokens need to be preserved as immutable.
-    restoreState((AttributeSource.State) iterator.next());
+    restoreState(iterator.next());
     return true;
   }
   

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/CharArraySet.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/CharArraySet.java?rev=827772&r1=827771&r2=827772&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/CharArraySet.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/CharArraySet.java Tue Oct 20 19:58:18 2009
@@ -31,9 +31,18 @@
  * etc.  It is designed to be quick to test if a char[]
  * is in the set without the necessity of converting it
  * to a String first.
+ * <P>
+ * <em>Please note:</em> This class implements {@link Set} but
+ * does not behave like it should in all cases. The generic type is
+ * {@code Set<Object>}, because you can add any object to it,
+ * that has a string representation. The add methods will use
+ * {@link Object#toString} and store the result using a {@code char[]}
+ * buffer. The same behaviour have the {@code contains()} methods.
+ * The {@link #iterator()} returns an {@code Iterator<String>}.
+ * For type safety also {@link #stringIterator()} is provided.
  */
 
-public class CharArraySet extends AbstractSet {
+public class CharArraySet extends AbstractSet<Object> {
   private final static int INIT_SIZE = 8;
   private char[][] entries;
   private int count;
@@ -49,11 +58,12 @@
     entries = new char[size][];
   }
 
- /** Create set from a Collection of char[] or String */
-  public CharArraySet(Collection c, boolean ignoreCase) {
+  /** Create set from a Collection of char[] or String */
+  public CharArraySet(Collection<? extends Object> c, boolean ignoreCase) {
     this(c.size(), ignoreCase);
     addAll(c);
   }
+  
   /** Create set from entries */
   private CharArraySet(char[][] entries, boolean ignoreCase, int count){
     this.entries = entries;
@@ -223,7 +233,7 @@
 
   public boolean contains(Object o) {
     if (o instanceof char[]) {
-      char[] text = (char[])o;
+      final char[] text = (char[])o;
       return contains(text, 0, text.length);
     } 
     return contains(o.toString());
@@ -258,7 +268,7 @@
 
   /** The Iterator<String> for this set.  Strings are constructed on the fly, so
    * use <code>nextCharArray</code> for more efficient access. */
-  public class CharArraySetIterator implements Iterator {
+  public class CharArraySetIterator implements Iterator<String> {
     int pos=-1;
     char[] next;
     CharArraySetIterator() {
@@ -284,7 +294,7 @@
 
     /** Returns the next String, as a Set<String> would...
      * use nextCharArray() for better efficiency. */
-    public Object next() {
+    public String next() {
       return new String(nextCharArray());
     }
 
@@ -293,10 +303,16 @@
     }
   }
 
-
-  public Iterator iterator() {
+  /** returns an iterator of new allocated Strings */
+  public Iterator<String> stringIterator() {
     return new CharArraySetIterator();
   }
+
+  /** returns an iterator of new allocated Strings, this method violates the Set interface */
+  @SuppressWarnings("unchecked")
+  public Iterator<Object> iterator() {
+    return (Iterator) stringIterator();
+  }
   
   /**
    * Efficient unmodifiable {@link CharArraySet}. This implementation does not
@@ -316,7 +332,7 @@
       throw new UnsupportedOperationException();
     }
     
-    public boolean addAll(Collection coll) {
+    public boolean addAll(Collection<? extends Object> coll) {
       throw new UnsupportedOperationException();
     }
     

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/MappingCharFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/MappingCharFilter.java?rev=827772&r1=827771&r2=827772&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/MappingCharFilter.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/MappingCharFilter.java Tue Oct 20 19:58:18 2009
@@ -30,8 +30,7 @@
 public class MappingCharFilter extends BaseCharFilter {
 
   private final NormalizeCharMap normMap;
-  //private LinkedList<Character> buffer;
-  private LinkedList buffer;
+  private LinkedList<Character> buffer;
   private String replacement;
   private int charPointer;
   private int nextCharCounter;
@@ -57,7 +56,7 @@
       int firstChar = nextChar();
       if (firstChar == -1) return -1;
       NormalizeCharMap nm = normMap.submap != null ?
-        (NormalizeCharMap)normMap.submap.get(CharacterCache.valueOf((char) firstChar)) : null;
+        normMap.submap.get(Character.valueOf((char) firstChar)) : null;
       if (nm == null) return firstChar;
       NormalizeCharMap result = match(nm);
       if (result == null) return firstChar;
@@ -78,7 +77,7 @@
   private int nextChar() throws IOException {
     nextCharCounter++;
     if (buffer != null && !buffer.isEmpty()) {
-      return ((Character)buffer.removeFirst()).charValue();
+      return buffer.removeFirst().charValue();
     }
     return input.read();
   }
@@ -86,15 +85,15 @@
   private void pushChar(int c) {
     nextCharCounter--;
     if(buffer == null)
-      buffer = new LinkedList();
-    buffer.addFirst(new Character((char) c));
+      buffer = new LinkedList<Character>();
+    buffer.addFirst(Character.valueOf((char) c));
   }
 
   private void pushLastChar(int c) {
     if (buffer == null) {
-      buffer = new LinkedList();
+      buffer = new LinkedList<Character>();
     }
-    buffer.addLast(new Character((char) c));
+    buffer.addLast(Character.valueOf((char) c));
   }
 
   private NormalizeCharMap match(NormalizeCharMap map) throws IOException {
@@ -102,7 +101,7 @@
     if (map.submap != null) {
       int chr = nextChar();
       if (chr != -1) {
-        NormalizeCharMap subMap = (NormalizeCharMap) map.submap.get(CharacterCache.valueOf((char) chr));
+        NormalizeCharMap subMap = map.submap.get(Character.valueOf((char) chr));
         if (subMap != null) {
           result = match(subMap);
         }

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/NormalizeCharMap.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/NormalizeCharMap.java?rev=827772&r1=827771&r2=827772&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/NormalizeCharMap.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/NormalizeCharMap.java Tue Oct 20 19:58:18 2009
@@ -45,10 +45,10 @@
       if (currMap.submap == null) {
         currMap.submap = new HashMap<Character, NormalizeCharMap>(1);
       }
-      NormalizeCharMap map = currMap.submap.get(CharacterCache.valueOf(c));
+      NormalizeCharMap map = currMap.submap.get(Character.valueOf(c));
       if (map == null) {
         map = new NormalizeCharMap();
-        currMap.submap.put(new Character(c), map);
+        currMap.submap.put(Character.valueOf(c), map);
       }
       currMap = map;
     }

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/PerFieldAnalyzerWrapper.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/PerFieldAnalyzerWrapper.java?rev=827772&r1=827771&r2=827772&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/PerFieldAnalyzerWrapper.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/PerFieldAnalyzerWrapper.java Tue Oct 20 19:58:18 2009
@@ -44,7 +44,7 @@
  */
 public class PerFieldAnalyzerWrapper extends Analyzer {
   private Analyzer defaultAnalyzer;
-  private Map analyzerMap = new HashMap();
+  private Map<String,Analyzer> analyzerMap = new HashMap<String,Analyzer>();
 
 
   /**
@@ -67,7 +67,7 @@
    * used for those fields 
    */
   public PerFieldAnalyzerWrapper(Analyzer defaultAnalyzer, 
-      Map /*<String, Analyzer>*/ fieldAnalyzers) {
+      Map<String,Analyzer> fieldAnalyzers) {
     this.defaultAnalyzer = defaultAnalyzer;
     if (fieldAnalyzers != null) {
       analyzerMap.putAll(fieldAnalyzers);
@@ -87,7 +87,7 @@
   }
 
   public TokenStream tokenStream(String fieldName, Reader reader) {
-    Analyzer analyzer = (Analyzer) analyzerMap.get(fieldName);
+    Analyzer analyzer = analyzerMap.get(fieldName);
     if (analyzer == null) {
       analyzer = defaultAnalyzer;
     }
@@ -102,7 +102,7 @@
       // tokenStream but not reusableTokenStream
       return tokenStream(fieldName, reader);
     }
-    Analyzer analyzer = (Analyzer) analyzerMap.get(fieldName);
+    Analyzer analyzer = analyzerMap.get(fieldName);
     if (analyzer == null)
       analyzer = defaultAnalyzer;
 
@@ -111,7 +111,7 @@
   
   /** Return the positionIncrementGap from the analyzer assigned to fieldName */
   public int getPositionIncrementGap(String fieldName) {
-    Analyzer analyzer = (Analyzer) analyzerMap.get(fieldName);
+    Analyzer analyzer = analyzerMap.get(fieldName);
     if (analyzer == null)
       analyzer = defaultAnalyzer;
     return analyzer.getPositionIncrementGap(fieldName);

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/TeeSinkTokenFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/TeeSinkTokenFilter.java?rev=827772&r1=827771&r2=827772&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/TeeSinkTokenFilter.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/TeeSinkTokenFilter.java Tue Oct 20 19:58:18 2009
@@ -73,7 +73,7 @@
  * <p>Note, the EntityDetect and URLDetect TokenStreams are for the example and do not currently exist in Lucene.
  */
 public final class TeeSinkTokenFilter extends TokenFilter {
-  private final List sinks = new LinkedList();
+  private final List<WeakReference<SinkTokenStream>> sinks = new LinkedList<WeakReference<SinkTokenStream>>();
   
   /**
    * Instantiates a new TeeSinkTokenFilter.
@@ -96,7 +96,7 @@
    */
   public SinkTokenStream newSinkTokenStream(SinkFilter filter) {
     SinkTokenStream sink = new SinkTokenStream(this.cloneAttributes(), filter);
-    this.sinks.add(new WeakReference(sink));
+    this.sinks.add(new WeakReference<SinkTokenStream>(sink));
     return sink;
   }
   
@@ -111,10 +111,10 @@
       throw new IllegalArgumentException("The supplied sink is not compatible to this tee");
     }
     // add eventually missing attribute impls to the existing sink
-    for (Iterator it = this.cloneAttributes().getAttributeImplsIterator(); it.hasNext(); ) {
-      sink.addAttributeImpl((AttributeImpl) it.next());
+    for (Iterator<AttributeImpl> it = this.cloneAttributes().getAttributeImplsIterator(); it.hasNext(); ) {
+      sink.addAttributeImpl(it.next());
     }
-    this.sinks.add(new WeakReference(sink));
+    this.sinks.add(new WeakReference<SinkTokenStream>(sink));
   }
   
   /**
@@ -131,8 +131,8 @@
     if (input.incrementToken()) {
       // capture state lazily - maybe no SinkFilter accepts this state
       AttributeSource.State state = null;
-      for (Iterator it = sinks.iterator(); it.hasNext(); ) {
-        final SinkTokenStream sink = (SinkTokenStream) ((WeakReference) it.next()).get();
+      for (WeakReference<SinkTokenStream> ref : sinks) {
+        final SinkTokenStream sink = ref.get();
         if (sink != null) {
           if (sink.accept(this)) {
             if (state == null) {
@@ -151,8 +151,8 @@
   public final void end() throws IOException {
     super.end();
     AttributeSource.State finalState = captureState();
-    for (Iterator it = sinks.iterator(); it.hasNext(); ) {
-      final SinkTokenStream sink = (SinkTokenStream) ((WeakReference) it.next()).get();
+    for (WeakReference<SinkTokenStream> ref : sinks) {
+      final SinkTokenStream sink = ref.get();
       if (sink != null) {
         sink.setFinalState(finalState);
       }
@@ -179,9 +179,9 @@
   }
   
   public static final class SinkTokenStream extends TokenStream {
-    private final List cachedStates = new LinkedList();
+    private final List<AttributeSource.State> cachedStates = new LinkedList<AttributeSource.State>();
     private AttributeSource.State finalState;
-    private Iterator it = null;
+    private Iterator<AttributeSource.State> it = null;
     private SinkFilter filter;
     
     private SinkTokenStream(AttributeSource source, SinkFilter filter) {
@@ -214,7 +214,7 @@
         return false;
       }
       
-      AttributeSource.State state = (State) it.next();
+      AttributeSource.State state = it.next();
       restoreState(state);
       return true;
     }

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/Token.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/Token.java?rev=827772&r1=827771&r2=827772&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/Token.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/Token.java Tue Oct 20 19:58:18 2009
@@ -58,18 +58,6 @@
   to easily switch from the old to the new TokenStream API.
   
   <br><br>
-
-  <p><b>NOTE:</b> As of 2.3, Token stores the term text
-  internally as a malleable char[] termBuffer instead of
-  String termText.  The indexing code and core tokenizers
-  have been changed to re-use a single Token instance, changing
-  its buffer and other fields in-place as the Token is
-  processed.  This provides substantially better indexing
-  performance as it saves the GC cost of new'ing a Token and
-  String for every term.  The APIs that accept String
-  termText are still available but a warning about the
-  associated performance cost has been added (below).  The
-  {@link #termText()} method has been deprecated.</p>
   
   <p>Tokenizers and filters should try to re-use a Token
   instance when possible for best performance, by
@@ -135,61 +123,13 @@
 
   private static int MIN_BUFFER_SIZE = 10;
 
-  /** @deprecated We will remove this when we remove the
-   * deprecated APIs */
-  private String termText;
-
-  /**
-   * Characters for the term text.
-   * @deprecated This will be made private. Instead, use:
-   * {@link #termBuffer()}, 
-   * {@link #setTermBuffer(char[], int, int)},
-   * {@link #setTermBuffer(String)}, or
-   * {@link #setTermBuffer(String, int, int)}
-   */
-  char[] termBuffer;
-
-  /**
-   * Length of term text in the buffer.
-   * @deprecated This will be made private. Instead, use:
-   * {@link #termLength()}, or @{link setTermLength(int)}.
-   */
-  int termLength;
-
-  /**
-   * Start in source text.
-   * @deprecated This will be made private. Instead, use:
-   * {@link #startOffset()}, or @{link setStartOffset(int)}.
-   */
-  int startOffset;
-
-  /**
-   * End in source text.
-   * @deprecated This will be made private. Instead, use:
-   * {@link #endOffset()}, or @{link setEndOffset(int)}.
-   */
-  int endOffset;
-
-  /**
-   * The lexical type of the token.
-   * @deprecated This will be made private. Instead, use:
-   * {@link #type()}, or @{link setType(String)}.
-   */
-  String type = DEFAULT_TYPE;
-
+  private char[] termBuffer;
+  private int termLength;
+  private int startOffset,endOffset;
+  private String type = DEFAULT_TYPE;
   private int flags;
-  
-  /**
-   * @deprecated This will be made private. Instead, use:
-   * {@link #getPayload()}, or @{link setPayload(Payload)}.
-   */
-  Payload payload;
-  
-  /**
-   * @deprecated This will be made private. Instead, use:
-   * {@link #getPositionIncrement()}, or @{link setPositionIncrement(String)}.
-   */
-  int positionIncrement = 1;
+  private Payload payload;
+  private int positionIncrement = 1;
 
   /** Constructs a Token will null text. */
   public Token() {
@@ -236,10 +176,9 @@
    *  @param text term text
    *  @param start start offset
    *  @param end end offset
-   *  @deprecated Use {@link #Token(char[], int, int, int, int)} instead.
    */
   public Token(String text, int start, int end) {
-    termText = text;
+    setTermBuffer(text);
     startOffset = start;
     endOffset = end;
   }
@@ -252,10 +191,9 @@
    *  @param start start offset
    *  @param end end offset
    *  @param typ token type
-   *  @deprecated Use {@link #Token(char[], int, int, int, int)} and {@link #setType(String)} instead.
    */
   public Token(String text, int start, int end, String typ) {
-    termText = text;
+    setTermBuffer(text);
     startOffset = start;
     endOffset = end;
     type = typ;
@@ -270,10 +208,9 @@
    * @param start
    * @param end
    * @param flags token type bits
-   * @deprecated Use {@link #Token(char[], int, int, int, int)} and {@link #setFlags(int)} instead.
    */
   public Token(String text, int start, int end, int flags) {
-    termText = text;
+    setTermBuffer(text);
     startOffset = start;
     endOffset = end;
     this.flags = flags;
@@ -335,32 +272,6 @@
     return positionIncrement;
   }
 
-  /** Sets the Token's term text.  <b>NOTE:</b> for better
-   *  indexing speed you should instead use the char[]
-   *  termBuffer methods to set the term text.
-   *  @deprecated use {@link #setTermBuffer(char[], int, int)} or
-   *                  {@link #setTermBuffer(String)} or
-   *                  {@link #setTermBuffer(String, int, int)}.
-   */
-  public void setTermText(String text) {
-    termText = text;
-    termBuffer = null;
-  }
-
-  /** Returns the Token's term text.
-   * 
-   * @deprecated This method now has a performance penalty
-   * because the text is stored internally in a char[].  If
-   * possible, use {@link #termBuffer()} and {@link
-   * #termLength()} directly instead.  If you really need a
-   * String, use {@link #term()}</b>
-   */
-  public final String termText() {
-    if (termText == null && termBuffer != null)
-      termText = new String(termBuffer, 0, termLength);
-    return termText;
-  }
-
   /** Returns the Token's term text.
    * 
    * This method has a performance penalty
@@ -371,8 +282,6 @@
    * a convenience call to <b>new String(token.termBuffer(), 0, token.termLength())</b>
    */
   public final String term() {
-    if (termText != null)
-      return termText;
     initTermBuffer();
     return new String(termBuffer, 0, termLength);
   }
@@ -384,7 +293,6 @@
    *  @param length the number of characters to copy
    */
   public final void setTermBuffer(char[] buffer, int offset, int length) {
-    termText = null;
     growTermBuffer(length);
     System.arraycopy(buffer, offset, termBuffer, 0, length);
     termLength = length;
@@ -394,7 +302,6 @@
    *  @param buffer the buffer to copy
    */
   public final void setTermBuffer(String buffer) {
-    termText = null;
     final int length = buffer.length();
     growTermBuffer(length);
     buffer.getChars(0, length, termBuffer, 0);
@@ -410,7 +317,6 @@
   public final void setTermBuffer(String buffer, int offset, int length) {
     assert offset <= buffer.length();
     assert offset + length <= buffer.length();
-    termText = null;
     growTermBuffer(length);
     buffer.getChars(offset, offset + length, termBuffer, 0);
     termLength = length;
@@ -441,17 +347,7 @@
   public char[] resizeTermBuffer(int newSize) {
     if (termBuffer == null) {
       // The buffer is always at least MIN_BUFFER_SIZE
-      newSize = newSize < MIN_BUFFER_SIZE ? MIN_BUFFER_SIZE : newSize;
-      //Preserve termText 
-      if (termText != null) {
-        final int ttLen = termText.length();
-        newSize = newSize < ttLen ? ttLen : newSize;
-        termBuffer = new char[ArrayUtil.getNextSize(newSize)];
-        termText.getChars(0, termText.length(), termBuffer, 0);
-        termText = null;
-      } else { // no term Text, the first allocation
-        termBuffer = new char[ArrayUtil.getNextSize(newSize)];
-      }    
+      termBuffer = new char[ArrayUtil.getNextSize(newSize < MIN_BUFFER_SIZE ? MIN_BUFFER_SIZE : newSize)]; 
     } else {
       if(termBuffer.length < newSize){
         // Not big enough; create a new array with slight
@@ -481,25 +377,10 @@
     } 
   }
   
-
-  // TODO: once we remove the deprecated termText() method
-  // and switch entirely to char[] termBuffer we don't need
-  // to use this method anymore, only for late init of the buffer
   private void initTermBuffer() {
     if (termBuffer == null) {
-      if (termText == null) {
-        termBuffer = new char[ArrayUtil.getNextSize(MIN_BUFFER_SIZE)];
-        termLength = 0;
-      } else {
-        int length = termText.length();
-        if (length < MIN_BUFFER_SIZE) length = MIN_BUFFER_SIZE;
-        termBuffer = new char[ArrayUtil.getNextSize(length)];
-        termLength = termText.length();
-        termText.getChars(0, termText.length(), termBuffer, 0);
-        termText = null;
-      }
-    } else {
-      termText = null;
+      termBuffer = new char[ArrayUtil.getNextSize(MIN_BUFFER_SIZE)];
+      termLength = 0;
     }
   }
 
@@ -528,7 +409,7 @@
     corresponding to this token in the source text.
 
     Note that the difference between endOffset() and startOffset() may not be
-    equal to termText.length(), as the term text may have been altered by a
+    equal to {@link #termLength}, as the term text may have been altered by a
     stemmer or some other filter. */
   public final int startOffset() {
     return startOffset;
@@ -630,7 +511,6 @@
     payload = null;
     // Leave termBuffer to allow re-use
     termLength = 0;
-    termText = null;
     positionIncrement = 1;
     flags = 0;
     startOffset = endOffset = 0;

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/TokenStream.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/TokenStream.java?rev=827772&r1=827771&r2=827772&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/TokenStream.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/analysis/TokenStream.java Tue Oct 20 19:58:18 2009
@@ -18,6 +18,7 @@
  */
 
 import java.io.IOException;
+import java.io.Closeable;
 
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
@@ -76,7 +77,7 @@
  * {@link AttributeSource#captureState} and {@link AttributeSource#restoreState}
  * can be used.
  */
-public abstract class TokenStream extends AttributeSource {
+public abstract class TokenStream extends AttributeSource implements Closeable {
 
   /**
    * A TokenStream using the default attribute factory.

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/document/MapFieldSelector.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/document/MapFieldSelector.java?rev=827772&r1=827771&r2=827772&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/document/MapFieldSelector.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/document/MapFieldSelector.java Tue Oct 20 19:58:18 2009
@@ -17,6 +17,7 @@
  * limitations under the License.
  */
 
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -27,39 +28,39 @@
  */
 public class MapFieldSelector implements FieldSelector {
     
-    Map fieldSelections;
+    Map<String,FieldSelectorResult> fieldSelections;
     
     /** Create a a MapFieldSelector
      * @param fieldSelections maps from field names (String) to {@link FieldSelectorResult}s
      */
-    public MapFieldSelector(Map fieldSelections) {
+    public MapFieldSelector(Map<String,FieldSelectorResult> fieldSelections) {
         this.fieldSelections = fieldSelections;
     }
     
     /** Create a a MapFieldSelector
      * @param fields fields to LOAD.  List of Strings.  All other fields are NO_LOAD.
      */
-    public MapFieldSelector(List fields) {
-        fieldSelections = new HashMap(fields.size()*5/3);
-        for (int i=0; i<fields.size(); i++)
-            fieldSelections.put(fields.get(i), FieldSelectorResult.LOAD);
+    public MapFieldSelector(List<String> fields) {
+        fieldSelections = new HashMap<String,FieldSelectorResult>(fields.size()*5/3);
+        for (final String field : fields)
+            fieldSelections.put(field, FieldSelectorResult.LOAD);
     }
     
     /** Create a a MapFieldSelector
      * @param fields fields to LOAD.  All other fields are NO_LOAD.
      */
-    public MapFieldSelector(String[] fields) {
-        fieldSelections = new HashMap(fields.length*5/3);
-        for (int i=0; i<fields.length; i++)
-            fieldSelections.put(fields[i], FieldSelectorResult.LOAD);
+    public MapFieldSelector(String... fields) {
+      this(Arrays.asList(fields));
     }
+
+
     
     /** Load field according to its associated value in fieldSelections
      * @param field a field name
      * @return the fieldSelections value that field maps to or NO_LOAD if none.
      */
     public FieldSelectorResult accept(String field) {
-        FieldSelectorResult selection = (FieldSelectorResult) fieldSelections.get(field);
+        FieldSelectorResult selection = fieldSelections.get(field);
         return selection!=null ? selection : FieldSelectorResult.NO_LOAD;
     }
     

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/document/SetBasedFieldSelector.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/document/SetBasedFieldSelector.java?rev=827772&r1=827771&r2=827772&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/document/SetBasedFieldSelector.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/document/SetBasedFieldSelector.java Tue Oct 20 19:58:18 2009
@@ -23,18 +23,16 @@
  **/
 public class SetBasedFieldSelector implements FieldSelector {
   
-  private Set fieldsToLoad;
-  private Set lazyFieldsToLoad;
+  private Set<String> fieldsToLoad;
+  private Set<String> lazyFieldsToLoad;
   
-  
-
   /**
    * Pass in the Set of {@link Field} names to load and the Set of {@link Field} names to load lazily.  If both are null, the
    * Document will not have any {@link Field} on it.  
    * @param fieldsToLoad A Set of {@link String} field names to load.  May be empty, but not null
    * @param lazyFieldsToLoad A Set of {@link String} field names to load lazily.  May be empty, but not null  
    */
-  public SetBasedFieldSelector(Set fieldsToLoad, Set lazyFieldsToLoad) {
+  public SetBasedFieldSelector(Set<String> fieldsToLoad, Set<String> lazyFieldsToLoad) {
     this.fieldsToLoad = fieldsToLoad;
     this.lazyFieldsToLoad = lazyFieldsToLoad;
   }

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/CheckIndex.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/CheckIndex.java?rev=827772&r1=827771&r2=827772&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/CheckIndex.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/CheckIndex.java Tue Oct 20 19:58:18 2009
@@ -30,7 +30,7 @@
 import java.io.IOException;
 import java.io.File;
 import java.util.Collection;
-import java.util.Iterator;
+
 import java.util.List;
 import java.util.ArrayList;
 import java.util.Map;
@@ -115,7 +115,7 @@
     public boolean partial;
 
     /** Holds the userData of the last commit in the index */
-    public Map userData;
+    public Map<String, String> userData;
 
     /** Holds the status of each segment in the index.
      *  See {@link #segmentInfos}.
@@ -174,10 +174,10 @@
        *  @see AbstractField#setOmitTermFreqAndPositions */
       public boolean hasProx;
 
-      /** Map<String, String> that includes certain
+      /** Map that includes certain
        *  debugging details that IndexWriter records into
        *  each segment it creates */
-      public Map diagnostics;
+      public Map<String,String> diagnostics;
 
       /** Status for testing of field norms (null if field norms could not be tested). */
       public FieldNormStatus fieldNormStatus;
@@ -281,7 +281,7 @@
     return checkIndex(null);
   }
 
-  protected Status checkIndex(List onlySegments) throws IOException {
+  protected Status checkIndex(List<String> onlySegments) throws IOException {
     return checkIndex(onlySegments, Codecs.getDefault());
   }
   
@@ -297,7 +297,7 @@
    *  <p><b>WARNING</b>: make sure
    *  you only call this when the index is not opened by any
    *  writer. */
-  protected Status checkIndex(List onlySegments, Codecs codecs) throws IOException {
+  protected Status checkIndex(List<String> onlySegments, Codecs codecs) throws IOException {
     NumberFormat nf = NumberFormat.getInstance();
     SegmentInfos sis = new SegmentInfos();
     Status result = new Status();
@@ -387,10 +387,9 @@
       result.partial = true;
       if (infoStream != null)
         infoStream.print("\nChecking only these segments:");
-      Iterator it = onlySegments.iterator();
-      while (it.hasNext()) {
+      for (String s : onlySegments) {
         if (infoStream != null)
-          infoStream.print(" " + it.next());
+          infoStream.print(" " + s);
       }
       result.segmentsChecked.addAll(onlySegments);
       msg(":");
@@ -429,7 +428,7 @@
         segInfoStat.numFiles = info.files().size();
         msg("    size (MB)=" + nf.format(info.sizeInBytes()/(1024.*1024.)));
         segInfoStat.sizeMB = info.sizeInBytes()/(1024.*1024.);
-        Map diagnostics = info.getDiagnostics();
+        Map<String,String> diagnostics = info.getDiagnostics();
         segInfoStat.diagnostics = diagnostics;
         if (diagnostics.size() > 0) {
           msg("    diagnostics = " + diagnostics);
@@ -487,7 +486,7 @@
         if (infoStream != null) {
           infoStream.print("    test: fields..............");
         }         
-        Collection fieldNames = reader.getFieldNames(IndexReader.FieldOption.ALL);
+        Collection<String> fieldNames = reader.getFieldNames(IndexReader.FieldOption.ALL);
         msg("OK [" + fieldNames.size() + " fields]");
         segInfoStat.numFields = fieldNames.size();
         
@@ -549,7 +548,7 @@
   /**
    * Test field norms.
    */
-  private Status.FieldNormStatus testFieldNorms(Collection fieldNames, SegmentReader reader) {
+  private Status.FieldNormStatus testFieldNorms(Collection<String> fieldNames, SegmentReader reader) {
     final Status.FieldNormStatus status = new Status.FieldNormStatus();
 
     try {
@@ -557,10 +556,8 @@
       if (infoStream != null) {
         infoStream.print("    test: field norms.........");
       }
-      Iterator it = fieldNames.iterator();
       final byte[] b = new byte[reader.maxDoc()];
-      while (it.hasNext()) {
-        final String fieldName = (String) it.next();
+      for (final String fieldName : fieldNames) {
         reader.norms(fieldName, b, 0);
         ++status.totFields;
       }
@@ -818,7 +815,7 @@
   public static void main(String[] args) throws IOException, InterruptedException {
 
     boolean doFix = false;
-    List onlySegments = new ArrayList();
+    List<String> onlySegments = new ArrayList<String>();
     String indexPath = null;
     int i = 0;
     while(i < args.length) {

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/CompoundFileReader.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/CompoundFileReader.java?rev=827772&r1=827771&r2=827772&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/CompoundFileReader.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/CompoundFileReader.java Tue Oct 20 19:58:18 2009
@@ -47,7 +47,7 @@
     private String fileName;
 
     private IndexInput stream;
-    private HashMap entries = new HashMap();
+    private HashMap<String,FileEntry> entries = new HashMap<String,FileEntry>();
 
 
   public CompoundFileReader(Directory dir, String name) throws IOException {

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/CompoundFileWriter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/CompoundFileWriter.java?rev=827772&r1=827771&r2=827772&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/CompoundFileWriter.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/CompoundFileWriter.java Tue Oct 20 19:58:18 2009
@@ -22,7 +22,7 @@
 import org.apache.lucene.store.IndexInput;
 import java.util.LinkedList;
 import java.util.HashSet;
-import java.util.Iterator;
+
 import java.io.IOException;
 
 
@@ -62,8 +62,8 @@
 
     private Directory directory;
     private String fileName;
-    private HashSet ids;
-    private LinkedList entries;
+    private HashSet<String> ids;
+    private LinkedList<FileEntry> entries;
     private boolean merged = false;
     private SegmentMerger.CheckAbort checkAbort;
 
@@ -83,8 +83,8 @@
         this.checkAbort = checkAbort;
         directory = dir;
         fileName = name;
-        ids = new HashSet();
-        entries = new LinkedList();
+        ids = new HashSet<String>();
+        entries = new LinkedList<FileEntry>();
     }
 
     /** Returns the directory of the compound file. */
@@ -152,10 +152,8 @@
             // Write the directory with all offsets at 0.
             // Remember the positions of directory entries so that we can
             // adjust the offsets later
-            Iterator it = entries.iterator();
             long totalSize = 0;
-            while(it.hasNext()) {
-                FileEntry fe = (FileEntry) it.next();
+            for (FileEntry fe : entries) {
                 fe.directoryOffset = os.getFilePointer();
                 os.writeLong(0);    // for now
                 os.writeString(fe.file);
@@ -174,17 +172,13 @@
             // Open the files and copy their data into the stream.
             // Remember the locations of each file's data section.
             byte buffer[] = new byte[16384];
-            it = entries.iterator();
-            while(it.hasNext()) {
-                FileEntry fe = (FileEntry) it.next();
+            for (FileEntry fe : entries) {
                 fe.dataOffset = os.getFilePointer();
                 copyFile(fe, os, buffer);
             }
 
             // Write the data offsets into the directory of the compound stream
-            it = entries.iterator();
-            while(it.hasNext()) {
-                FileEntry fe = (FileEntry) it.next();
+            for (FileEntry fe : entries) {
                 os.seek(fe.directoryOffset);
                 os.writeLong(fe.dataOffset);
             }

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/ConcurrentMergeScheduler.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/ConcurrentMergeScheduler.java?rev=827772&r1=827771&r2=827772&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/ConcurrentMergeScheduler.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/ConcurrentMergeScheduler.java Tue Oct 20 19:58:18 2009
@@ -36,7 +36,7 @@
 
   private int mergeThreadPriority = -1;
 
-  protected List mergeThreads = new ArrayList();
+  protected List<MergeThread> mergeThreads = new ArrayList<MergeThread>();
 
   // Max number of threads allowed to be merging at once
   private int maxThreadCount = 3;
@@ -363,7 +363,7 @@
       // Make sure all outstanding threads are done so we see
       // any exceptions they may produce:
       for(int i=0;i<count;i++)
-        ((ConcurrentMergeScheduler) allInstances.get(i)).sync();
+        allInstances.get(i).sync();
       boolean v = anyExceptions;
       anyExceptions = false;
       return v;
@@ -382,7 +382,7 @@
       final int size = allInstances.size();
       int upto = 0;
       for(int i=0;i<size;i++) {
-        final ConcurrentMergeScheduler other = (ConcurrentMergeScheduler) allInstances.get(i);
+        final ConcurrentMergeScheduler other = allInstances.get(i);
         if (!(other.closed && 0 == other.mergeThreadCount()))
           // Keep this one for now: it still has threads or
           // may spawn new threads
@@ -406,8 +406,8 @@
   }
 
   /** Used for testing */
-  private static List allInstances;
+  private static List<ConcurrentMergeScheduler> allInstances;
   public static void setTestMode() {
-    allInstances = new ArrayList();
+    allInstances = new ArrayList<ConcurrentMergeScheduler>();
   }
 }

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DirectoryReader.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DirectoryReader.java?rev=827772&r1=827771&r2=827772&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DirectoryReader.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DirectoryReader.java Tue Oct 20 19:58:18 2009
@@ -25,7 +25,6 @@
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -54,7 +53,7 @@
   IndexWriter writer;
 
   private IndexDeletionPolicy deletionPolicy;
-  private final HashSet synced = new HashSet();
+  private final HashSet<String> synced = new HashSet<String>();
   private Lock writeLock;
   private SegmentInfos segmentInfos;
   private boolean stale;
@@ -65,7 +64,7 @@
 
   private SegmentReader[] subReaders;
   private int[] starts;                           // 1st docno for each segment
-  private Map normsCache = new HashMap();
+  private Map<String,byte[]> normsCache = new HashMap<String,byte[]>();
   private int maxDoc = 0;
   private int numDocs = -1;
   private boolean hasDeletions = false;
@@ -213,7 +212,7 @@
 
   /** This constructor is only used for {@link #reopen()} */
   DirectoryReader(Directory directory, SegmentInfos infos, SegmentReader[] oldReaders, int[] oldStarts,
-                  Map oldNormsCache, boolean readOnly, boolean doClone, int termInfosIndexDivisor, Codecs codecs) throws IOException {
+                  Map<String,byte[]> oldNormsCache, boolean readOnly, boolean doClone, int termInfosIndexDivisor, Codecs codecs) throws IOException {
     this.directory = directory;
     this.readOnly = readOnly;
     this.segmentInfos = infos;
@@ -232,7 +231,7 @@
 
     // we put the old SegmentReaders in a map, that allows us
     // to lookup a reader using its segment name
-    Map segmentReaders = new HashMap();
+    Map<String,Integer> segmentReaders = new HashMap<String,Integer>();
 
     if (oldReaders != null) {
       // create a Map SegmentName->SegmentReader
@@ -309,10 +308,8 @@
     
     // try to copy unchanged norms from the old normsCache to the new one
     if (oldNormsCache != null) {
-      Iterator it = oldNormsCache.entrySet().iterator();
-      while (it.hasNext()) {
-        Map.Entry entry = (Map.Entry) it.next();
-        String field = (String) entry.getKey();
+      for (Map.Entry<String,byte[]> entry: oldNormsCache.entrySet()) {
+        String field = entry.getKey();
         if (!hasNorms(field)) {
           continue;
         }
@@ -797,7 +794,7 @@
    *
    * @throws IOException if there is a low-level IO error
    */
-  protected void doCommit(Map commitUserData) throws IOException {
+  protected void doCommit(Map<String,String> commitUserData) throws IOException {
     if (hasChanges) {
       segmentInfos.setUserData(commitUserData);
       // Default deleter (for backwards compatibility) is
@@ -816,9 +813,8 @@
           subReaders[i].commit();
 
         // Sync all files we just wrote
-        Iterator it = segmentInfos.files(directory, false).iterator();
-        while (it.hasNext()) {
-          final String fileName = (String) it.next();
+        final Collection<String> files = segmentInfos.files(directory, false);
+        for (final String fileName : files) { 
           if (!synced.contains(fileName)) {
             assert directory.fileExists(fileName);
             directory.sync(fileName);
@@ -882,7 +878,7 @@
     }
   }
 
-  public Map getCommitUserData() {
+  public Map<String,String> getCommitUserData() {
     ensureOpen();
     return segmentInfos.getUserData();
   }
@@ -917,17 +913,16 @@
     if (ioe != null) throw ioe;
   }
 
-  public Collection getFieldNames (IndexReader.FieldOption fieldNames) {
+  public Collection<String> getFieldNames (IndexReader.FieldOption fieldNames) {
     ensureOpen();
     return getFieldNames(fieldNames, this.subReaders);
   }
   
-  static Collection getFieldNames (IndexReader.FieldOption fieldNames, IndexReader[] subReaders) {
+  static Collection<String> getFieldNames (IndexReader.FieldOption fieldNames, IndexReader[] subReaders) {
     // maintain a unique set of field names
-    Set fieldSet = new HashSet();
-    for (int i = 0; i < subReaders.length; i++) {
-      IndexReader reader = subReaders[i];
-      Collection names = reader.getFieldNames(fieldNames);
+    Set<String> fieldSet = new HashSet<String>();
+    for (IndexReader reader : subReaders) {
+      Collection<String> names = reader.getFieldNames(fieldNames);
       fieldSet.addAll(names);
     }
     return fieldSet;
@@ -959,15 +954,15 @@
   }
 
   /** @see org.apache.lucene.index.IndexReader#listCommits */
-  public static Collection listCommits(Directory dir) throws IOException {
+  public static Collection<IndexCommit> listCommits(Directory dir) throws IOException {
     return listCommits(dir, Codecs.getDefault());
   }
 
   /** @see org.apache.lucene.index.IndexReader#listCommits */
-  public static Collection listCommits(Directory dir, Codecs codecs) throws IOException {
+  public static Collection<IndexCommit> listCommits(Directory dir, Codecs codecs) throws IOException {
     final String[] files = dir.listAll();
 
-    Collection commits = new ArrayList();
+    Collection<IndexCommit> commits = new ArrayList<IndexCommit>();
 
     SegmentInfos latest = new SegmentInfos();
     latest.read(dir, codecs);
@@ -1009,12 +1004,12 @@
 
   private static final class ReaderCommit extends IndexCommit {
     private String segmentsFileName;
-    Collection files;
+    Collection<String> files;
     Directory dir;
     long generation;
     long version;
     final boolean isOptimized;
-    final Map userData;
+    final Map<String,String> userData;
 
     ReaderCommit(SegmentInfos infos, Directory dir) throws IOException {
       segmentsFileName = infos.getCurrentSegmentFileName();
@@ -1034,7 +1029,7 @@
       return segmentsFileName;
     }
 
-    public Collection getFileNames() {
+    public Collection<String> getFileNames() {
       return files;
     }
 
@@ -1054,7 +1049,7 @@
       return false;
     }
 
-    public Map getUserData() {
+    public Map<String,String> getUserData() {
       return userData;
     }
   }

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DocConsumer.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DocConsumer.java?rev=827772&r1=827771&r2=827772&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DocConsumer.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DocConsumer.java Tue Oct 20 19:58:18 2009
@@ -22,7 +22,7 @@
 
 abstract class DocConsumer {
   abstract DocConsumerPerThread addThread(DocumentsWriterThreadState perThread) throws IOException;
-  abstract void flush(final Collection threads, final SegmentWriteState state) throws IOException;
+  abstract void flush(final Collection<DocConsumerPerThread> threads, final SegmentWriteState state) throws IOException;
   abstract void closeDocStore(final SegmentWriteState state) throws IOException;
   abstract void abort();
   abstract boolean freeRAM();

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DocFieldConsumer.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DocFieldConsumer.java?rev=827772&r1=827771&r2=827772&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DocFieldConsumer.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DocFieldConsumer.java Tue Oct 20 19:58:18 2009
@@ -18,6 +18,7 @@
  */
 
 import java.io.IOException;
+import java.util.Collection;
 import java.util.Map;
 
 abstract class DocFieldConsumer {
@@ -26,7 +27,7 @@
 
   /** Called when DocumentsWriter decides to create a new
    *  segment */
-  abstract void flush(Map threadsAndFields, SegmentWriteState state) throws IOException;
+  abstract void flush(Map<DocFieldConsumerPerThread,Collection<DocFieldConsumerPerField>> threadsAndFields, SegmentWriteState state) throws IOException;
 
   /** Called when DocumentsWriter decides to close the doc
    *  stores */

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DocFieldConsumers.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DocFieldConsumers.java?rev=827772&r1=827771&r2=827772&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DocFieldConsumers.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/DocFieldConsumers.java Tue Oct 20 19:58:18 2009
@@ -44,7 +44,7 @@
     two.setFieldInfos(fieldInfos);
   }
 
-  public void flush(Map threadsAndFields, SegmentWriteState state) throws IOException {
+  public void flush(Map<DocFieldConsumerPerThread,Collection<DocFieldConsumerPerField>> threadsAndFields, SegmentWriteState state) throws IOException {
 
     Map oneThreadsAndFields = new HashMap();
     Map twoThreadsAndFields = new HashMap();



Mime
View raw message