PageRenderTime 42ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/jEdit/tags/jedit-4-5-pre1/org/gjt/sp/jedit/buffer/DefaultFoldHandlerProvider.java

#
Java | 69 lines | 19 code | 4 blank | 46 comment | 0 complexity | 06f59da19ee54b4f72a5db21b1ea7a08 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. * DummyFoldHandler.java - Fold handler used when folding is switched off
  3. * :tabSize=8:indentSize=8:noTabs=false:
  4. * :folding=explicit:collapseFolds=1:
  5. *
  6. * Copyright (C) 2001 Slava Pestov
  7. * Portions copyright (C) 2007 Matthieu Casanova
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version 2
  12. * of the License, or any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  22. */
  23. package org.gjt.sp.jedit.buffer;
  24. import java.util.Map;
  25. import java.util.HashMap;
  26. /**
  27. * @author Matthieu Casanova
  28. * @version $Id: Buffer.java 8190 2006-12-07 07:58:34Z kpouer $
  29. */
  30. public class DefaultFoldHandlerProvider implements FoldHandlerProvider
  31. {
  32. private final Map<String, FoldHandler> folds = new HashMap<String, FoldHandler>();
  33. /**
  34. * Returns the fold handler with the specified name, or null if
  35. * there is no registered handler with that name.
  36. *
  37. * @param name The name of the desired fold handler
  38. * @return the FoldHandler or null if it doesn't exist
  39. * @since jEdit 4.3pre10
  40. */
  41. public FoldHandler getFoldHandler(String name)
  42. {
  43. return folds.get(name);
  44. }
  45. /**
  46. * Returns an array containing the names of all registered fold
  47. * handlers.
  48. *
  49. * @since jEdit 4.0pre6
  50. */
  51. public String[] getFoldModes()
  52. {
  53. return folds.keySet().toArray(new String[folds.size()]);
  54. }
  55. /**
  56. * Add a new FoldHander.
  57. *
  58. * @param foldHandler the new foldHandler
  59. * @since jEdit 4.3pre13
  60. */
  61. public void addFoldHandler(FoldHandler foldHandler)
  62. {
  63. folds.put(foldHandler.getName(), foldHandler);
  64. }
  65. }