1 /*
2  * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * This code is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License version 2 only, as
7  * published by the Free Software Foundation.  Oracle designates this
8  * particular file as subject to the "Classpath" exception as provided
9  * by Oracle in the LICENSE file that accompanied this code.
10  *
11  * This code is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14  * version 2 for more details (a copy is included in the LICENSE file that
15  * accompanied this code).
16  *
17  * You should have received a copy of the GNU General Public License version
18  * 2 along with this work; if not, write to the Free Software Foundation,
19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20  *
21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22  * or visit www.oracle.com if you need additional information or have any
23  * questions.
24  */
25 
26 package java.nio.charset;
27 
28 
29 /**
30  * A typesafe enumeration for coding-error actions.
31  *
32  * <p> Instances of this class are used to specify how malformed-input and
33  * unmappable-character errors are to be handled by charset <a
34  * href="CharsetDecoder.html#cae">decoders</a> and <a
35  * href="CharsetEncoder.html#cae">encoders</a>.  </p>
36  *
37  *
38  * @author Mark Reinhold
39  * @author JSR-51 Expert Group
40  * @since 1.4
41  */
42 
43 public class CodingErrorAction {
44 
45     private String name;
46 
CodingErrorAction(String name)47     private CodingErrorAction(String name) {
48         this.name = name;
49     }
50 
51     /**
52      * Action indicating that a coding error is to be handled by dropping the
53      * erroneous input and resuming the coding operation.
54      */
55     public static final CodingErrorAction IGNORE
56         = new CodingErrorAction("IGNORE");
57 
58     /**
59      * Action indicating that a coding error is to be handled by dropping the
60      * erroneous input, appending the coder's replacement value to the output
61      * buffer, and resuming the coding operation.
62      */
63     public static final CodingErrorAction REPLACE
64         = new CodingErrorAction("REPLACE");
65 
66     /**
67      * Action indicating that a coding error is to be reported, either by
68      * returning a {@link CoderResult} object or by throwing a {@link
69      * CharacterCodingException}, whichever is appropriate for the method
70      * implementing the coding process.
71      */
72     public static final CodingErrorAction REPORT
73         = new CodingErrorAction("REPORT");
74 
75     /**
76      * Returns a string describing this action.
77      *
78      * @return  A descriptive string
79      */
toString()80     public String toString() {
81         return name;
82     }
83 
84 }
85