mirror of https://github.com/apache/lucene.git
LUCENE-5372: Replace StringBuffer by StringBuilder, where possible
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1555645 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f8b91da0d4
commit
2e6b894036
|
@ -130,6 +130,11 @@ API Changes
|
|||
APIs more approachable to new users. (Shai Erera, Gilad Barkai, Rob
|
||||
Muir, Mike McCandless)
|
||||
|
||||
Optimizations
|
||||
|
||||
* LUCENE-5372: Replace StringBuffer by StringBuilder, where possible.
|
||||
(Joshua Hartman via Uwe Schindler, Dawid Weiss, Mike McCandless)
|
||||
|
||||
Changes in Runtime Behavior
|
||||
|
||||
* LUCENE-5362: IndexReader and SegmentCoreReaders now throw
|
||||
|
|
|
@ -131,7 +131,7 @@ public class PatternParser extends DefaultHandler {
|
|||
}
|
||||
}
|
||||
|
||||
protected String readToken(StringBuffer chars) {
|
||||
protected String readToken(StringBuilder chars) {
|
||||
String word;
|
||||
boolean space = false;
|
||||
int i;
|
||||
|
@ -344,7 +344,7 @@ public class PatternParser extends DefaultHandler {
|
|||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void characters(char ch[], int start, int length) {
|
||||
StringBuffer chars = new StringBuffer(length);
|
||||
StringBuilder chars = new StringBuilder(length);
|
||||
chars.append(ch, start, length);
|
||||
String word = readToken(chars);
|
||||
while (word != null) {
|
||||
|
|
|
@ -209,7 +209,7 @@ public class TestJapaneseIterationMarkCharFilter extends BaseTokenStreamTestCase
|
|||
}
|
||||
|
||||
private String readFully(Reader stream) throws IOException {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
int ch;
|
||||
while ((ch = stream.read()) != -1) {
|
||||
buffer.append((char) ch);
|
||||
|
|
|
@ -231,7 +231,7 @@ public class Diff {
|
|||
}
|
||||
|
||||
// read the patch string
|
||||
StringBuffer result = new StringBuffer();
|
||||
StringBuilder result = new StringBuilder();
|
||||
final char base = 'a' - 1;
|
||||
char deletes = base;
|
||||
char equals = base;
|
||||
|
|
|
@ -92,7 +92,7 @@ public class TestSearch extends LuceneTestCase {
|
|||
doTestSearch(random(), pw, false);
|
||||
pw.close();
|
||||
sw.close();
|
||||
String multiFileOutput = sw.getBuffer().toString();
|
||||
String multiFileOutput = sw.toString();
|
||||
//System.out.println(multiFileOutput);
|
||||
|
||||
sw = new StringWriter();
|
||||
|
@ -100,7 +100,7 @@ public class TestSearch extends LuceneTestCase {
|
|||
doTestSearch(random(), pw, true);
|
||||
pw.close();
|
||||
sw.close();
|
||||
String singleFileOutput = sw.getBuffer().toString();
|
||||
String singleFileOutput = sw.toString();
|
||||
|
||||
assertEquals(multiFileOutput, singleFileOutput);
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ public class TestSearchForDuplicates extends LuceneTestCase {
|
|||
doTest(random(), pw, false, MAX_DOCS);
|
||||
pw.close();
|
||||
sw.close();
|
||||
String multiFileOutput = sw.getBuffer().toString();
|
||||
String multiFileOutput = sw.toString();
|
||||
//System.out.println(multiFileOutput);
|
||||
|
||||
sw = new StringWriter();
|
||||
|
@ -61,7 +61,7 @@ public class TestSearchForDuplicates extends LuceneTestCase {
|
|||
doTest(random(), pw, true, MAX_DOCS);
|
||||
pw.close();
|
||||
sw.close();
|
||||
String singleFileOutput = sw.getBuffer().toString();
|
||||
String singleFileOutput = sw.toString();
|
||||
|
||||
assertEquals(multiFileOutput, singleFileOutput);
|
||||
}
|
||||
|
|
|
@ -149,7 +149,7 @@ public class TestDoc extends LuceneTestCase {
|
|||
out.close();
|
||||
sw.close();
|
||||
|
||||
String multiFileOutput = sw.getBuffer().toString();
|
||||
String multiFileOutput = sw.toString();
|
||||
//System.out.println(multiFileOutput);
|
||||
|
||||
sw = new StringWriter();
|
||||
|
@ -190,7 +190,7 @@ public class TestDoc extends LuceneTestCase {
|
|||
directory.close();
|
||||
out.close();
|
||||
sw.close();
|
||||
String singleFileOutput = sw.getBuffer().toString();
|
||||
String singleFileOutput = sw.toString();
|
||||
|
||||
assertEquals(multiFileOutput, singleFileOutput);
|
||||
}
|
||||
|
|
|
@ -46,6 +46,15 @@
|
|||
|
||||
<target name="javacc" depends="javacc-QueryParser,javacc-surround,javacc-flexible"/>
|
||||
|
||||
<macrodef name="replaceStringBuffer">
|
||||
<attribute name="dir"/>
|
||||
<sequential>
|
||||
<replace token="StringBuffer" value="StringBuilder" encoding="UTF-8">
|
||||
<fileset dir="@{dir}" includes="ParseException.java TokenMgrError.java"/>
|
||||
</replace>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
<target name="javacc-QueryParser" depends="resolve-javacc">
|
||||
<sequential>
|
||||
<invoke-javacc target="src/java/org/apache/lucene/queryparser/classic/QueryParser.jj"
|
||||
|
@ -60,7 +69,7 @@
|
|||
byline="true"
|
||||
match="public QueryParser\(QueryParserTokenManager "
|
||||
replace="protected QueryParser(QueryParserTokenManager "/>
|
||||
|
||||
<replaceStringBuffer dir="src/java/org/apache/lucene/queryparser/classic"/>
|
||||
</sequential>
|
||||
</target>
|
||||
|
||||
|
@ -68,6 +77,7 @@
|
|||
<invoke-javacc target="src/java/org/apache/lucene/queryparser/surround/parser/QueryParser.jj"
|
||||
outputDir="src/java/org/apache/lucene/queryparser/surround/parser"
|
||||
/>
|
||||
<replaceStringBuffer dir="src/java/org/apache/lucene/queryparser/surround/parser"/>
|
||||
</target>
|
||||
|
||||
<target name="javacc-flexible" depends="resolve-javacc">
|
||||
|
@ -126,6 +136,7 @@ import org.apache.lucene.queryparser.flexible.core.messages.*;"
|
|||
replace=" static private String add_escapes(String str) {"
|
||||
flags="g"
|
||||
byline="true"/>
|
||||
<replaceStringBuffer dir="src/java/org/apache/lucene/queryparser/flexible/standard/parser"/>
|
||||
</target>
|
||||
|
||||
<target name="resolve-javacc" xmlns:ivy="antlib:org.apache.ivy.ant">
|
||||
|
|
|
@ -112,4 +112,4 @@ interface CharStream {
|
|||
void Done();
|
||||
|
||||
}
|
||||
/* JavaCC - OriginalChecksum=30b94cad7b10d0d81e3a59a1083939d0 (do not edit this line) */
|
||||
/* JavaCC - OriginalChecksum=c847dd1920bf7901125a7244125682ad (do not edit this line) */
|
||||
|
|
|
@ -89,7 +89,7 @@ public class ParseException extends Exception {
|
|||
int[][] expectedTokenSequences,
|
||||
String[] tokenImage) {
|
||||
String eol = System.getProperty("line.separator", "\n");
|
||||
StringBuffer expected = new StringBuffer();
|
||||
StringBuilder expected = new StringBuilder();
|
||||
int maxSize = 0;
|
||||
for (int i = 0; i < expectedTokenSequences.length; i++) {
|
||||
if (maxSize < expectedTokenSequences[i].length) {
|
||||
|
@ -139,7 +139,7 @@ public class ParseException extends Exception {
|
|||
* string literal.
|
||||
*/
|
||||
static String add_escapes(String str) {
|
||||
StringBuffer retval = new StringBuffer();
|
||||
StringBuilder retval = new StringBuilder();
|
||||
char ch;
|
||||
for (int i = 0; i < str.length(); i++) {
|
||||
switch (str.charAt(i))
|
||||
|
@ -184,4 +184,4 @@ public class ParseException extends Exception {
|
|||
}
|
||||
|
||||
}
|
||||
/* JavaCC - OriginalChecksum=b187d97d5bb75c3fc63d642c1c26ac6e (do not edit this line) */
|
||||
/* JavaCC - OriginalChecksum=61602edcb3a15810cbc58f5593eba40d (do not edit this line) */
|
||||
|
|
|
@ -128,4 +128,4 @@ public class Token implements java.io.Serializable {
|
|||
}
|
||||
|
||||
}
|
||||
/* JavaCC - OriginalChecksum=405bb5d2fcd84e94ac1c8f0b12c1f914 (do not edit this line) */
|
||||
/* JavaCC - OriginalChecksum=c1e1418b35aa9e47ef8dc98b87423d70 (do not edit this line) */
|
||||
|
|
|
@ -48,7 +48,7 @@ public class TokenMgrError extends Error
|
|||
* equivalents in the given string
|
||||
*/
|
||||
protected static final String addEscapes(String str) {
|
||||
StringBuffer retval = new StringBuffer();
|
||||
StringBuilder retval = new StringBuilder();
|
||||
char ch;
|
||||
for (int i = 0; i < str.length(); i++) {
|
||||
switch (str.charAt(i))
|
||||
|
@ -144,4 +144,4 @@ public class TokenMgrError extends Error
|
|||
this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
|
||||
}
|
||||
}
|
||||
/* JavaCC - OriginalChecksum=f433e1a52b8eadbf12f3fbbbf87fd140 (do not edit this line) */
|
||||
/* JavaCC - OriginalChecksum=0c275864a1972d9a01601ab81426872d (do not edit this line) */
|
||||
|
|
|
@ -112,4 +112,4 @@ interface CharStream {
|
|||
void Done();
|
||||
|
||||
}
|
||||
/* JavaCC - OriginalChecksum=53b2ec7502d50e2290e86187a6c01270 (do not edit this line) */
|
||||
/* JavaCC - OriginalChecksum=c95f1720d9b38046dc5d294b741c44cb (do not edit this line) */
|
||||
|
|
|
@ -92,7 +92,7 @@ public class ParseException extends QueryNodeParseException {
|
|||
int[][] expectedTokenSequences,
|
||||
String[] tokenImage) {
|
||||
String eol = System.getProperty("line.separator", "\n");
|
||||
StringBuffer expected = new StringBuffer();
|
||||
StringBuilder expected = new StringBuilder();
|
||||
int maxSize = 0;
|
||||
for (int i = 0; i < expectedTokenSequences.length; i++) {
|
||||
if (maxSize < expectedTokenSequences[i].length) {
|
||||
|
@ -142,7 +142,7 @@ public class ParseException extends QueryNodeParseException {
|
|||
* string literal.
|
||||
*/
|
||||
static String add_escapes(String str) {
|
||||
StringBuffer retval = new StringBuffer();
|
||||
StringBuilder retval = new StringBuilder();
|
||||
char ch;
|
||||
for (int i = 0; i < str.length(); i++) {
|
||||
switch (str.charAt(i))
|
||||
|
@ -187,4 +187,4 @@ public class ParseException extends QueryNodeParseException {
|
|||
}
|
||||
|
||||
}
|
||||
/* JavaCC - OriginalChecksum=4263a02db9988d7a863aa97ad2f6dc67 (do not edit this line) */
|
||||
/* JavaCC - OriginalChecksum=81401c29cf6f9909761c636b4778ccc0 (do not edit this line) */
|
||||
|
|
|
@ -128,4 +128,4 @@ public class Token implements java.io.Serializable {
|
|||
}
|
||||
|
||||
}
|
||||
/* JavaCC - OriginalChecksum=ea8b1e55950603be28e2f63dcd544ab4 (do not edit this line) */
|
||||
/* JavaCC - OriginalChecksum=30bbd23e0dec26f141130dc62a4f6e9d (do not edit this line) */
|
||||
|
|
|
@ -48,7 +48,7 @@ public class TokenMgrError extends Error
|
|||
* equivalents in the given string
|
||||
*/
|
||||
protected static final String addEscapes(String str) {
|
||||
StringBuffer retval = new StringBuffer();
|
||||
StringBuilder retval = new StringBuilder();
|
||||
char ch;
|
||||
for (int i = 0; i < str.length(); i++) {
|
||||
switch (str.charAt(i))
|
||||
|
@ -144,4 +144,4 @@ public class TokenMgrError extends Error
|
|||
this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
|
||||
}
|
||||
}
|
||||
/* JavaCC - OriginalChecksum=be88283d82a985d82a34dda46bcf42d5 (do not edit this line) */
|
||||
/* JavaCC - OriginalChecksum=3ca7fbf7de9f2424b131a5499b0a78d0 (do not edit this line) */
|
||||
|
|
|
@ -112,4 +112,4 @@ interface CharStream {
|
|||
void Done();
|
||||
|
||||
}
|
||||
/* JavaCC - OriginalChecksum=242ae59b965491e225a44534cbc73b42 (do not edit this line) */
|
||||
/* JavaCC - OriginalChecksum=5ca20c9145f29a0f8909470a7f949fe4 (do not edit this line) */
|
||||
|
|
|
@ -89,7 +89,7 @@ public class ParseException extends Exception {
|
|||
int[][] expectedTokenSequences,
|
||||
String[] tokenImage) {
|
||||
String eol = System.getProperty("line.separator", "\n");
|
||||
StringBuffer expected = new StringBuffer();
|
||||
StringBuilder expected = new StringBuilder();
|
||||
int maxSize = 0;
|
||||
for (int i = 0; i < expectedTokenSequences.length; i++) {
|
||||
if (maxSize < expectedTokenSequences[i].length) {
|
||||
|
@ -139,7 +139,7 @@ public class ParseException extends Exception {
|
|||
* string literal.
|
||||
*/
|
||||
static String add_escapes(String str) {
|
||||
StringBuffer retval = new StringBuffer();
|
||||
StringBuilder retval = new StringBuilder();
|
||||
char ch;
|
||||
for (int i = 0; i < str.length(); i++) {
|
||||
switch (str.charAt(i))
|
||||
|
@ -184,4 +184,4 @@ public class ParseException extends Exception {
|
|||
}
|
||||
|
||||
}
|
||||
/* JavaCC - OriginalChecksum=bd8163f41bf2fd1bb00f025fce3dcaaf (do not edit this line) */
|
||||
/* JavaCC - OriginalChecksum=be6f55e3bf157e8c96b4c06cca5ec81b (do not edit this line) */
|
||||
|
|
|
@ -128,4 +128,4 @@ public class Token implements java.io.Serializable {
|
|||
}
|
||||
|
||||
}
|
||||
/* JavaCC - OriginalChecksum=f2df701e24da1cf2d025118ce6efdd2f (do not edit this line) */
|
||||
/* JavaCC - OriginalChecksum=db38f23b3674db52ff034369707a0ac3 (do not edit this line) */
|
||||
|
|
|
@ -48,7 +48,7 @@ public class TokenMgrError extends Error
|
|||
* equivalents in the given string
|
||||
*/
|
||||
protected static final String addEscapes(String str) {
|
||||
StringBuffer retval = new StringBuffer();
|
||||
StringBuilder retval = new StringBuilder();
|
||||
char ch;
|
||||
for (int i = 0; i < str.length(); i++) {
|
||||
switch (str.charAt(i))
|
||||
|
@ -144,4 +144,4 @@ public class TokenMgrError extends Error
|
|||
this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
|
||||
}
|
||||
}
|
||||
/* JavaCC - OriginalChecksum=8c69a370d9a9893140562c8bb911678c (do not edit this line) */
|
||||
/* JavaCC - OriginalChecksum=dcdd5ccde13b91bcd8f76a86ca618852 (do not edit this line) */
|
||||
|
|
|
@ -419,7 +419,7 @@ public class JaspellTernarySearchTrie {
|
|||
*@return The <code>String</code> that indexes the node argument.
|
||||
*/
|
||||
protected String getKey(TSTNode node) {
|
||||
StringBuffer getKeyBuffer = new StringBuffer();
|
||||
StringBuilder getKeyBuffer = new StringBuilder();
|
||||
getKeyBuffer.setLength(0);
|
||||
getKeyBuffer.append("" + node.splitchar);
|
||||
TSTNode currentNode;
|
||||
|
|
|
@ -293,7 +293,7 @@ public class MailEntityProcessor extends EntityProcessorBase {
|
|||
|
||||
private void logConfig() {
|
||||
if (!LOG.isInfoEnabled()) return;
|
||||
StringBuffer config = new StringBuffer();
|
||||
StringBuilder config = new StringBuilder();
|
||||
config.append("user : ").append(user).append(System.getProperty("line.separator"));
|
||||
config.append("pwd : ").append(password).append(System.getProperty("line.separator"));
|
||||
config.append("protocol : ").append(protocol).append(System.getProperty("line.separator"));
|
||||
|
|
|
@ -287,7 +287,7 @@ public abstract class LanguageIdentifierUpdateProcessor extends UpdateRequestPro
|
|||
* Concatenates content from multiple fields
|
||||
*/
|
||||
protected String concatFields(SolrInputDocument doc, String[] fields) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (String fieldName : inputFields) {
|
||||
log.debug("Appending field "+fieldName);
|
||||
if (doc.containsKey(fieldName)) {
|
||||
|
|
|
@ -78,6 +78,9 @@
|
|||
byline="true"
|
||||
match="public QueryParser\(QueryParserTokenManager "
|
||||
replace="protected QueryParser(QueryParserTokenManager "/>
|
||||
<replace token="StringBuffer" value="StringBuilder" encoding="UTF-8">
|
||||
<fileset dir="src/java/org/apache/solr/parser" includes="ParseException.java TokenMgrError.java"/>
|
||||
</replace>
|
||||
|
||||
</sequential>
|
||||
</target>
|
||||
|
|
|
@ -574,7 +574,7 @@ public class SnapPuller {
|
|||
if (props.containsKey(TIMES_INDEX_REPLICATED)) {
|
||||
indexCount = Integer.valueOf(props.getProperty(TIMES_INDEX_REPLICATED)) + 1;
|
||||
}
|
||||
StringBuffer sb = readToStringBuffer(replicationTime, props.getProperty(INDEX_REPLICATED_AT_LIST));
|
||||
StringBuilder sb = readToStringBuilder(replicationTime, props.getProperty(INDEX_REPLICATED_AT_LIST));
|
||||
props.setProperty(INDEX_REPLICATED_AT_LIST, sb.toString());
|
||||
props.setProperty(INDEX_REPLICATED_AT, String.valueOf(replicationTime));
|
||||
props.setProperty(PREVIOUS_CYCLE_TIME_TAKEN, String.valueOf(replicationTimeTaken));
|
||||
|
@ -596,7 +596,7 @@ public class SnapPuller {
|
|||
}
|
||||
props.setProperty(TIMES_FAILED, String.valueOf(numFailures));
|
||||
props.setProperty(REPLICATION_FAILED_AT, String.valueOf(replicationTime));
|
||||
sb = readToStringBuffer(replicationTime, props.getProperty(REPLICATION_FAILED_AT_LIST));
|
||||
sb = readToStringBuilder(replicationTime, props.getProperty(REPLICATION_FAILED_AT_LIST));
|
||||
props.setProperty(REPLICATION_FAILED_AT_LIST, sb.toString());
|
||||
}
|
||||
|
||||
|
@ -639,8 +639,8 @@ public class SnapPuller {
|
|||
return bytesDownloaded;
|
||||
}
|
||||
|
||||
private StringBuffer readToStringBuffer(long replicationTime, String str) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
private StringBuilder readToStringBuilder(long replicationTime, String str) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
List<String> l = new ArrayList<String>();
|
||||
if (str != null && str.length() != 0) {
|
||||
String[] ss = str.split(",");
|
||||
|
|
|
@ -187,16 +187,6 @@ public class CharBuffer {
|
|||
return c[pos];
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the contents of the buffer into a StringBuffer.
|
||||
* This method involves copying the new data once!
|
||||
*/
|
||||
public StringBuffer toStringBuffer() {
|
||||
StringBuffer sb = new StringBuffer(length);
|
||||
sb.append(c, 0, length);
|
||||
return sb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the contents of the buffer into a StringBuffer.
|
||||
* This method involves copying the new data once!
|
||||
|
|
|
@ -46,7 +46,7 @@ public class CSVWriter {
|
|||
public void writeRecord(Map map) {
|
||||
CSVField[] fields = config.getFields();
|
||||
try {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < fields.length; i++) {
|
||||
Object o = map.get(fields[i].getName());
|
||||
if (o != null) {
|
||||
|
@ -83,7 +83,7 @@ public class CSVWriter {
|
|||
if (field.overrideFill()) {
|
||||
fillPattern = field.getFill();
|
||||
}
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int fillSize = (field.getSize() - value.length());
|
||||
char[] fill = new char[fillSize];
|
||||
Arrays.fill(fill, config.getFillChar());
|
||||
|
|
|
@ -112,4 +112,4 @@ interface CharStream {
|
|||
void Done();
|
||||
|
||||
}
|
||||
/* JavaCC - OriginalChecksum=48b70e7c01825c8f301c7362bf1028d8 (do not edit this line) */
|
||||
/* JavaCC - OriginalChecksum=a81c9280a3ec4578458c607a9d95acb4 (do not edit this line) */
|
||||
|
|
|
@ -89,7 +89,7 @@ public class ParseException extends Exception {
|
|||
int[][] expectedTokenSequences,
|
||||
String[] tokenImage) {
|
||||
String eol = System.getProperty("line.separator", "\n");
|
||||
StringBuffer expected = new StringBuffer();
|
||||
StringBuilder expected = new StringBuilder();
|
||||
int maxSize = 0;
|
||||
for (int i = 0; i < expectedTokenSequences.length; i++) {
|
||||
if (maxSize < expectedTokenSequences[i].length) {
|
||||
|
@ -139,7 +139,7 @@ public class ParseException extends Exception {
|
|||
* string literal.
|
||||
*/
|
||||
static String add_escapes(String str) {
|
||||
StringBuffer retval = new StringBuffer();
|
||||
StringBuilder retval = new StringBuilder();
|
||||
char ch;
|
||||
for (int i = 0; i < str.length(); i++) {
|
||||
switch (str.charAt(i))
|
||||
|
@ -184,4 +184,4 @@ public class ParseException extends Exception {
|
|||
}
|
||||
|
||||
}
|
||||
/* JavaCC - OriginalChecksum=25e1ae9ad9614c4ce31c4b83f8a7397b (do not edit this line) */
|
||||
/* JavaCC - OriginalChecksum=d7aa203ee92ebbb23011a23311e60537 (do not edit this line) */
|
||||
|
|
|
@ -91,7 +91,6 @@ public class QueryParser extends SolrQueryParserBase implements QueryParserConst
|
|||
}
|
||||
|
||||
// This makes sure that there is no garbage after the query string
|
||||
@Override
|
||||
final public Query TopLevelQuery(String field) throws ParseException, SyntaxError {
|
||||
Query q;
|
||||
q = Query(field);
|
||||
|
@ -479,7 +478,6 @@ public class QueryParser extends SolrQueryParserBase implements QueryParserConst
|
|||
}
|
||||
|
||||
/** Reinitialise. */
|
||||
@Override
|
||||
public void ReInit(CharStream stream) {
|
||||
token_source.ReInit(stream);
|
||||
token = new Token();
|
||||
|
|
|
@ -97,7 +97,6 @@ public class Token implements java.io.Serializable {
|
|||
/**
|
||||
* Returns the image.
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return image;
|
||||
|
@ -129,4 +128,4 @@ public class Token implements java.io.Serializable {
|
|||
}
|
||||
|
||||
}
|
||||
/* JavaCC - OriginalChecksum=f463ad6fd3205ca07166de02ee86b907 (do not edit this line) */
|
||||
/* JavaCC - OriginalChecksum=9036cc9068ac33d9c79403fe5349f705 (do not edit this line) */
|
||||
|
|
|
@ -48,7 +48,7 @@ public class TokenMgrError extends Error
|
|||
* equivalents in the given string
|
||||
*/
|
||||
protected static final String addEscapes(String str) {
|
||||
StringBuffer retval = new StringBuffer();
|
||||
StringBuilder retval = new StringBuilder();
|
||||
char ch;
|
||||
for (int i = 0; i < str.length(); i++) {
|
||||
switch (str.charAt(i))
|
||||
|
@ -121,7 +121,6 @@ public class TokenMgrError extends Error
|
|||
*
|
||||
* from this method for such cases in the release version of your parser.
|
||||
*/
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return super.getMessage();
|
||||
}
|
||||
|
@ -145,4 +144,4 @@ public class TokenMgrError extends Error
|
|||
this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
|
||||
}
|
||||
}
|
||||
/* JavaCC - OriginalChecksum=200a46f65c1a0f71a7f037b35f4e934e (do not edit this line) */
|
||||
/* JavaCC - OriginalChecksum=59744072870f5c27fc8796947fc3b06f (do not edit this line) */
|
||||
|
|
|
@ -947,7 +947,7 @@ public class SimplePostTool {
|
|||
public static String getXP(Node n, String xpath, boolean concatAll)
|
||||
throws XPathExpressionException {
|
||||
NodeList nodes = getNodesFromXP(n, xpath);
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (nodes.getLength() > 0) {
|
||||
for(int i = 0; i < nodes.getLength() ; i++) {
|
||||
sb.append(nodes.item(i).getNodeValue() + " ");
|
||||
|
|
|
@ -96,7 +96,7 @@ public class TestRandomDVFaceting extends SolrTestCaseJ4 {
|
|||
}
|
||||
if (ids.size() == 0) return;
|
||||
|
||||
StringBuffer sb = new StringBuffer("id:(");
|
||||
StringBuilder sb = new StringBuilder("id:(");
|
||||
for (String id : ids) {
|
||||
sb.append(id).append(' ');
|
||||
model.remove(id);
|
||||
|
|
|
@ -95,7 +95,7 @@ public class TestRandomFaceting extends SolrTestCaseJ4 {
|
|||
}
|
||||
if (ids.size() == 0) return;
|
||||
|
||||
StringBuffer sb = new StringBuffer("id:(");
|
||||
StringBuilder sb = new StringBuilder("id:(");
|
||||
for (String id : ids) {
|
||||
sb.append(id).append(' ');
|
||||
model.remove(id);
|
||||
|
|
|
@ -156,11 +156,11 @@ public class CSVPrinterTest extends TestCase {
|
|||
}
|
||||
|
||||
public static String printable(String s) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i=0; i<s.length(); i++) {
|
||||
char ch = s.charAt(i);
|
||||
if (ch<=' ' || ch>=128) {
|
||||
sb.append("(" + (int)ch + ")");
|
||||
sb.append("(").append((int)ch).append(")");
|
||||
} else {
|
||||
sb.append(ch);
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ public class CSVConfigGuesserTest extends TestCase {
|
|||
field.setSize(4);
|
||||
expected.addField(field);
|
||||
expected.addField(field);
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("1234;abcd;1234\n");
|
||||
sb.append("abcd;1234;abcd");
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(sb.toString().getBytes("UTF-8"));
|
||||
|
@ -77,7 +77,7 @@ public class CSVConfigGuesserTest extends TestCase {
|
|||
expected.setFill(CSVConfig.FILLRIGHT);
|
||||
expected.setIgnoreValueDelimiter(false);
|
||||
// expected.setFixedWidth(false);
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("1,2,3,4\n");
|
||||
sb.append("abcd,1234,abcd,1234");
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(sb.toString().getBytes("UTF-8"));
|
||||
|
|
|
@ -57,7 +57,7 @@ public class Base64 {
|
|||
int numFullGroups = aLen / 3;
|
||||
int numBytesInPartialGroup = aLen - 3 * numFullGroups;
|
||||
int resultLen = 4 * ((aLen + 2) / 3);
|
||||
StringBuffer result = new StringBuffer(resultLen);
|
||||
StringBuilder result = new StringBuilder(resultLen);
|
||||
char[] intToAlpha = intToBase64;
|
||||
|
||||
// Translate all full groups from byte array elements to Base64
|
||||
|
|
|
@ -871,7 +871,7 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase {
|
|||
*/
|
||||
public static XmlDoc doc(String... fieldsAndValues) {
|
||||
XmlDoc d = new XmlDoc();
|
||||
d.xml = TestHarness.makeSimpleDoc(fieldsAndValues).toString();
|
||||
d.xml = TestHarness.makeSimpleDoc(fieldsAndValues);
|
||||
return d;
|
||||
}
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ abstract public class BaseTestHarness {
|
|||
*
|
||||
* @param fieldsAndValues 0 and Even numbered args are fields names odds are field values.
|
||||
*/
|
||||
public static StringBuffer makeSimpleDoc(String... fieldsAndValues) {
|
||||
public static String makeSimpleDoc(String... fieldsAndValues) {
|
||||
|
||||
try {
|
||||
StringWriter w = new StringWriter();
|
||||
|
@ -113,7 +113,7 @@ abstract public class BaseTestHarness {
|
|||
fieldsAndValues[i]);
|
||||
}
|
||||
w.append("</doc>");
|
||||
return w.getBuffer();
|
||||
return w.toString();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException
|
||||
("this should never happen with a StringWriter", e);
|
||||
|
|
Loading…
Reference in New Issue