PageRenderTime 105ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

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

#
Java | 103 lines | 46 code | 10 blank | 47 comment | 2 complexity | 9a20ff682eec83d3498ce9042fa20ba8 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. * AllBufferSet.java - All buffer matcher
  3. * :tabSize=8:indentSize=8:noTabs=false:
  4. * :folding=explicit:collapseFolds=1:
  5. *
  6. * Copyright (C) 1999, 2000, 2001 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 gnu.regexp.*;
  25. import java.util.Vector;
  26. import org.gjt.sp.jedit.*;
  27. import org.gjt.sp.util.Log;
  28. //}}}
  29. /**
  30. * A file set for searching all open buffers.
  31. * @author Slava Pestov
  32. * @version $Id: AllBufferSet.java 3931 2001-12-02 11:40:51Z spestov $
  33. */
  34. public class AllBufferSet extends BufferListSet
  35. {
  36. //{{{ AllBufferSet constructor
  37. /**
  38. * Creates a new all buffer set.
  39. * @param glob The filename glob
  40. * @since jEdit 2.7pre3
  41. */
  42. public AllBufferSet(String glob)
  43. {
  44. this.glob = glob;
  45. } //}}}
  46. //{{{ getFileFilter() method
  47. /**
  48. * Returns the filename filter.
  49. * @since jEdit 2.7pre3
  50. */
  51. public String getFileFilter()
  52. {
  53. return glob;
  54. } //}}}
  55. //{{{ getCode() method
  56. /**
  57. * Returns the BeanShell code that will recreate this file set.
  58. * @since jEdit 2.7pre3
  59. */
  60. public String getCode()
  61. {
  62. return "new AllBufferSet(\"" + MiscUtilities.charsToEscapes(glob)
  63. + "\")";
  64. } //}}}
  65. //{{{ Instance variables
  66. private String glob;
  67. //}}}
  68. //{{{ _getFiles() method
  69. protected String[] _getFiles()
  70. {
  71. Buffer[] buffers = jEdit.getBuffers();
  72. Vector vector = new Vector(buffers.length);
  73. RE filter;
  74. try
  75. {
  76. filter = new RE(MiscUtilities.globToRE(glob));
  77. }
  78. catch(Exception e)
  79. {
  80. Log.log(Log.ERROR,DirectoryListSet.class,e);
  81. return null;
  82. }
  83. for(int i = 0; i < buffers.length; i++)
  84. {
  85. Buffer buffer = buffers[i];
  86. if(filter.isMatch(buffer.getName()))
  87. vector.addElement(buffer.getPath());
  88. }
  89. String[] retVal = new String[vector.size()];
  90. vector.copyInto(retVal);
  91. return retVal;
  92. } //}}}
  93. }