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:
parent
37c07ef765
commit
40a1ac82ef
|
@ -537,13 +537,13 @@ public class UpdateRequest extends InstanceShardOperationRequest<UpdateRequest>
|
||||||
public UpdateRequest source(BytesReference source) throws Exception {
|
public UpdateRequest source(BytesReference source) throws Exception {
|
||||||
XContentType xContentType = XContentFactory.xContentType(source);
|
XContentType xContentType = XContentFactory.xContentType(source);
|
||||||
try (XContentParser parser = XContentFactory.xContent(xContentType).createParser(source)) {
|
try (XContentParser parser = XContentFactory.xContent(xContentType).createParser(source)) {
|
||||||
XContentParser.Token t = parser.nextToken();
|
XContentParser.Token token = parser.nextToken();
|
||||||
if (t == null) {
|
if (token == null) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
String currentFieldName = null;
|
String currentFieldName = null;
|
||||||
while ((t = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||||
if (t == XContentParser.Token.FIELD_NAME) {
|
if (token == XContentParser.Token.FIELD_NAME) {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if ("script".equals(currentFieldName)) {
|
} else if ("script".equals(currentFieldName)) {
|
||||||
script = parser.textOrNull();
|
script = parser.textOrNull();
|
||||||
|
|
|
@ -434,28 +434,28 @@ public class MappingMetaData {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
XContentParser.Token t = parser.currentToken();
|
XContentParser.Token token = parser.currentToken();
|
||||||
if (t == null) {
|
if (token == null) {
|
||||||
t = parser.nextToken();
|
token = parser.nextToken();
|
||||||
}
|
}
|
||||||
if (t == XContentParser.Token.START_OBJECT) {
|
if (token == XContentParser.Token.START_OBJECT) {
|
||||||
t = parser.nextToken();
|
token = parser.nextToken();
|
||||||
}
|
}
|
||||||
String idPart = context.idParsingStillNeeded() ? id().pathElements()[context.locationId] : null;
|
String idPart = context.idParsingStillNeeded() ? id().pathElements()[context.locationId] : null;
|
||||||
String routingPart = context.routingParsingStillNeeded() ? routing().pathElements()[context.locationRouting] : null;
|
String routingPart = context.routingParsingStillNeeded() ? routing().pathElements()[context.locationRouting] : null;
|
||||||
String timestampPart = context.timestampParsingStillNeeded() ? timestamp().pathElements()[context.locationTimestamp] : 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
|
// Must point to field name
|
||||||
String fieldName = parser.currentName();
|
String fieldName = parser.currentName();
|
||||||
// And then the value...
|
// And then the value...
|
||||||
t = parser.nextToken();
|
token = parser.nextToken();
|
||||||
boolean incLocationId = false;
|
boolean incLocationId = false;
|
||||||
boolean incLocationRouting = false;
|
boolean incLocationRouting = false;
|
||||||
boolean incLocationTimestamp = false;
|
boolean incLocationTimestamp = false;
|
||||||
if (context.idParsingStillNeeded() && fieldName.equals(idPart)) {
|
if (context.idParsingStillNeeded() && fieldName.equals(idPart)) {
|
||||||
if (context.locationId + 1 == id.pathElements().length) {
|
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");
|
throw new MapperParsingException("id field must be a value but was either an object or an array");
|
||||||
}
|
}
|
||||||
context.id = parser.textOrNull();
|
context.id = parser.textOrNull();
|
||||||
|
@ -482,7 +482,7 @@ public class MappingMetaData {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (incLocationId || incLocationRouting || incLocationTimestamp) {
|
if (incLocationId || incLocationRouting || incLocationTimestamp) {
|
||||||
if (t == XContentParser.Token.START_OBJECT) {
|
if (token == XContentParser.Token.START_OBJECT) {
|
||||||
context.locationId += incLocationId ? 1 : 0;
|
context.locationId += incLocationId ? 1 : 0;
|
||||||
context.locationRouting += incLocationRouting ? 1 : 0;
|
context.locationRouting += incLocationRouting ? 1 : 0;
|
||||||
context.locationTimestamp += incLocationTimestamp ? 1 : 0;
|
context.locationTimestamp += incLocationTimestamp ? 1 : 0;
|
||||||
|
|
|
@ -271,16 +271,16 @@ public class XContentHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void copyCurrentStructure(XContentGenerator generator, XContentParser parser) throws IOException {
|
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
|
// Let's handle field-name separately first
|
||||||
if (t == XContentParser.Token.FIELD_NAME) {
|
if (token == XContentParser.Token.FIELD_NAME) {
|
||||||
generator.writeFieldName(parser.currentName());
|
generator.writeFieldName(parser.currentName());
|
||||||
t = parser.nextToken();
|
token = parser.nextToken();
|
||||||
// fall-through to copy the associated value
|
// fall-through to copy the associated value
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (t) {
|
switch (token) {
|
||||||
case START_ARRAY:
|
case START_ARRAY:
|
||||||
generator.writeStartArray();
|
generator.writeStartArray();
|
||||||
while (parser.nextToken() != XContentParser.Token.END_ARRAY) {
|
while (parser.nextToken() != XContentParser.Token.END_ARRAY) {
|
||||||
|
|
|
@ -260,38 +260,38 @@ public abstract class AbstractXContentParser implements XContentParser {
|
||||||
|
|
||||||
static Map<String, Object> readMap(XContentParser parser, MapFactory mapFactory) throws IOException {
|
static Map<String, Object> readMap(XContentParser parser, MapFactory mapFactory) throws IOException {
|
||||||
Map<String, Object> map = mapFactory.newMap();
|
Map<String, Object> map = mapFactory.newMap();
|
||||||
XContentParser.Token t = parser.currentToken();
|
XContentParser.Token token = parser.currentToken();
|
||||||
if (t == null) {
|
if (token == null) {
|
||||||
t = parser.nextToken();
|
token = parser.nextToken();
|
||||||
}
|
}
|
||||||
if (t == XContentParser.Token.START_OBJECT) {
|
if (token == XContentParser.Token.START_OBJECT) {
|
||||||
t = parser.nextToken();
|
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
|
// Must point to field name
|
||||||
String fieldName = parser.currentName();
|
String fieldName = parser.currentName();
|
||||||
// And then the value...
|
// And then the value...
|
||||||
t = parser.nextToken();
|
token = parser.nextToken();
|
||||||
Object value = readValue(parser, mapFactory, t);
|
Object value = readValue(parser, mapFactory, token);
|
||||||
map.put(fieldName, value);
|
map.put(fieldName, value);
|
||||||
}
|
}
|
||||||
return map;
|
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<>();
|
ArrayList<Object> list = new ArrayList<>();
|
||||||
while ((t = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
|
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
|
||||||
list.add(readValue(parser, mapFactory, t));
|
list.add(readValue(parser, mapFactory, token));
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Object readValue(XContentParser parser, MapFactory mapFactory, XContentParser.Token t) throws IOException {
|
private static Object readValue(XContentParser parser, MapFactory mapFactory, XContentParser.Token token) throws IOException {
|
||||||
if (t == XContentParser.Token.VALUE_NULL) {
|
if (token == XContentParser.Token.VALUE_NULL) {
|
||||||
return null;
|
return null;
|
||||||
} else if (t == XContentParser.Token.VALUE_STRING) {
|
} else if (token == XContentParser.Token.VALUE_STRING) {
|
||||||
return parser.text();
|
return parser.text();
|
||||||
} else if (t == XContentParser.Token.VALUE_NUMBER) {
|
} else if (token == XContentParser.Token.VALUE_NUMBER) {
|
||||||
XContentParser.NumberType numberType = parser.numberType();
|
XContentParser.NumberType numberType = parser.numberType();
|
||||||
if (numberType == XContentParser.NumberType.INT) {
|
if (numberType == XContentParser.NumberType.INT) {
|
||||||
return parser.intValue();
|
return parser.intValue();
|
||||||
|
@ -302,13 +302,13 @@ public abstract class AbstractXContentParser implements XContentParser {
|
||||||
} else if (numberType == XContentParser.NumberType.DOUBLE) {
|
} else if (numberType == XContentParser.NumberType.DOUBLE) {
|
||||||
return parser.doubleValue();
|
return parser.doubleValue();
|
||||||
}
|
}
|
||||||
} else if (t == XContentParser.Token.VALUE_BOOLEAN) {
|
} else if (token == XContentParser.Token.VALUE_BOOLEAN) {
|
||||||
return parser.booleanValue();
|
return parser.booleanValue();
|
||||||
} else if (t == XContentParser.Token.START_OBJECT) {
|
} else if (token == XContentParser.Token.START_OBJECT) {
|
||||||
return readMap(parser, mapFactory);
|
return readMap(parser, mapFactory);
|
||||||
} else if (t == XContentParser.Token.START_ARRAY) {
|
} else if (token == XContentParser.Token.START_ARRAY) {
|
||||||
return readList(parser, mapFactory, t);
|
return readList(parser, mapFactory, token);
|
||||||
} else if (t == XContentParser.Token.VALUE_EMBEDDED_OBJECT) {
|
} else if (token == XContentParser.Token.VALUE_EMBEDDED_OBJECT) {
|
||||||
return parser.binaryValue();
|
return parser.binaryValue();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Reference in New Issue