reader = new BufferedReader(new InputStreamReader(entityStream));
}
char c = JsonParsing.eatWhitspace(reader, false);
if (c != '[') throw new JAXBUnmarshalException("Expecting a json array as input");
c = JsonParsing.eatWhitspace(reader, true);
ArrayList list = new ArrayList();
if (c != ']')
{
MessageBodyReader messageReader = providers.getMessageBodyReader(baseType, null, annotations, mediaType);
do
{
String str = JsonParsing.extractJsonMapString(reader);
ByteArrayInputStream stream = new ByteArrayInputStream(str.getBytes());
Object obj = messageReader.readFrom(baseType, null, annotations, mediaType, httpHeaders, stream);
list.add(obj);
c = JsonParsing.eatWhitspace(reader, false);
if (c == ']') break;
if (c != ',')
{
throw new JAXBUnmarshalException("Was expecting a ',' in json array");
}
c = JsonParsing.eatWhitspace(reader, true);
} while (c != -1);
}
if (type.isArray())
{
Object array = Array.newInstance(baseType, list.size());
for (int i = 0; i < list.size(); i++)
{
Array.set(array, i, list.get(i));
}
return array;
}
else
{
Collection outCol = null;
if (type.isInterface())
{
if (List.class.isAssignableFrom(type)) return list;
else if (Set.class.isAssignableFrom(type)) outCol = new HashSet();
else outCol = new ArrayList();
}
else
{
try
{
outCol = (Collection) type.newInstance();
}
catch (Exception e)
{
throw new JAXBUnmarshalException(e);
}
}
outCol.addAll(list);
return outCol;
}