- All Implemented Interfaces:
ValidMediaFilter,ValidMediaInput,ValidMediaOutput,NoClose,Closeable,Flushable,Appendable,AutoCloseable
MediaValidator while doing nothing on FilterWriter.close().- Author:
- AO Industries, Inc.
-
Field Summary
Fields inherited from class java.io.FilterWriter
out -
Method Summary
Modifier and TypeMethodDescriptionappend(char c) The default implementation of this append method in Writer calls the write(int) method for backward-compatibility.append(CharSequence csq) The default implementation of this append method in Writer converts to a String for backward-compatibility.append(CharSequence csq, int start, int end) The default implementation of this append method in Writer converts to a String for backward-compatibility.booleancanSkipValidation(MediaType outputType) Checks if validation may be skipped when the characters being written to this validator is already known to be valid with the given media type.voidclose()Does not close the wrapped validator.getOut()Gets the wrapped writer, which has been optimized: First, passed throughCoercion.optimize(java.io.Writer, com.aoapps.lang.io.Encoder)(withencoder = null).Gets the input type.booleanbooleanisValidatingMediaInputType(MediaType inputType) Checks if this is validating the provided type, which allows one validator to be substituted in place of another.voidvalidate(boolean trim) Performs final validation and resets the validator for reuse.static MediaValidatorwrap(MediaValidator out) Returnsoutwhen it is already aMediaValidator.isNoClose(), otherwise returns a newNoCloseMediaValidatorwrappingout.Dispatches towrap(com.aoapps.encoding.MediaValidator)when out is aMediaValidator, otherwise dispatches toNoCloseWriter.wrap(java.io.Writer).Methods inherited from class com.aoapps.encoding.MediaValidator
getMediaValidator, getValidMediaOutputType, isBufferedMethods inherited from class java.io.FilterWriter
flush, write, write, writeMethods inherited from class java.io.Writer
nullWriter, write, write
-
Method Details
-
wrap
Returnsoutwhen it is already aMediaValidator.isNoClose(), otherwise returns a newNoCloseMediaValidatorwrappingout. -
wrap
Dispatches towrap(com.aoapps.encoding.MediaValidator)when out is aMediaValidator, otherwise dispatches toNoCloseWriter.wrap(java.io.Writer).- See Also:
-
getValidMediaInputType
Description copied from interface:ValidMediaInputGets the input type. -
isValidatingMediaInputType
Description copied from interface:ValidMediaInputChecks if this is validating the provided type, which allows one validator to be substituted in place of another. This is acceptable when this validator is equal to, or more strict, than the giveninputType.Please note that this validator only needs to block invalid characters for
inputType. This validator does not need to let through all characters, just block the invalid. This is a one-way optimization.This is almost the inverse operation of
ValidMediaInput.isValidatingMediaInputType(com.aoapps.encoding.MediaType), with the exception of characters only invalid due to nested encodings.- Returns:
truewhen this validator will throw exceptions on all invalid characters from the giveninputType- See Also:
-
canSkipValidation
Description copied from interface:ValidMediaInputChecks if validation may be skipped when the characters being written to this validator is already known to be valid with the given media type. This may be done when every valid character for the given media type is also valid within this validator.This is almost the inverse operation of
ValidMediaInput.isValidatingMediaInputType(com.aoapps.encoding.MediaType), with the exception of characters only invalid due to nested encodings.- Returns:
truewhen all valid characters of the givenoutputTypeare also valid on this validator- See Also:
-
getOut
Gets the wrapped writer, which has been optimized: First, passed throughCoercion.optimize(java.io.Writer, com.aoapps.lang.io.Encoder)(withencoder = null). Second, passed throughwrap(java.io.Writer)whenoutisNoCloseandNoClose.isNoClose().- Overrides:
getOutin classMediaValidator- Returns:
- the wrapped writer passed through
wrap(java.io.Writer)orwrap(com.aoapps.encoding.MediaValidator).
-
append
Description copied from class:MediaValidatorThe default implementation of this append method in Writer converts to a String for backward-compatibility. This passes the append directly to the wrapped Writer.- Specified by:
appendin interfaceAppendable- Overrides:
appendin classMediaValidator- Throws:
IOException
-
append
Description copied from class:MediaValidatorThe default implementation of this append method in Writer converts to a String for backward-compatibility. This passes the append directly to the wrapped Writer.- Specified by:
appendin interfaceAppendable- Overrides:
appendin classMediaValidator- Throws:
IOException
-
append
Description copied from class:MediaValidatorThe default implementation of this append method in Writer calls the write(int) method for backward-compatibility. This passes the append directly to the wrapped Writer.- Specified by:
appendin interfaceAppendable- Overrides:
appendin classMediaValidator- Throws:
IOException
-
validate
Description copied from class:MediaValidatorPerforms final validation and resets the validator for reuse.- Overrides:
validatein classMediaValidator- Parameters:
trim- Requests that the buffer be trimmed, if buffered and trim supported.- Throws:
IOException
-
isNoClose
public boolean isNoClose()- Specified by:
isNoClosein interfaceNoClose- Overrides:
isNoClosein classMediaValidator- Returns:
truesince this is always no-close.
-
close
public void close()Does not close the wrapped validator.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceNoClose- Overrides:
closein classFilterWriter
-
