parentType = classType.getGenericSuperclass();
}
if (itemType == null) {
throw new SerializationException("Could not determine sequence item type.");
}
// Instantiate the sequence type
Class<?> sequenceType;
if (typeArgument instanceof ParameterizedType) {
ParameterizedType parameterizedType = (ParameterizedType)typeArgument;
sequenceType = (Class<?>)parameterizedType.getRawType();
} else {
sequenceType = (Class<?>)typeArgument;
}
try {
sequence = (Sequence<Object>)sequenceType.newInstance();
} catch (InstantiationException exception) {
throw new RuntimeException(exception);
} catch (IllegalAccessException exception) {
throw new RuntimeException(exception);
}
}
// Notify the listeners
if (jsonSerializerListeners != null) {
jsonSerializerListeners.beginSequence(this, sequence);
}
// Move to the next character after '['
c = reader.read();
skipWhitespaceAndComments(reader);
while (c != -1 && c != ']') {
sequence.add(readValue(reader, itemType));
skipWhitespaceAndComments(reader);
if (c == ',') {
c = reader.read();
skipWhitespaceAndComments(reader);
} else if (c == -1) {
throw new SerializationException("Unexpected end of input stream.");
} else {
if (c != ']') {
throw new SerializationException("Unexpected character in input stream.");
}
}
}
// Move to the next character after ']'