/*
@Override
public boolean isValidatingMediaInputType(MediaType inputType) {
return inputType==MediaType.TEXT;
}
188427
@Override
	final public void doTag() throws JspException, IOException {
		try {
			// The output type cannot be determined until the body of the tag is invoked, because nested tags may
			// alter the resulting type.  We invoke the body first to accommodate nested tags.
			JspFragment body = getJspBody();
			if(body!=null) body.invoke(NullWriter.getInstance());

			MediaType myOutputType = getOutputType();
			if(myOutputType==null) {
				// No output, error if anything written.
				// prefix skipped
				doTag(FailOnWriteWriter.getInstance());
				// suffix skipped
			} else {
				final PageContext pageContext = (PageContext)getJspContext();
				final ServletRequest request = pageContext.getRequest();
				final HttpServletResponse response = (HttpServletResponse)pageContext.getResponse();
				final Writer 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);
				}

				// Determine the validator for the parent type.  This is to make sure prefix and suffix are valid.
				Writer containerValidator;
				if(parentEncodingContext != null) {
					// Make sure the output is compatibly validated.  It is a bug in the parent to not validate its input consistent with its content type
					if(!parentEncodingContext.validMediaInput.isValidatingMediaInputType(containerContentType)) {
						throw new LocalizedJspTagException(
							ApplicationResources.accessor,
							"AutoEncodingFilterTag.parentIncompatibleValidation",
							parentEncodingContext.validMediaInput.getClass().getName(),
							containerContentType.getContentType()
						);
					}
					// Already validated
					containerValidator = out;
				} else {
					// Need to add validator
					containerValidator = MediaValidator.getMediaValidator(containerContentType, out);
				}

				// Write any prefix
				writePrefix(containerContentType, containerValidator);

				// Find the encoder
				MediaEncoder mediaEncoder = MediaEncoder.getInstance(new HttpServletResponseEncodingContext(response), myOutputType, containerContentType);
				if(mediaEncoder!=null) {
					setMediaEncoderOptions(mediaEncoder);
					// Encode our output.  The encoder guarantees valid output for our parent.
					MediaWriter mediaWriter = new MediaWriter(mediaEncoder, out);
					mediaWriter.writePrefix();
					try {
						ThreadEncodingContext.setCurrentContext(
							request,
							new ThreadEncodingContext(myOutputType, 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(myOutputType)
					) {
						ThreadEncodingContext.setCurrentContext(
							request,
							new ThreadEncodingContext(myOutputType, 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(myOutputType, out);
						ThreadEncodingContext.setCurrentContext(
							request,
							new ThreadEncodingContext(myOutputType, validator)
						);
						try {
							doTag(validator);
						} finally {
							ThreadEncodingContext.setCurrentContext(request, parentEncodingContext);
						}
					}
				}

				// Write any suffix
				writeSuffix(containerContentType, containerValidator);
			}
		} catch(MediaException err) {
			throw new JspTagException(err);
		}
	}
21669
public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
		if (!hasMatchingMediaType(mediaType)) {
			return false;
		}

		return isValidType(type, annotations);
	}
767461
@Override
    public final void writeTypedElement(AsciiValueEncoder enc,
            XMLValidator validator, char[] copyBuffer)
        throws IOException, XMLStreamException
    {
        if (mSurrogate != 0) {
            throwUnpairedSurrogate();
        }

        /* Ok, this gets trickier: can't use efficient direct-to-bytes
         * encoding since validator won't be able to use it. Instead
         * have to use temporary copy buffer.
         */
        final int copyBufferLen = copyBuffer.length;

        // Copy buffer should never be too small, no need to check up front
        do {
            int ptr = enc.encodeMore(copyBuffer, 0, copyBufferLen);

            // False -> can't be sure it's the whole remaining text
            validator.validateText(copyBuffer, 0, ptr, false);
            writeRawAscii(copyBuffer, 0, ptr);
        } while (!enc.isCompleted());
    }
977927
@Override
	public boolean canRead(Class<?> clazz, @Nullable MediaType mediaType) {
		return type.isAssignableFrom(clazz) && super.canRead(clazz, mediaType);
	}
1295120
public static MediaValidator getMediaValidator(MediaType contentType, Writer out) throws MediaException {
		// If the existing out is already validating for this type, use it.
		// This occurs when one validation validates to a set of characters that are a subset of the requested validator.
		// For example, a URL is always valid TEXT.
		if(out instanceof MediaValidator) {
			MediaValidator inputValidator = (MediaValidator)out;
			if(inputValidator.isValidatingMediaInputType(contentType)) return inputValidator;
		}
		// Add filter if needed for the given type
		switch(contentType) {
			case JAVASCRIPT:
			case JSON:
			case LD_JSON:
				return new JavaScriptValidator(out, contentType);
			case SH:
				return new ShValidator(out);
			case MYSQL:
				return new MysqlValidator(out);
			case PSQL:
				return new PsqlValidator(out);
			case TEXT:
				return new TextValidator(out);
			case URL:
				return new UrlValidator(out);
			case XHTML:
				return new XhtmlValidator(out);
			case XHTML_ATTRIBUTE:
				return new XhtmlAttributeValidator(out);
			default:
				throw new MediaException(ApplicationResources.accessor.getMessage("MediaValidator.unableToFindValidator", contentType.getContentType()));
		}
	}
