| |
|
| java.lang.Object java.nio.charset.Charset$Coder$
Constructor Summary | |
| Charset$Coder$(Charset cs, float average$ItypesPerOtype$, float max$ItypesPerOtype$, $replType$ replacement) | protected | Charset$Coder$(Charset cs, float average$ItypesPerOtype$, float max$ItypesPerOtype$) Initializes a new $coder$. |
Method Summary | |
final public CoderResult | $code$($Itype$Buffer in, $Otype$Buffer out, boolean endOfInput) $Code$s as many $itype$s as possible from the given input buffer,
writing the results to the given output buffer.
The buffers are read from, and written to, starting at their current
positions. | final public $Otype$Buffer | $code$($Itype$Buffer in) Convenience method that $code$s the remaining content of a single input
$itype$ buffer into a newly-allocated $otype$ buffer.
This method implements an entire $coding$
operation; that is, it resets this $coder$, then it $code$s the
$itype$s in the given $itype$ buffer, and finally it flushes this
$coder$. | abstract protected CoderResult | $code$Loop($Itype$Buffer in, $Otype$Buffer out) $Code$s one or more $itype$s into one or more $otype$s.
This method encapsulates the basic $coding$ loop, $coding$ as many
$itype$s as possible until it either runs out of input, runs out of room
in the output buffer, or encounters $a$ $coding$ error. | final public float | average$ItypesPerOtype$() Returns the average number of $otype$s that will be produced for each
$itype$ of input. | public boolean | canEncode(char c) Tells whether or not this encoder can encode the given character.
This method returns false if the given character is a
surrogate character; such characters can be interpreted only when they
are members of a pair consisting of a high surrogate followed by a low
surrogate. | public boolean | canEncode(CharSequence cs) Tells whether or not this encoder can encode the given character
sequence.
If this method returns false for a particular character
sequence then more information about why the sequence cannot be encoded
may be obtained by performing a full encoding
operation.
This method may modify this encoder's state; it should therefore not
be invoked if an encoding operation is already in progress.
The default implementation of this method is not very efficient; it
should generally be overridden to improve performance. | final public Charset | charset() Returns the charset that created this $coder$. | public Charset | detectedCharset() Retrieves the charset that was detected by this
decoder (optional operation).
If this decoder implements an auto-detecting charset then this
method returns the actual charset once it has been detected. | final public CoderResult | flush($Otype$Buffer out) Flushes this $coder$.
Some $coder$s maintain internal state and may need to write some
final $otype$s to the output buffer once the overall input sequence has
been read.
Any additional output is written to the output buffer beginning at
its current position. | protected CoderResult | implFlush($Otype$Buffer out) Flushes this $coder$.
The default implementation of this method does nothing, and always
returns
CoderResult.UNDERFLOW . | protected void | implOnMalformedInput(CodingErrorAction newAction) Reports a change to this $coder$'s malformed-input action.
The default implementation of this method does nothing. | protected void | implOnUnmappableCharacter(CodingErrorAction newAction) Reports a change to this $coder$'s unmappable-character action.
The default implementation of this method does nothing. | protected void | implReplaceWith($replType$ newReplacement) Reports a change to this $coder$'s replacement value.
The default implementation of this method does nothing. | protected void | implReset() Resets this $coder$, clearing any charset-specific internal state.
The default implementation of this method does nothing. | public boolean | isAutoDetecting() Tells whether or not this decoder implements an auto-detecting charset.
The default implementation of this method always returns
false; it should be overridden by auto-detecting decoders to
return true. | public boolean | isCharsetDetected() Tells whether or not this decoder has yet detected a
charset (optional operation).
If this decoder implements an auto-detecting charset then at a
single point during a decoding operation this method may start returning
true to indicate that a specific charset has been detected in
the input byte sequence. | public boolean | isLegalReplacement(byte[] repl) Tells whether or not the given byte array is a legal replacement value
for this encoder.
A replacement is legal if, and only if, it is a legal sequence of
bytes in this encoder's charset; that is, it must be possible to decode
the replacement into one or more sixteen-bit Unicode characters.
The default implementation of this method is not very efficient; it
should generally be overridden to improve performance. | public CodingErrorAction | malformedInputAction() Returns this $coder$'s current action for malformed-input errors. | final public float | max$ItypesPerOtype$() Returns the maximum number of $otype$s that will be produced for each
$itype$ of input. | final public Charset$Coder$ | onMalformedInput(CodingErrorAction newAction) Changes this $coder$'s action for malformed-input errors. | final public Charset$Coder$ | onUnmappableCharacter(CodingErrorAction newAction) Changes this $coder$'s action for unmappable-character errors.
This method invokes the
Charset$Coder$.implOnUnmappableCharacterimplOnUnmappableCharacter method, passing the new action. | final public Charset$Coder$ | replaceWith($replType$ newReplacement) Changes this $coder$'s replacement value.
This method invokes the
Charset$Coder$.implReplaceWith implReplaceWith method, passing the new replacement, after checking that the new
replacement is acceptable. | final public $replType$ | replacement() Returns this $coder$'s replacement value. | final public Charset$Coder$ | reset() Resets this $coder$, clearing any internal state.
This method resets charset-independent state and also invokes the
Charset$Coder$.implReset() implReset method in order to perform any
charset-specific reset actions. | public CodingErrorAction | unmappableCharacterAction() Returns this $coder$'s current action for unmappable-character errors. |
Charset$Coder$ | Charset$Coder$(Charset cs, float average$ItypesPerOtype$, float max$ItypesPerOtype$, $replType$ replacement)(Code) | | |
Charset$Coder$ | protected Charset$Coder$(Charset cs, float average$ItypesPerOtype$, float max$ItypesPerOtype$)(Code) | | Initializes a new $coder$. The new $coder$ will have the given
$otypes-per-itype$ values and its replacement will be the
$replTypeName$ $defaultReplName$.
Parameters: average$ItypesPerOtype$ - A positive float value indicating the expected number of$otype$s that will be produced for each input $itype$ Parameters: max$ItypesPerOtype$ - A positive float value indicating the maximum number of$otype$s that will be produced for each input $itype$ throws: IllegalArgumentException - If the preconditions on the parameters do not hold |
$code$ | final public CoderResult $code$($Itype$Buffer in, $Otype$Buffer out, boolean endOfInput)(Code) | | $Code$s as many $itype$s as possible from the given input buffer,
writing the results to the given output buffer.
The buffers are read from, and written to, starting at their current
positions. At most
Buffer.remaining in.remaining() $itype$s
will be read and at most
Buffer.remaining out.remaining() $otype$s will be written. The buffers' positions will be advanced to
reflect the $itype$s read and the $otype$s written, but their marks and
limits will not be modified.
In addition to reading $itype$s from the input buffer and writing
$otype$s to the output buffer, this method returns a
CoderResult object to describe its reason for termination:
CoderResult.UNDERFLOW indicates that as much of the
input buffer as possible has been $code$d. If there is no further
input then the invoker can proceed to the next step of the
$coding$ operation. Otherwise this method
should be invoked again with further input.
CoderResult.OVERFLOW indicates that there is
insufficient space in the output buffer to $code$ any more $itype$s.
This method should be invoked again with an output buffer that has
more
$otype$s. This is
typically done by draining any $code$d $otype$s from the output
buffer.
A
CoderResult.malformedForLengthmalformed-input result indicates that a malformed-input
error has been detected. The malformed $itype$s begin at the input
buffer's (possibly incremented) position; the number of malformed
$itype$s may be determined by invoking the result object's
CoderResult.length length method. This case applies only if the
Charset$Coder$.onMalformedInput malformed action of this $coder$
is
CodingErrorAction.REPORT ; otherwise the malformed input
will be ignored or replaced, as requested.
An
CoderResult.unmappableForLengthunmappable-character result indicates that an
unmappable-character error has been detected. The $itype$s that
$code$ the unmappable character begin at the input buffer's (possibly
incremented) position; the number of such $itype$s may be determined
by invoking the result object's
CoderResult.length length method. This case applies only if the
Charset$Coder$.onUnmappableCharacter unmappable action of this $coder$ is
CodingErrorAction.REPORT ; otherwise the unmappable character will be
ignored or replaced, as requested.
In any case, if this method is to be reinvoked in the same $coding$
operation then care should be taken to preserve any $itype$s remaining
in the input buffer so that they are available to the next invocation.
The endOfInput parameter advises this method as to whether
the invoker can provide further input beyond that contained in the given
input buffer. If there is a possibility of providing additional input
then the invoker should pass false for this parameter; if there
is no possibility of providing further input then the invoker should
pass true. It is not erroneous, and in fact it is quite
common, to pass false in one invocation and later discover that
no further input was actually available. It is critical, however, that
the final invocation of this method in a sequence of invocations always
pass true so that any remaining un$code$d input will be treated
as being malformed.
This method works by invoking the
Charset$Coder$.$code$Loop $code$Loop method, interpreting its results, handling error conditions, and
reinvoking it as necessary.
Parameters: in - The input $itype$ buffer Parameters: out - The output $otype$ buffer Parameters: endOfInput - true if, and only if, the invoker can provide noadditional input $itype$s beyond those in the given buffer A coder-result object describing the reason for termination throws: IllegalStateException - If $a$ $coding$ operation is already in progress and the previousstep was an invocation neither of the Charset$Coder$.reset resetmethod, nor of this method with a value of false forthe endOfInput parameter, nor of this method with avalue of true for the endOfInput parameterbut a return value indicating an incomplete $coding$ operation throws: CoderMalfunctionError - If an invocation of the $code$Loop method threwan unexpected exception |
$code$ | final public $Otype$Buffer $code$($Itype$Buffer in) throws CharacterCodingException(Code) | | Convenience method that $code$s the remaining content of a single input
$itype$ buffer into a newly-allocated $otype$ buffer.
This method implements an entire $coding$
operation; that is, it resets this $coder$, then it $code$s the
$itype$s in the given $itype$ buffer, and finally it flushes this
$coder$. This method should therefore not be invoked if $a$ $coding$
operation is already in progress.
Parameters: in - The input $itype$ buffer A newly-allocated $otype$ buffer containing the result of the$coding$ operation. The buffer's position will be zero and itslimit will follow the last $otype$ written. throws: IllegalStateException - If $a$ $coding$ operation is already in progress throws: MalformedInputException - If the $itype$ sequence starting at the input buffer's currentposition is $notLegal$ and the current malformed-input actionis CodingErrorAction.REPORT throws: UnmappableCharacterException - If the $itype$ sequence starting at the input buffer's currentposition cannot be mapped to an equivalent $otype$ sequence andthe current unmappable-character action is CodingErrorAction.REPORT |
$code$Loop | abstract protected CoderResult $code$Loop($Itype$Buffer in, $Otype$Buffer out)(Code) | | $Code$s one or more $itype$s into one or more $otype$s.
This method encapsulates the basic $coding$ loop, $coding$ as many
$itype$s as possible until it either runs out of input, runs out of room
in the output buffer, or encounters $a$ $coding$ error. This method is
invoked by the
Charset$Coder$.$code$ $code$ method, which handles result
interpretation and error recovery.
The buffers are read from, and written to, starting at their current
positions. At most
Buffer.remaining in.remaining() $itype$s
will be read, and at most
Buffer.remaining out.remaining() $otype$s will be written. The buffers' positions will be advanced to
reflect the $itype$s read and the $otype$s written, but their marks and
limits will not be modified.
This method returns a
CoderResult object to describe its
reason for termination, in the same manner as the
Charset$Coder$.$code$ $code$ method. Most implementations of this method will handle $coding$ errors
by returning an appropriate result object for interpretation by the
Charset$Coder$.$code$ $code$ method. An optimized implementation may instead
examine the relevant error action and implement that action itself.
An implementation of this method may perform arbitrary lookahead by
returning
CoderResult.UNDERFLOW until it receives sufficient
input.
Parameters: in - The input $itype$ buffer Parameters: out - The output $otype$ buffer A coder-result object describing the reason for termination |
average$ItypesPerOtype$ | final public float average$ItypesPerOtype$()(Code) | | Returns the average number of $otype$s that will be produced for each
$itype$ of input. This heuristic value may be used to estimate the size
of the output buffer required for a given input sequence.
The average number of $otype$s producedper $itype$ of input |
canEncode | public boolean canEncode(char c)(Code) | | Tells whether or not this encoder can encode the given character.
This method returns false if the given character is a
surrogate character; such characters can be interpreted only when they
are members of a pair consisting of a high surrogate followed by a low
surrogate. The
Charset$Coder$.canEncode(java.lang.CharSequence)canEncode(CharSequence) method may be used to test whether or not a
character sequence can be encoded.
This method may modify this encoder's state; it should therefore not
be invoked if an encoding operation is already in
progress.
The default implementation of this method is not very efficient; it
should generally be overridden to improve performance.
true if, and only if, this encoder can encodethe given character throws: IllegalStateException - If $a$ $coding$ operation is already in progress |
canEncode | public boolean canEncode(CharSequence cs)(Code) | | Tells whether or not this encoder can encode the given character
sequence.
If this method returns false for a particular character
sequence then more information about why the sequence cannot be encoded
may be obtained by performing a full encoding
operation.
This method may modify this encoder's state; it should therefore not
be invoked if an encoding operation is already in progress.
The default implementation of this method is not very efficient; it
should generally be overridden to improve performance.
true if, and only if, this encoder can encodethe given character without throwing any exceptions and withoutperforming any replacements throws: IllegalStateException - If $a$ $coding$ operation is already in progress |
charset | final public Charset charset()(Code) | | Returns the charset that created this $coder$.
This $coder$'s charset |
detectedCharset | public Charset detectedCharset()(Code) | | Retrieves the charset that was detected by this
decoder (optional operation).
If this decoder implements an auto-detecting charset then this
method returns the actual charset once it has been detected. After that
point, this method returns the same value for the duration of the
current decoding operation. If not enough input bytes have yet been
read to determine the actual charset then this method throws an
IllegalStateException .
The default implementation of this method always throws an
UnsupportedOperationException ; it should be overridden by
auto-detecting decoders to return the appropriate value.
The charset detected by this auto-detecting decoder,or null if the charset has not yet been determined throws: IllegalStateException - If insufficient bytes have been read to determine a charset throws: UnsupportedOperationException - If this decoder does not implement an auto-detecting charset |
flush | final public CoderResult flush($Otype$Buffer out)(Code) | | Flushes this $coder$.
Some $coder$s maintain internal state and may need to write some
final $otype$s to the output buffer once the overall input sequence has
been read.
Any additional output is written to the output buffer beginning at
its current position. At most
Buffer.remaining out.remaining() $otype$s will be written. The buffer's position will be advanced
appropriately, but its mark and limit will not be modified.
If this method completes successfully then it returns
CoderResult.UNDERFLOW . If there is insufficient room in the output
buffer then it returns
CoderResult.OVERFLOW . If this happens
then this method must be invoked again, with an output buffer that has
more room, in order to complete the current $coding$
operation.
If this $coder$ has already been flushed then invoking this method
has no effect.
This method invokes the
Charset$Coder$.implFlush implFlush method to
perform the actual flushing operation.
Parameters: out - The output $otype$ buffer A coder-result object, either CoderResult.UNDERFLOW orCoderResult.OVERFLOW throws: IllegalStateException - If the previous step of the current $coding$ operation was aninvocation neither of the Charset$Coder$.flush flush method nor ofthe three-argument Charset$Coder$.$code$($Itype$Buffer,$Otype$Buffer,boolean) $code$ methodwith a value of true for the endOfInputparameter |
implFlush | protected CoderResult implFlush($Otype$Buffer out)(Code) | | Flushes this $coder$.
The default implementation of this method does nothing, and always
returns
CoderResult.UNDERFLOW . This method should be overridden
by $coder$s that may need to write final $otype$s to the output buffer
once the entire input sequence has been read.
Parameters: out - The output $otype$ buffer A coder-result object, either CoderResult.UNDERFLOW orCoderResult.OVERFLOW |
implOnMalformedInput | protected void implOnMalformedInput(CodingErrorAction newAction)(Code) | | Reports a change to this $coder$'s malformed-input action.
The default implementation of this method does nothing. This method
should be overridden by $coder$s that require notification of changes to
the malformed-input action.
|
implOnUnmappableCharacter | protected void implOnUnmappableCharacter(CodingErrorAction newAction)(Code) | | Reports a change to this $coder$'s unmappable-character action.
The default implementation of this method does nothing. This method
should be overridden by $coder$s that require notification of changes to
the unmappable-character action.
|
implReplaceWith | protected void implReplaceWith($replType$ newReplacement)(Code) | | Reports a change to this $coder$'s replacement value.
The default implementation of this method does nothing. This method
should be overridden by $coder$s that require notification of changes to
the replacement.
Parameters: newReplacement - |
implReset | protected void implReset()(Code) | | Resets this $coder$, clearing any charset-specific internal state.
The default implementation of this method does nothing. This method
should be overridden by $coder$s that maintain internal state.
|
isAutoDetecting | public boolean isAutoDetecting()(Code) | | Tells whether or not this decoder implements an auto-detecting charset.
The default implementation of this method always returns
false; it should be overridden by auto-detecting decoders to
return true.
true if, and only if, this decoder implements anauto-detecting charset |
isCharsetDetected | public boolean isCharsetDetected()(Code) | | Tells whether or not this decoder has yet detected a
charset (optional operation).
If this decoder implements an auto-detecting charset then at a
single point during a decoding operation this method may start returning
true to indicate that a specific charset has been detected in
the input byte sequence. Once this occurs, the
Charset$Coder$.detectedCharsetdetectedCharset method may be invoked to retrieve the detected charset.
That this method returns false does not imply that no bytes
have yet been decoded. Some auto-detecting decoders are capable of
decoding some, or even all, of an input byte sequence without fixing on
a particular charset.
The default implementation of this method always throws an
UnsupportedOperationException ; it should be overridden by
auto-detecting decoders to return true once the input charset
has been determined.
true if, and only if, this decoder has detected aspecific charset throws: UnsupportedOperationException - If this decoder does not implement an auto-detecting charset |
isLegalReplacement | public boolean isLegalReplacement(byte[] repl)(Code) | | Tells whether or not the given byte array is a legal replacement value
for this encoder.
A replacement is legal if, and only if, it is a legal sequence of
bytes in this encoder's charset; that is, it must be possible to decode
the replacement into one or more sixteen-bit Unicode characters.
The default implementation of this method is not very efficient; it
should generally be overridden to improve performance.
Parameters: repl - The byte array to be tested true if, and only if, the given byte arrayis a legal replacement value for this encoder |
malformedInputAction | public CodingErrorAction malformedInputAction()(Code) | | Returns this $coder$'s current action for malformed-input errors.
The current malformed-input action, which is never null |
max$ItypesPerOtype$ | final public float max$ItypesPerOtype$()(Code) | | Returns the maximum number of $otype$s that will be produced for each
$itype$ of input. This value may be used to compute the worst-case size
of the output buffer required for a given input sequence.
The maximum number of $otype$s that will be produced per$itype$ of input |
onMalformedInput | final public Charset$Coder$ onMalformedInput(CodingErrorAction newAction)(Code) | | Changes this $coder$'s action for malformed-input errors.
This method invokes the
Charset$Coder$.implOnMalformedInputimplOnMalformedInput method, passing the new action.
Parameters: newAction - The new action; must not be null This $coder$ throws: IllegalArgumentException - If the precondition on the parameter does not hold |
onUnmappableCharacter | final public Charset$Coder$ onUnmappableCharacter(CodingErrorAction newAction)(Code) | | Changes this $coder$'s action for unmappable-character errors.
This method invokes the
Charset$Coder$.implOnUnmappableCharacterimplOnUnmappableCharacter method, passing the new action.
Parameters: newAction - The new action; must not be null This $coder$ throws: IllegalArgumentException - If the precondition on the parameter does not hold |
replaceWith | final public Charset$Coder$ replaceWith($replType$ newReplacement)(Code) | | Changes this $coder$'s replacement value.
This method invokes the
Charset$Coder$.implReplaceWith implReplaceWith method, passing the new replacement, after checking that the new
replacement is acceptable.
Parameters: newReplacement - #if[decoder]The new replacement; must not be nulland must have non-zero length#end[decoder]#if[encoder]The new replacement; must not be null, must havenon-zero length, must not be longer than the value returned bythe Charset$Coder$.max$ItypesPerOtype$() max$ItypesPerOtype$ method, andmust be Charset$Coder$.isLegalReplacement legal#end[encoder] This $coder$ throws: IllegalArgumentException - If the preconditions on the parameter do not hold |
replacement | final public $replType$ replacement()(Code) | | Returns this $coder$'s replacement value.
This $coder$'s current replacement,which is never null and is never empty |
reset | final public Charset$Coder$ reset()(Code) | | Resets this $coder$, clearing any internal state.
This method resets charset-independent state and also invokes the
Charset$Coder$.implReset() implReset method in order to perform any
charset-specific reset actions.
This $coder$ |
unmappableCharacterAction | public CodingErrorAction unmappableCharacterAction()(Code) | | Returns this $coder$'s current action for unmappable-character errors.
The current unmappable-character action, which is nevernull |
|
|
|