/*
@Override
public boolean isValidatingMediaInputType(MediaType inputType) {
return inputValidator!=null && inputValidator.isValidatingMediaInputType(inputType);
}
511945
@Override
	public void doTag() throws JspException, IOException {
		try {
			final PageContext pageContext = (PageContext)getJspContext();
			final ServletRequest request = pageContext.getRequest();
			final HttpServletResponse response = (HttpServletResponse)pageContext.getResponse();
			final JspWriter out = pageContext.getOut();

			final ThreadEncodingContext parentEncodingContext = ThreadEncodingContext.getCurrentContext(request);

			// Determine the container's content type
			MediaType containerContentType;
			if(parentEncodingContext != null) {
				// Use the output type of the parent
				containerContentType = parentEncodingContext.contentType;
			} else {
				// Use the content type of the response
				String responseContentType = response.getContentType();
				// Default to XHTML: TODO: Is there a better way since can't set content type early in response then reset again...
				if(responseContentType == null) responseContentType = MediaType.XHTML.getContentType();
				containerContentType = MediaType.getMediaTypeForContentType(responseContentType);
			}
			// Find the encoder
			final MediaType myContentType = getContentType();
			MediaEncoder mediaEncoder = MediaEncoder.getInstance(new HttpServletResponseEncodingContext(response), myContentType, containerContentType);
			if(mediaEncoder != null) {
				setMediaEncoderOptions(mediaEncoder);
				// Encode both our output and the content.  The encoder validates our input and guarantees valid output for our parent.
				MediaWriter mediaWriter = new MediaWriter(mediaEncoder, out);
				mediaWriter.writePrefix();
				try {
					ThreadEncodingContext.setCurrentContext(
						request,
						new ThreadEncodingContext(myContentType, mediaWriter)
					);
					try {
						doTag(mediaWriter);
					} finally {
						// Restore previous encoding context that is used for our output
						ThreadEncodingContext.setCurrentContext(request, parentEncodingContext);
					}
				} finally {
					mediaWriter.writeSuffix();
				}
			} else {
				// If parentValidMediaInput exists and is validating our output type, no additional validation is required
				if(
					parentEncodingContext != null
					&& parentEncodingContext.validMediaInput.isValidatingMediaInputType(myContentType)
				) {
					ThreadEncodingContext.setCurrentContext(
						request,
						new ThreadEncodingContext(myContentType, parentEncodingContext.validMediaInput)
					);
					try {
						doTag(out);
					} finally {
						ThreadEncodingContext.setCurrentContext(request, parentEncodingContext);
					}
				} else {
						// Not using an encoder and parent doesn't validate our output, validate our own output.
					MediaValidator validator = MediaValidator.getMediaValidator(myContentType, out);
					ThreadEncodingContext.setCurrentContext(
						request,
						new ThreadEncodingContext(myContentType, validator)
					);
					try {
						doTag(validator);
					} finally {
						ThreadEncodingContext.setCurrentContext(request, parentEncodingContext);
					}
				}
			}
		} catch(MediaException err) {
			throw new JspTagException(err);
		}
	}
253370
protected function validateType () : bool
	{
		// Checks if video type is allowed
		if ($this->validateMimeType() == FALSE) return FALSE;
		// Checks if video size is valid for upload
		if ($this->validateFileSize() == FALSE) return FALSE;
		// Finally uplods the file after successful evaluation
		if ($this->uploadFile() == FALSE) return FALSE;

		return TRUE;
	}
486443
function validateInputAsJson() {
  if (this.value) {
    try {
      JSON.parse(this.value);
      setValidationClasses(this, true);
    }
    catch(e) {
      setValidationClasses(this, false);
    }
  }
  else {
    setValidationClasses(this, false)
  }
}
1059150
private static void checkMediaType(Multimap<MediaType, SerializationFormat> simplifiedMediaTypeToFormats,
                                       MediaType mediaType) {
        final MediaType simplifiedMediaType = mediaType.withoutParameters();
        for (SerializationFormat format : simplifiedMediaTypeToFormats.get(simplifiedMediaType)) {
            for (MediaType registeredMediaType : format.mediaTypes()) {
                checkState(!registeredMediaType.is(mediaType) && !mediaType.is(registeredMediaType),
                           "media type registered already: ", mediaType);
            }
        }
    }
1078162
public function confirmMediaType($uriRetriever, $uri)
    {
        $contentType = $uriRetriever->getContentType();

        if (is_null($contentType)) {
            // Well, we didn't get an invalid one
            return;
        }

        if (in_array($contentType, array(Validator::SCHEMA_MEDIA_TYPE, 'application/json'))) {
            return;
        }

        foreach ($this->allowedInvalidContentTypeEndpoints as $endpoint) {
            if (strpos($uri, $endpoint) === 0) {
                return true;
            }
        }

        throw new InvalidSchemaMediaTypeException(sprintf('Media type %s expected', Validator::SCHEMA_MEDIA_TYPE));
    }
1306840
@Override
    public boolean canRead(@Nonnull MediaType mimeType, Type resultType) {
        MediaType type = mimeType.withoutParameters();
        return (type.is(MediaType.ANY_TEXT_TYPE) || MediaType.APPLICATION_XML_UTF_8.withoutParameters().is(type)
                || MediaType.JSON_UTF_8.withoutParameters().is(type)) && String.class.equals(TypeToken.of(resultType).getRawType());
    }
483093
@Nullable
    @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
    private CodecType identifyCodecType(@NonNull MediaCodecInfo codecInfo) {

        final String name = codecInfo.getName();
        for (String token : AVC_TYPES) {
            if (name.contains(token)) {
                return CodecType.AVC;
            }
        }
        for (String token : H263_TYPES) {
            if (name.contains(token)) {
                return CodecType.H263;
            }
        }
        for (String token : MPEG4_TYPES) {
            if (name.contains(token)) {
                return CodecType.MPEG4;
            }
        }
        for (String token : AAC_TYPES) {
            if (name.contains(token)) {
                return CodecType.AAC;
            }
        }

        return null;
    }
948694
@Override
	public boolean supports(@NonNull MediaType delimiter) {

		return this.mediaTypes.stream() //
				.anyMatch(mediaType -> mediaType.isCompatibleWith(delimiter));
	}
1202881
private static MediaType parse(String mediaType) {

		Assert.notNullOrEmptyTrimmed(mediaType, "Missing media type!");

		String type = null;
		String subType = null;
		Map<String, String> params = new HashMap<>();

		String[] parts = mediaType.split(";");
		for (int i = 0; i < parts.length; i++) {

			String part = StringUtils.trimToNull(parts[i]);
			if (part == null) {
				continue;
			}

			if (i == 0) {
				// get type and subtype
				String[] typeSubType = part.split("/");
				Assert.isTrue(typeSubType.length == 2, "Missing or invalid type with subType: '" + part + "'");

				type = StringUtils.trimToNull(typeSubType[0]);
				subType = StringUtils.trimToNull(typeSubType[1]);

				Assert.notNull(type, "Missing media type!");
				Assert.notNull(subType, "Missing media sub-type!");

			} else {

				try {
					Pair<String, String> pair = getNameValue(part);
					params.put(pair.getKey(), pair.getValue());
				}
				catch (IllegalArgumentException e) {
					log.warn("Invalid media type option: ", e);
				}
			}
		}

		return new MediaType(type, subType, params);
	}
372114
private boolean isRenditionMatchSizeSameSmaller(MediaFormat mediaFormat, MediaFormat mediaFormatRequested) {
    long widthRequested = mediaFormatRequested.getEffectiveMinWidth();
    long heightRequested = mediaFormatRequested.getEffectiveMinHeight();

    long widthMin = mediaFormat.getEffectiveMinWidth();
    long heightMin = mediaFormat.getEffectiveMinHeight();

    return widthMin <= widthRequested && heightMin <= heightRequested;
  }
1123503
public static MediaType getMediaTypeByExtension(String extension) {
        final String input = EXTENSIONS.get(extension);
        if (input == null) {
            return null;
        }
        return MediaType.parse(input);
    }
203918
public boolean validateNodeType()
   {

      boolean hasValidated = false;

      if (primaryItemName != null)
      {
         if (primaryItemName.length() <= 0)
         {
            primaryItemName = null;
            hasValidated = true;
         }
      }

      if (declaredSupertypeNames == null)
      {
         declaredSupertypeNames = new ArrayList<String>();
         hasValidated = true;
      }
      else
      {
         int prevSize = declaredSupertypeNames.size();
         fixStringsList(declaredSupertypeNames);
         hasValidated = prevSize != declaredSupertypeNames.size();
      }

      if (declaredPropertyDefinitionValues == null)
      {
         declaredPropertyDefinitionValues = new ArrayList<PropertyDefinitionValue>();
         hasValidated = true;
      }
      else
      {
         int prevSize = declaredPropertyDefinitionValues.size();
         fixPropertyDefinitionValuesList(declaredPropertyDefinitionValues);
         hasValidated = prevSize != declaredPropertyDefinitionValues.size();
      }

      if (declaredChildNodeDefinitionValues == null)
      {
         declaredChildNodeDefinitionValues = new ArrayList<NodeDefinitionValue>();
         hasValidated = true;
      }
      else
      {
         int prevSize = declaredChildNodeDefinitionValues.size();
         fixNodeDefinitionValuesList(declaredChildNodeDefinitionValues);
         hasValidated = prevSize != declaredChildNodeDefinitionValues.size();
      }

      return hasValidated;
   }
559927
private boolean hasInputWithValue() {

		// Visit all children of the fieldset of type Input
		AbstractVisitorWithResult<Boolean> visitor = new AbstractVisitorWithResult<Boolean>() {
			@Override
			public WComponentTreeVisitor.VisitorResult visit(final WComponent comp) {
				// Check if the component is an Input and has a value
				if (comp instanceof Input && !((Input) comp).isEmpty()) {
					setResult(true);
					return VisitorResult.ABORT;
				}
				return VisitorResult.CONTINUE;
			}
		};
		visitor.setResult(false);

		TreeUtil.traverseVisible(this, visitor);

		return visitor.getResult();
	}
62675
protected int score(MediaType contentTypeFromRequest, MediaType... expectedTypes) {
        if (contentTypeFromRequest == null) {
            return DEFAULT_SCORE;
        }
        for (MediaType expected : expectedTypes) {
            if (contentTypeFromRequest.matches(expected)) {
                return MAXIMUM_FORMAT_SCORE;
            }
        }
        return DEFAULT_SCORE;
    }
718563
public static MediaType valueOf(String type) throws IllegalArgumentException {
        if (type == null || type.trim().isEmpty() || type.startsWith(SUBTYPE_SEPARATOR) || type.endsWith(SUBTYPE_SEPARATOR)) {
            throw new IllegalArgumentException("Invalid mime type '" + type + "'");
        }
        String[] splitType = type.split(SUBTYPE_SEPARATOR);
        if (splitType.length == 2) {
            nonEmpty(type, splitType[0]);
            nonEmpty(type, splitType[1]);
            Map<String, String> parameters = new HashMap<>();
            String subType = splitType[1];
            if (splitType[1].contains(PARAMETERS_SEPARATOR)) {
                String[] subTypeWithparameter = splitType[1].split(PARAMETERS_SEPARATOR);
                String paramString = subTypeWithparameter[1].trim();
                subType = subTypeWithparameter[0];
                parameters = parseParameters(paramString);
            }
            return new MediaType(splitType[0].trim(), subType.trim(), parameters);
        }
        if (!type.contains(SUBTYPE_SEPARATOR)) {
            String mimeType = mimeMappings.getMimeType(type);
            if (mimeType != null) {
                return valueOf(mimeType);
            }
        }
        throw new IllegalArgumentException("Invalid mime type '" + type + "'");
    }
723982
public boolean equalsIgnoreParameters(HttpMediaType mediaType) {
    return mediaType != null
        && getType().equalsIgnoreCase(mediaType.getType())
        && getSubType().equalsIgnoreCase(mediaType.getSubType());
  }
761001
function MediaInput({ wrapperProps = {}, start, end, ...props }) {
  const { getInputProps } = useFieldContext();
  const inputRef = useRef(undefined);

  const { onClick, ...otherWrapperProps } = wrapperProps;

  const onFauxInputClickHandler = composeEventHandlers(onClick, () => {
    inputRef.current && inputRef.current.focus();
  });

  return (
    <FauxInput
      data-garden-id="forms.media_input"
      data-garden-version={PACKAGE_VERSION}
      onClick={onFauxInputClickHandler}
      mediaLayout
      {...otherWrapperProps}
    >
      {start && <StyledTextMediaFigure>{start}</StyledTextMediaFigure>}
      <StyledTextMediaInput
        {...getInputProps({
          innerRef: inputRef,
          ...props
        })}
      />
      {end && <StyledTextMediaFigure>{end}</StyledTextMediaFigure>}
    </FauxInput>
  );
}