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 ( ) ) ) ; } }
Gets the media validator for the given type . If the given writer is already validator for the requested type will return the provided writer .