KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > org > apache > xerces > internal > impl > io > MalformedByteSequenceException


1 /*
2  * Copyright 2004 The Apache Software Foundation.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */

16  
17 package com.sun.org.apache.xerces.internal.impl.io;
18
19 import java.io.CharConversionException JavaDoc;
20 import java.util.Locale JavaDoc;
21 import com.sun.org.apache.xerces.internal.util.MessageFormatter;
22
23 /**
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>
27  *
28  * @author Michael Glavassevich, IBM
29  *
30  * @version $Id: MalformedByteSequenceException.java,v 1.1.1.1 2004/05/04 10:22:02 vk112360 Exp $
31  */

32 public class MalformedByteSequenceException extends CharConversionException JavaDoc {
33
34     //
35
// Data
36
//
37

38     /** message formatter **/
39     private MessageFormatter fFormatter;
40     
41     /** locale for error message **/
42     private Locale JavaDoc fLocale;
43     
44     /** error domain **/
45     private String JavaDoc fDomain;
46     
47     /** key for the error message **/
48     private String JavaDoc fKey;
49     
50     /** replacement arguements for the error message **/
51     private Object JavaDoc[] fArguments;
52     
53     /** message text for this message, initially null **/
54     private String JavaDoc fMessage;
55     
56     //
57
// Constructors
58
//
59

60     /**
61      * Constructs a MalformedByteSequenceException with the given
62      * parameters which may be passed to an error reporter to
63      * generate a localized string for this exception.
64      *
65      * @param formatter The MessageFormatter used for building the
66      * message text for this exception.
67      * @param locale The Locale for which messages are to be reported.
68      * @param domain The error domain.
69      * @param key The key of the error message.
70      * @param arguments The replacement arguments for the error message,
71      * if needed.
72      */

73     public MalformedByteSequenceException(MessageFormatter formatter,
74         Locale JavaDoc locale, String JavaDoc domain, String JavaDoc key, Object JavaDoc[] arguments) {
75         fFormatter = formatter;
76         fLocale = locale;
77         fDomain = domain;
78         fKey = key;
79         fArguments = arguments;
80     } // <init>(MessageFormatter, Locale, String, String, Object[])
81

82     //
83
// Public methods
84
//
85

86     /**
87      * <p>Returns the error domain of the error message.</p>
88      *
89      * @return the error domain
90      */

91     public String JavaDoc getDomain () {
92         return fDomain;
93     } // getDomain
94

95     /**
96      * <p>Returns the key of the error message.</p>
97      *
98      * @return the error key of the error message
99      */

100     public String JavaDoc getKey () {
101         return fKey;
102     } // getKey()
103

104     /**
105      * <p>Returns the replacement arguments for the error
106      * message or <code>null</code> if none exist.</p>
107      *
108      * @return the replacement arguments for the error message
109      * or <code>null</code> if none exist
110      */

111     public Object JavaDoc[] getArguments () {
112         return fArguments;
113     } // getArguments();
114

115     /**
116      * <p>Returns the localized message for this exception.</p>
117      *
118      * @return the localized message for this exception.
119      */

120     public String JavaDoc getMessage() {
121         if (fMessage == null) {
122             fMessage = fFormatter.formatMessage(fLocale, fKey, fArguments);
123             // The references to the message formatter and locale
124
// aren't needed anymore so null them.
125
fFormatter = null;
126             fLocale = null;
127         }
128         return fMessage;
129      } // getMessage()
130

131 } // MalformedByteSequenceException
132
Popular Tags