01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package java.nio.charset;
19:
20: import org.apache.harmony.niochar.internal.nls.Messages;
21:
22: /**
23: * Thrown when a malformed input is encountered, for example, a byte sequence is
24: * illegal for the given charset.
25: */
26: public class MalformedInputException extends CharacterCodingException {
27:
28: /*
29: * This constant is used during deserialization to check the J2SE version
30: * which created the serialized object.
31: */
32: private static final long serialVersionUID = -3438823399834806194L;
33:
34: // the length of the malformed input
35: private int inputLength;
36:
37: /**
38: * Constructs an instance of this exception.
39: *
40: * @param length
41: * the length of the malformed input
42: */
43: public MalformedInputException(int length) {
44: this .inputLength = length;
45: }
46:
47: /**
48: * Gets the length of the malformed input.
49: *
50: * @return the length of the malformed input
51: */
52: public int getInputLength() {
53: return this .inputLength;
54: }
55:
56: /**
57: * Gets a message describing this exception.
58: *
59: * @return a message describing this exception
60: */
61: public String getMessage() {
62: // niochar.05=Malformed input length is {0}.
63: return Messages.getString("niochar.05", this .inputLength); //$NON-NLS-1$
64: }
65: }
|