01: /*
02: * IndentRuleFactory.java
03: * :tabSize=8:indentSize=8:noTabs=false:
04: * :folding=explicit:collapseFolds=1:
05: *
06: * Copyright (C) 2005 Slava Pestov
07: *
08: * This program is free software; you can redistribute it and/or
09: * 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:
23: package org.gjt.sp.jedit.indent;
24:
25: import java.util.regex.PatternSyntaxException;
26:
27: public class IndentRuleFactory {
28: public static IndentRule indentNextLines(String regexp)
29: throws PatternSyntaxException {
30: return new RegexpIndentRule(regexp, null,
31: new IndentAction.Increase(), null, false);
32: }
33:
34: public static IndentRule indentNextLine(String regexp)
35: throws PatternSyntaxException {
36: return new RegexpIndentRule(regexp,
37: new IndentAction.Decrease(),
38: new IndentAction.Increase(), null, true);
39: }
40:
41: public static IndentRule unindentThisLine(String regexp)
42: throws PatternSyntaxException {
43: return new RegexpIndentRule(regexp, null,
44: new IndentAction.Increase(),
45: new IndentAction.Decrease(), false);
46: }
47:
48: public static IndentRule unindentNextLines(String regexp)
49: throws PatternSyntaxException {
50: return new RegexpIndentRule(regexp, null,
51: new IndentAction.Decrease(), null, false);
52: }
53:
54: public static IndentRule indentOpenBracket(char bracket)
55: throws PatternSyntaxException {
56: return new OpenBracketIndentRule(bracket, true);
57: }
58:
59: public static IndentRule indentCloseBracket(char bracket)
60: throws PatternSyntaxException {
61: return new CloseBracketIndentRule(bracket, true);
62: }
63:
64: public static IndentRule unalignedOpenBracket(char bracket)
65: throws PatternSyntaxException {
66: return new OpenBracketIndentRule(bracket, false);
67: }
68:
69: public static IndentRule unalignedCloseBracket(char bracket)
70: throws PatternSyntaxException {
71: return new CloseBracketIndentRule(bracket, false);
72: }
73: }
|