OSDN Git Service

libjava/ChangeLog:
[pf3gnuchains/gcc-fork.git] / libjava / classpath / tools / gnu / classpath / tools / MalformedInputEvent.java
1 /* gnu.classpath.tools.MalformedInputEvent
2    Copyright (C) 2004 Free Software Foundation, Inc.
3
4 This file is part of GNU Classpath.
5
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10  
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING.  If not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA. */
20
21 package gnu.classpath.tools;
22
23 import java.util.EventObject;
24
25 /**
26  *  Encapsulates information about malformed input encountered by a
27  *  {@link NotifyingInputStreamReader}.
28  *
29  *  You can use {@link getSource()} to fetch a reference to the
30  *  <code>NotifyingInputStreamReader</code> which encountered the
31  *  malformed input.
32  *
33  *  @author Julian Scheid
34  */
35 public class MalformedInputEvent
36    extends EventObject
37 {
38    private int lineNumber;
39    private int columnNumber;
40    private int length;
41
42    MalformedInputEvent(NotifyingInputStreamReader source,
43                        int lineNumber,
44                        int columnNumber,
45                        int length)
46    {
47       super(source);
48       this.columnNumber = columnNumber;
49       this.lineNumber = lineNumber;
50       this.length = length;
51    }
52
53    /**
54     *  Return the 1-based line number where the malformed input begins
55     *  in the stream read by the
56     *  <code>NotifyingInputStreamReader</code>.
57     */
58    public int getLineNumber()
59    {
60       return lineNumber;
61    }
62
63    /**
64     *  Return the 0-based column number where the malformed input
65     *  begins in the stream read by the
66     *  <code>NotifyingInputStreamReader</code>.
67     */
68    public int getColumnNumber()
69    {
70       return columnNumber;
71    }
72
73    /**
74     *  Return the length (in bytes) of the malformed input encountered
75     *  by the <code>NotifyingInputStreamReader</code>. Note that a
76     *  consecutive run of malformed input isn't necessarily reported
77     *  as a whole; depending on the <code>Charset</code> and
78     *  implementation details of <code>CharsetDecoder</code>, the run
79     *  could be reported in chunks down to individual bytes.
80     */
81    public int getLength()
82    {
83       return length;
84    }
85
86    public String toString()
87    {
88       return "MalformedInputEvent{line=" + lineNumber
89          + ",column=" + columnNumber
90          + ",length=" + length
91          + "}";
92    }
93 }