java.nio.charset

Class CodingErrorAction


public class CodingErrorAction
extends Object

A typesafe enumeration for coding-error actions.

Instances of this class are used to specify how malformed-input and unmappable-character errors are to be handled by charset decoders and encoders.

Since:
1.4

Field Summary

static CodingErrorAction
IGNORE
Action indicating that a coding error is to be handled by dropping the erroneous input and resuming the coding operation.
static CodingErrorAction
REPLACE
Action indicating that a coding error is to be handled by dropping the erroneous input, appending the coder's replacement value to the output buffer, and resuming the coding operation.
static CodingErrorAction
REPORT
Action indicating that a coding error is to be reported, either by returning a CoderResult object or by throwing a CharacterCodingException, whichever is appropriate for the method implementing the coding process.

Method Summary

String
toString()
Returns a string describing this action.

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

IGNORE

public static final CodingErrorAction IGNORE
Action indicating that a coding error is to be handled by dropping the erroneous input and resuming the coding operation.

REPLACE

public static final CodingErrorAction REPLACE
Action indicating that a coding error is to be handled by dropping the erroneous input, appending the coder's replacement value to the output buffer, and resuming the coding operation.
Usages and Demos :

View More Examples of REPLACE
   1: import java.nio.charset.CoderResult;
   2: import java.nio.charset.CodingErrorAction;
   3: import java.nio.charset.IllegalCharsetNameException;
   4:         ...
   5:     private static String externalizeFileName(CharSequence name) {
   6:         return name.toString().replace('.', File.separatorChar);
   7:     }
   8:         ...
   9:             if (subdirectory.length() != 0) {
  10:                 subdirectory = subdirectory.replace('\\', '/');
  11:                 if (!subdirectory.endsWith("/")) subdirectory = subdirectory + "/";
  12:         ...
  13: 
  14:             CodingErrorAction action;

View Full Code Here

REPORT

public static final CodingErrorAction REPORT
Action indicating that a coding error is to be reported, either by returning a CoderResult object or by throwing a CharacterCodingException, whichever is appropriate for the method implementing the coding process.
Usages and Demos :

View More Examples of REPORT
   1: import java.nio.charset.CharacterCodingException;
   2: import java.nio.charset.CodingErrorAction;
   3: import java.nio.ByteBuffer;
   4:         ...
   5: 
   6:         csetdecoder.onMalformedInput( CodingErrorAction.REPORT );
   7:         ...
   8:         csetdecoder.onUnmappableCharacter( CodingErrorAction.REPORT );
   9: 
  10:         ...
  11: 
  12:             l1decoder.onMalformedInput( CodingErrorAction.REPORT );

View Full Code Here
   1: import java.nio.charset.CharsetDecoder;
   2: import java.nio.charset.CodingErrorAction;
   3: 
   4:         ...
   5: 
   6:         csetdecoder.onMalformedInput( CodingErrorAction.REPORT );
   7:         ...
   8:         csetdecoder.onUnmappableCharacter( CodingErrorAction.REPORT );
   9: 
  10:         ...
  11:             
  12:             l1decoder.onMalformedInput( CodingErrorAction.REPORT );

View Full Code Here
   1: import java.nio.charset.Charset;
   2: import java.nio.charset.CodingErrorAction;
   3: import java.text.Collator;
   4:         ...
   5:             return new String(ArrayUtils.getChars(charset.newDecoder()
   6:                     .onMalformedInput(CodingErrorAction.REPORT)
   7:         ...
   8:                     .onUnmappableCharacter(CodingErrorAction.REPORT).decode(
   9:                             ByteBuffer.wrap(bytes))));
  10:         ...
  11:             return ArrayUtils.getBytes(charset.newEncoder().onMalformedInput(
  12:                     CodingErrorAction.REPORT).onUnmappableCharacter(

View Full Code Here
   1: import java.nio.charset.CoderResult;
   2: import java.nio.charset.CodingErrorAction;
   3: import java.nio.charset.IllegalCharsetNameException;
   4:         ...
   5: 
   6:             CodingErrorAction action;
   7:             if (ignoreEncodingErrors)
   8:         ...
   9:                 action = CodingErrorAction.REPLACE;
  10:             else
  11:         ...
  12:                 action = CodingErrorAction.REPORT;

View Full Code Here

Method Details

toString

public String toString()
Returns a string describing this action.
Overrides:
toString in interface Object
Returns:
A descriptive string