+ * A rudimentary check is done to ensure type is a media type. It must start with a
+ * token followed by a slash. No check is done for
+ * what follows the slash.
+ *
+ * The type may also not be one of the JavaScript media types defined in + * text/javacript + * on MDN. + * + * @param type the media type of the data block. + */ + public JavaScriptDataBlockType(String type) + { + Args.notNull(type, "type"); + Args.isTrue(TYPE_PREFIX_PATTERN.matcher(type).find(), + "'type' must be a media type (that is: start with a type followed by a slash)."); + Args.isFalse(JAVASCRIPT_MEDIA_TYPES.contains(type.toLowerCase(Locale.ENGLISH)), + "'type' may not be a JavaScript media type."); + + this.type = type; + } + + @Override + public String getType() + { + return type; + } +}