nl.vpro.domain.subtitles.SubtitlesFormat 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.domain.subtitles;
import lombok.Getter;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.Optional;
import jakarta.xml.bind.annotation.XmlEnum;
import jakarta.xml.bind.annotation.XmlType;
import nl.vpro.api.rs.subtitles.Constants;
import nl.vpro.util.ISO6937CharsetProvider;
/**
* The recognized (by POMS) subtitles formats.
* @author Michiel Meeuwissen
* @since 4.7
*/
@XmlEnum
@XmlType(name = "subtitlesFormatEnum")
public enum SubtitlesFormat {
/**
* WEBVTT
*/
WEBVTT("vtt", Constants.VTT, StandardCharsets.UTF_8),
TT888("txt", Constants.TT888, ISO6937CharsetProvider.ISO6937),
EBU("stl", Constants.EBU, null),
SRT("srt", Constants.SRT, Charset.forName("cp1252"))
;
@Getter
private final String extension;
@Getter
private final String mediaType;
@Getter
private final Charset charset;
SubtitlesFormat(String extension, String mediaType, Charset charset) {
this.extension = extension;
this.mediaType = mediaType;
this.charset = charset;
}
public static Optional ofExtension(String extension) {
for (SubtitlesFormat sf : values()) {
if (sf.extension.equalsIgnoreCase(extension)) {
return Optional.of(sf);
}
}
return Optional.empty();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy