PageRenderTime 219ms CodeModel.GetById 213ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/jEdit/tags/jedit-4-0-pre3/org/gjt/sp/jedit/search/HyperSearchResult.java

#
Java | 86 lines | 48 code | 10 blank | 28 comment | 3 complexity | 822324e9b7c2b6b9e1bd22015e781ba1 MD5 | raw file
 1/*
 2 * HyperSearchResult.java - HyperSearch result
 3 * :tabSize=8:indentSize=8:noTabs=false:
 4 * :folding=explicit:collapseFolds=1:
 5 *
 6 * Copyright (C) 1998, 1999, 2000 Slava Pestov
 7 *
 8 * This program is free software; you can redistribute it and/or
 9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21 */
22
23package org.gjt.sp.jedit.search;
24
25//{{{ Imports
26import javax.swing.text.*;
27import org.gjt.sp.jedit.jEdit;
28import org.gjt.sp.jedit.Buffer;
29import org.gjt.sp.util.Log;
30//}}}
31
32public class HyperSearchResult
33{
34	public String path;
35	public Buffer buffer;
36	public int line;
37	public int start;
38	public int end;
39	public Position startPos;
40	public Position endPos;
41	public String str; // cached for speed
42
43	//{{{ HyperSearchResult method
44	public HyperSearchResult(Buffer buffer, int line, int start, int end)
45	{
46		path = buffer.getPath();
47		this.line = line;
48		this.start = start;
49		this.end = end;
50
51		if(!buffer.isTemporary())
52			bufferOpened(buffer);
53
54		str = (line + 1) + ": " + buffer.getLineText(line)
55			.replace('\t',' ').trim();
56	} //}}}
57
58	//{{{ bufferOpened() method
59	public void bufferOpened(Buffer buffer)
60	{
61		this.buffer = buffer;
62		startPos = buffer.createPosition(start);
63		endPos = buffer.createPosition(end);
64	} //}}}
65
66	//{{{ bufferClosed() method
67	public void bufferClosed()
68	{
69		buffer = null;
70		startPos = endPos = null;
71	} //}}}
72
73	//{{{ getBuffer() method
74	public Buffer getBuffer()
75	{
76		if(buffer == null)
77			buffer = jEdit.openFile(null,path);
78		return buffer;
79	} //}}}
80
81	//{{{ toString() method
82	public String toString()
83	{
84		return str;
85	} //}}}
86}