private final Media readMedia(JsonParser parser) throws IOException
{
if (parser.nextToken() != JsonToken.START_OBJECT) {
reportIllegal(parser, JsonToken.START_OBJECT);
}
Media media = new Media();
JsonToken t;
while ((t = parser.nextToken()) != JsonToken.END_OBJECT) {
if (t != JsonToken.FIELD_NAME) {
reportIllegal(parser, JsonToken.FIELD_NAME);
}
// read value token (or START_ARRAY)
String field = parser.getCurrentName();
t = parser.nextToken();
Integer I = fieldToIndex.get(field);
if (I != null) {
switch (I.intValue()) {
case FIELD_IX_PLAYER:
media.setPlayer(Media.Player.valueOf(parser.getText()));
continue;
case FIELD_IX_URI:
media.setUri(parser.getText());
continue;
case FIELD_IX_TITLE:
media.setTitle(parser.getText());
continue;
case FIELD_IX_WIDTH:
media.setWidth(parser.getIntValue());
continue;
case FIELD_IX_HEIGHT:
media.setHeight(parser.getIntValue());
continue;
case FIELD_IX_FORMAT:
media.setFormat(parser.getText());
continue;
case FIELD_IX_DURATION:
media.setDuration(parser.getLongValue());
continue;
case FIELD_IX_SIZE:
media.setSize(parser.getLongValue());
continue;
case FIELD_IX_BITRATE:
media.setBitrate(parser.getIntValue());
continue;
case FIELD_IX_PERSONS:
if (t != JsonToken.START_ARRAY) {
reportIllegal(parser, JsonToken.START_ARRAY);
}
while (parser.nextToken() != JsonToken.END_ARRAY) {
media.addToPerson(parser.getText());
}
continue;
}
}
throw new IllegalStateException("Unexpected field '"+field+"'");