2
* Copyright 2004 The Apache Software Foundation.
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
17
package org.apache.xerces.impl.io;
19
import java.io.CharConversionException;
20
import java.util.Locale;
21
import org.apache.xerces.util.MessageFormatter;
24
* <p>Signals that a malformed byte sequence was detected
25
* by a <code>java.io.Reader</code> that decodes bytes
26
* of a given encoding into characters.</p>
30
* @author Michael Glavassevich, IBM
32
* @version $Id: MalformedByteSequenceException.java 320091 2004-10-04 22:07:41Z mrglavas $
34
public class MalformedByteSequenceException extends CharConversionException {
36
/** Serialization version. */
37
static final long serialVersionUID = 8436382245048328739L;
43
/** message formatter **/
44
private MessageFormatter fFormatter;
46
/** locale for error message **/
47
private Locale fLocale;
50
private String fDomain;
52
/** key for the error message **/
55
/** replacement arguements for the error message **/
56
private Object[] fArguments;
58
/** message text for this message, initially null **/
59
private String fMessage;
66
* Constructs a MalformedByteSequenceException with the given
67
* parameters which may be passed to an error reporter to
68
* generate a localized string for this exception.
70
* @param formatter The MessageFormatter used for building the
71
* message text for this exception.
72
* @param locale The Locale for which messages are to be reported.
73
* @param domain The error domain.
74
* @param key The key of the error message.
75
* @param arguments The replacement arguments for the error message,
78
public MalformedByteSequenceException(MessageFormatter formatter,
79
Locale locale, String domain, String key, Object[] arguments) {
80
fFormatter = formatter;
84
fArguments = arguments;
85
} // <init>(MessageFormatter, Locale, String, String, Object[])
92
* <p>Returns the error domain of the error message.</p>
94
* @return the error domain
96
public String getDomain () {
101
* <p>Returns the key of the error message.</p>
103
* @return the error key of the error message
105
public String getKey () {
110
* <p>Returns the replacement arguments for the error
111
* message or <code>null</code> if none exist.</p>
113
* @return the replacement arguments for the error message
114
* or <code>null</code> if none exist
116
public Object[] getArguments () {
121
* <p>Returns the localized message for this exception.</p>
123
* @return the localized message for this exception.
125
public String getMessage() {
126
if (fMessage == null) {
127
fMessage = fFormatter.formatMessage(fLocale, fKey, fArguments);
128
// The references to the message formatter and locale
129
// aren't needed anymore so null them.
136
} // MalformedByteSequenceException