PageRenderTime 75ms CodeModel.GetById 69ms app.highlight 3ms RepoModel.GetById 1ms 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
 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 */
23package org.gjt.sp.jedit.buffer;
24
25import java.util.Map;
26import java.util.HashMap;
27
28/**
29 * @author Matthieu Casanova
30 * @version $Id: Buffer.java 8190 2006-12-07 07:58:34Z kpouer $
31 */
32public class DefaultFoldHandlerProvider implements FoldHandlerProvider
33{
34	private final Map<String, FoldHandler> folds = new HashMap<String, FoldHandler>();
35	/**
36	 * Returns the fold handler with the specified name, or null if
37	 * there is no registered handler with that name.
38	 *
39	 * @param name The name of the desired fold handler
40	 * @return the FoldHandler or null if it doesn't exist
41	 * @since jEdit 4.3pre10
42	 */
43	public FoldHandler getFoldHandler(String name)
44	{
45		return folds.get(name);
46	}
47
48	/**
49	 * Returns an array containing the names of all registered fold
50	 * handlers.
51	 *
52	 * @since jEdit 4.0pre6
53	 */
54	public String[] getFoldModes()
55	{
56		return folds.keySet().toArray(new String[folds.size()]); 
57	}
58	
59	/**
60	 * Add a new FoldHander.
61	 *
62	 * @param foldHandler the new foldHandler
63	 * @since jEdit 4.3pre13
64	 */
65	public void addFoldHandler(FoldHandler foldHandler)
66	{
67		folds.put(foldHandler.getName(), foldHandler);
68	}
69}