483526
@Override
    public boolean isValid(Object input) {
        boolean value;
        try {
            value = Boolean.parseBoolean(input.toString());
        } catch (NumberFormatException e) {
            return false;
        }


        return true;
    }
1163860
public boolean mediaIsAudio () {
        String contentType = this.getContentType();
        return contentType != null && this.media != null && contentType.startsWith("audio");
    }
648960
public static String validateInput(final String context,
			final String input, final String type, final int maxLength,
			final boolean allowNull, final boolean canonicalize)
			throws ValidationException {
		return validator.getValidInput(context, input, type, maxLength,
				allowNull, canonicalize);
	}
289293
function MediaType (type, subtype, suffix) {
  this.type = type
  this.subtype = subtype
  this.suffix = suffix
}
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;
   }
931822
public static Object convertTextToText(Object source, MediaType sourceType, MediaType destinationType) {
      if (source == null) return null;
      if (sourceType == null) throw new NullPointerException("MediaType cannot be null!");
      if (!sourceType.match(MediaType.TEXT_PLAIN)) throw log.invalidMediaType(TEXT_PLAIN_TYPE, sourceType.toString());

      boolean asString = destinationType.hasStringType();

      Charset sourceCharset = sourceType.getCharset();
      Charset destinationCharset = destinationType.getCharset();
      if (sourceCharset.equals(destinationCharset)) return convertTextClass(source, destinationType, asString);
      byte[] byteContent = source instanceof byte[] ? (byte[]) source : source.toString().getBytes(sourceCharset);
      return convertTextClass(convertCharset(byteContent, sourceCharset, destinationCharset), destinationType, asString);
   }
202299
@Override
    public boolean condition(Object input) {
        if (input instanceof String) {
            return !schema.getMetaData(columnIdx).isValid(new Text(input.toString()));
        } else if (input instanceof Double) {
            Double d = (Double) input;
            return !schema.getMetaData(columnIdx).isValid(new DoubleWritable(d));
        } else if (input instanceof Integer) {
            Integer i = (Integer) input;
            return !schema.getMetaData(columnIdx).isValid(new IntWritable(i));
        } else if (input instanceof Long) {
            Long l = (Long) input;
            return !schema.getMetaData(columnIdx).isValid(new LongWritable(l));
        } else if (input instanceof Boolean) {
            Boolean b = (Boolean) input;
            return !schema.getMetaData(columnIdx).isValid(new BooleanWritable(b));
        }

        else
            throw new IllegalStateException("Illegal type " + input.getClass().toString());
    }
1233695
private boolean isJawrImageTag(ComponentTag tag) {
		String tagName = tag.getName();
		return (tagName.equalsIgnoreCase("img") || (tagName
				.equalsIgnoreCase("input") && tag.getAttribute("type").equals(
				"image")));
	}
1067731
@JsonIgnore
    public boolean isValid() {
        return StringUtils.isNotBlank(getMetadata())
            && StringUtils.isNotBlank(getSigningCertificate())
            && StringUtils.isNotBlank(getSigningKey())
            && StringUtils.isNotBlank(getEncryptionCertificate())
            && StringUtils.isNotBlank(getEncryptionKey());
    }
1112862
public static boolean equalsIgnoreParameters(String mediaTypeA, String mediaTypeB) {
    // TODO(mlinder): Make the HttpMediaType.isSameType implementation more performant.
    return (mediaTypeA == null && mediaTypeB == null)
        || mediaTypeA != null
            && mediaTypeB != null
            && new HttpMediaType(mediaTypeA).equalsIgnoreParameters(new HttpMediaType(mediaTypeB));
  }
665691
@Deprecated
    public static Optional<SerializationFormat> fromMediaType(@Nullable String mediaType) {
        if (mediaType == null) {
            return Optional.empty();
        }

        try {
            return find(MediaType.parse(mediaType));
        } catch (IllegalArgumentException e) {
            // Malformed media type
            return Optional.empty();
        }
    }
580275
@Override
    public boolean parseAndValidateRequest() {
        boolean result = false;
        if(!super.parseAndValidateRequest() || !hasVectorClock(this.isVectorClockOptional)
           || !hasContentLength() || !hasContentType()) {
            result = false;
        } else {
            result = true;
        }

        return result;
    }