4 import java.util.regex.Matcher;
5 import java.util.regex.Pattern;
8 * nicobrowser.util.Utilより, 必要なものをピックアップしたクラス.
12 public final class Util {
18 * Content-Type から拡張子を決定する.
19 * @param contentType Content-Type文字列.
22 public static String getExtention(String contentType) {
23 if ("video/flv".equals(contentType) || "video/x-flv".equals(contentType)) {
25 } else if ("video/mp4".equals(contentType)) {
27 } else if ("application/x-shockwave-flash".equals(contentType)) {
30 return contentType.split("/")[1];
33 public static String getVideoId(final String alterId) {
34 final int startIdIdx = alterId.lastIndexOf("/") + 1;
35 final String altId = alterId.substring(startIdIdx);
36 final Pattern idPattern = Pattern.compile("([a-z]*\\d+)");
37 final Matcher idMatcher = idPattern.matcher(altId);
38 if (!idMatcher.find()) {
39 throw new IllegalArgumentException("URL/IDの指定が不正です: " + alterId);
42 return idMatcher.group(1);