PageRenderTime 25ms CodeModel.GetById 0ms RepoModel.GetById 0ms 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
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
  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. package org.gjt.sp.jedit.search;
  23. //{{{ Imports
  24. import javax.swing.text.*;
  25. import org.gjt.sp.jedit.jEdit;
  26. import org.gjt.sp.jedit.Buffer;
  27. import org.gjt.sp.util.Log;
  28. //}}}
  29. public class HyperSearchResult
  30. {
  31. public String path;
  32. public Buffer buffer;
  33. public int line;
  34. public int start;
  35. public int end;
  36. public Position startPos;
  37. public Position endPos;
  38. public String str; // cached for speed
  39. //{{{ HyperSearchResult method
  40. public HyperSearchResult(Buffer buffer, int line, int start, int end)
  41. {
  42. path = buffer.getPath();
  43. this.line = line;
  44. this.start = start;
  45. this.end = end;
  46. if(!buffer.isTemporary())
  47. bufferOpened(buffer);
  48. str = (line + 1) + ": " + buffer.getLineText(line)
  49. .replace('\t',' ').trim();
  50. } //}}}
  51. //{{{ bufferOpened() method
  52. public void bufferOpened(Buffer buffer)
  53. {
  54. this.buffer = buffer;
  55. startPos = buffer.createPosition(start);
  56. endPos = buffer.createPosition(end);
  57. } //}}}
  58. //{{{ bufferClosed() method
  59. public void bufferClosed()
  60. {
  61. buffer = null;
  62. startPos = endPos = null;
  63. } //}}}
  64. //{{{ getBuffer() method
  65. public Buffer getBuffer()
  66. {
  67. if(buffer == null)
  68. buffer = jEdit.openFile(null,path);
  69. return buffer;
  70. } //}}}
  71. //{{{ toString() method
  72. public String toString()
  73. {
  74. return str;
  75. } //}}}
  76. }