Renamed XContentParser.Token named "t" to "token".

The name "token" was declared 191 times for XContentParser.Token
objects, while "t" was used only 6 times.
This commit is contained in:
Miltos Allamanis 2014-02-10 19:19:06 +00:00 committed by Luca Cavanna
parent 37c07ef765
commit 40a1ac82ef
4 changed files with 37 additions and 37 deletions

View File

@ -537,13 +537,13 @@ public class UpdateRequest extends InstanceShardOperationRequest<UpdateRequest>
public UpdateRequest source(BytesReference source) throws Exception {
XContentType xContentType = XContentFactory.xContentType(source);
try (XContentParser parser = XContentFactory.xContent(xContentType).createParser(source)) {
XContentParser.Token t = parser.nextToken();
if (t == null) {
XContentParser.Token token = parser.nextToken();
if (token == null) {
return this;
}
String currentFieldName = null;
while ((t = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
if (t == XContentParser.Token.FIELD_NAME) {
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName();
} else if ("script".equals(currentFieldName)) {
script = parser.textOrNull();

View File

@ -434,28 +434,28 @@ public class MappingMetaData {
return;
}
XContentParser.Token t = parser.currentToken();
if (t == null) {
t = parser.nextToken();
XContentParser.Token token = parser.currentToken();
if (token == null) {
token = parser.nextToken();
}
if (t == XContentParser.Token.START_OBJECT) {
t = parser.nextToken();
if (token == XContentParser.Token.START_OBJECT) {
token = parser.nextToken();
}
String idPart = context.idParsingStillNeeded() ? id().pathElements()[context.locationId] : null;
String routingPart = context.routingParsingStillNeeded() ? routing().pathElements()[context.locationRouting] : null;
String timestampPart = context.timestampParsingStillNeeded() ? timestamp().pathElements()[context.locationTimestamp] : null;
for (; t == XContentParser.Token.FIELD_NAME; t = parser.nextToken()) {
for (; token == XContentParser.Token.FIELD_NAME; token = parser.nextToken()) {
// Must point to field name
String fieldName = parser.currentName();
// And then the value...
t = parser.nextToken();
token = parser.nextToken();
boolean incLocationId = false;
boolean incLocationRouting = false;
boolean incLocationTimestamp = false;
if (context.idParsingStillNeeded() && fieldName.equals(idPart)) {
if (context.locationId + 1 == id.pathElements().length) {
if (!t.isValue()) {
if (!token.isValue()) {
throw new MapperParsingException("id field must be a value but was either an object or an array");
}
context.id = parser.textOrNull();
@ -482,7 +482,7 @@ public class MappingMetaData {
}
if (incLocationId || incLocationRouting || incLocationTimestamp) {
if (t == XContentParser.Token.START_OBJECT) {
if (token == XContentParser.Token.START_OBJECT) {
context.locationId += incLocationId ? 1 : 0;
context.locationRouting += incLocationRouting ? 1 : 0;
context.locationTimestamp += incLocationTimestamp ? 1 : 0;

View File

@ -271,16 +271,16 @@ public class XContentHelper {
}
public static void copyCurrentStructure(XContentGenerator generator, XContentParser parser) throws IOException {
XContentParser.Token t = parser.currentToken();
XContentParser.Token token = parser.currentToken();
// Let's handle field-name separately first
if (t == XContentParser.Token.FIELD_NAME) {
if (token == XContentParser.Token.FIELD_NAME) {
generator.writeFieldName(parser.currentName());
t = parser.nextToken();
token = parser.nextToken();
// fall-through to copy the associated value
}
switch (t) {
switch (token) {
case START_ARRAY:
generator.writeStartArray();
while (parser.nextToken() != XContentParser.Token.END_ARRAY) {

View File

@ -260,38 +260,38 @@ public abstract class AbstractXContentParser implements XContentParser {
static Map<String, Object> readMap(XContentParser parser, MapFactory mapFactory) throws IOException {
Map<String, Object> map = mapFactory.newMap();
XContentParser.Token t = parser.currentToken();
if (t == null) {
t = parser.nextToken();
XContentParser.Token token = parser.currentToken();
if (token == null) {
token = parser.nextToken();
}
if (t == XContentParser.Token.START_OBJECT) {
t = parser.nextToken();
if (token == XContentParser.Token.START_OBJECT) {
token = parser.nextToken();
}
for (; t == XContentParser.Token.FIELD_NAME; t = parser.nextToken()) {
for (; token == XContentParser.Token.FIELD_NAME; token = parser.nextToken()) {
// Must point to field name
String fieldName = parser.currentName();
// And then the value...
t = parser.nextToken();
Object value = readValue(parser, mapFactory, t);
token = parser.nextToken();
Object value = readValue(parser, mapFactory, token);
map.put(fieldName, value);
}
return map;
}
private static List<Object> readList(XContentParser parser, MapFactory mapFactory, XContentParser.Token t) throws IOException {
private static List<Object> readList(XContentParser parser, MapFactory mapFactory, XContentParser.Token token) throws IOException {
ArrayList<Object> list = new ArrayList<>();
while ((t = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
list.add(readValue(parser, mapFactory, t));
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
list.add(readValue(parser, mapFactory, token));
}
return list;
}
private static Object readValue(XContentParser parser, MapFactory mapFactory, XContentParser.Token t) throws IOException {
if (t == XContentParser.Token.VALUE_NULL) {
private static Object readValue(XContentParser parser, MapFactory mapFactory, XContentParser.Token token) throws IOException {
if (token == XContentParser.Token.VALUE_NULL) {
return null;
} else if (t == XContentParser.Token.VALUE_STRING) {
} else if (token == XContentParser.Token.VALUE_STRING) {
return parser.text();
} else if (t == XContentParser.Token.VALUE_NUMBER) {
} else if (token == XContentParser.Token.VALUE_NUMBER) {
XContentParser.NumberType numberType = parser.numberType();
if (numberType == XContentParser.NumberType.INT) {
return parser.intValue();
@ -302,13 +302,13 @@ public abstract class AbstractXContentParser implements XContentParser {
} else if (numberType == XContentParser.NumberType.DOUBLE) {
return parser.doubleValue();
}
} else if (t == XContentParser.Token.VALUE_BOOLEAN) {
} else if (token == XContentParser.Token.VALUE_BOOLEAN) {
return parser.booleanValue();
} else if (t == XContentParser.Token.START_OBJECT) {
} else if (token == XContentParser.Token.START_OBJECT) {
return readMap(parser, mapFactory);
} else if (t == XContentParser.Token.START_ARRAY) {
return readList(parser, mapFactory, t);
} else if (t == XContentParser.Token.VALUE_EMBEDDED_OBJECT) {
} else if (token == XContentParser.Token.START_ARRAY) {
return readList(parser, mapFactory, token);
} else if (token == XContentParser.Token.VALUE_EMBEDDED_OBJECT) {
return parser.binaryValue();
}
return null;