nl.vpro.api.rs.subtitles.AbstractIteratorReader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of subtitles-domain Show documentation
Show all versions of subtitles-domain Show documentation
Subtitles are related to media, but are implemented completely parallel. Classes to contain, parse, and assemble subtitle objects are here.
The newest version!
package nl.vpro.api.rs.subtitles;
import java.io.InputStream;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import java.util.Iterator;
import jakarta.ws.rs.WebApplicationException;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.MultivaluedMap;
import jakarta.ws.rs.ext.MessageBodyReader;
import nl.vpro.domain.subtitles.Cue;
/**
* @author Michiel Meeuwissen
* @since 5.1
*/
abstract class AbstractIteratorReader implements MessageBodyReader> {
private final MediaType mediaType;
public AbstractIteratorReader(MediaType mediaType) {
this.mediaType = mediaType;
}
@Override
public boolean isReadable(Class> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
return mediaType.isCompatible(this.mediaType) && Iterator.class.isAssignableFrom(type);
}
@Override
public Iterator readFrom(Class> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap httpHeaders, InputStream entityStream) throws WebApplicationException {
return read(entityStream);
}
abstract Iterator read(InputStream entityStream);
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy