KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > armedbear > j > OccurrenceLine


1 /*
2  * OccurrenceLine.java
3  *
4  * Copyright (C) 2000-2002 Peter Graves
5  * $Id: OccurrenceLine.java,v 1.1.1.1 2002/09/24 16:07:44 piso Exp $
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20  */

21
22 package org.armedbear.j;
23
24 public final class OccurrenceLine extends TextLine
25 {
26     private Line sourceLine;
27     private int sourceLineNumber; // 1-based.
28

29     public OccurrenceLine(Line sourceLine)
30     {
31         super();
32         FastStringBuffer sb = new FastStringBuffer();
33         sb.append(sourceLine.lineNumber()+1);
34         sb.append(':');
35         sb.append(sourceLine.getText());
36         init(sb.toString());
37         this.sourceLine = sourceLine;
38         // sourceLineNumber is 1-based.
39
sourceLineNumber = sourceLine.lineNumber() + 1;
40     }
41
42     // sourceLineNumber is 1-based.
43
public OccurrenceLine(String JavaDoc s, int sourceLineNumber)
44     {
45         super();
46         FastStringBuffer sb = new FastStringBuffer();
47         sb.append(sourceLineNumber);
48         sb.append(':');
49         sb.append(s);
50         init(sb.toString());
51         this.sourceLineNumber = sourceLineNumber;
52     }
53
54     public OccurrenceLine(Tag tag)
55     {
56         super();
57         String JavaDoc s = tag.getCanonicalSignature();
58         if (s == null)
59             s = tag.getLongName();
60         init(s);
61     }
62
63     public final Line getSourceLine()
64     {
65         return sourceLine;
66     }
67
68     // sourceLineNumber is 1-based.
69
public final int getSourceLineNumber()
70     {
71         return sourceLineNumber;
72     }
73 }
74
Popular Tags