aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse/jgit/errors/NoClosingBracketException.java
blob: 54ad321a46c759b2d85c4b246fd0ff10fabb9aff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
 * Copyright (C) 2008, Florian Köberle <florianskarten@web.de>
 * Copyright (C) 2009, Vasyl' Vavrychuk <vvavrychuk@gmail.com>
 * Copyright (C) 2009, Yann Simon <yann.simon.fr@gmail.com> and others
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Distribution License v. 1.0 which is available at
 * https://www.eclipse.org/org/documents/edl-v10.php.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

package org.eclipse.jgit.errors;

import java.text.MessageFormat;

import org.eclipse.jgit.internal.JGitText;

/**
 * Thrown when a pattern contains a character group which is open to the right
 * side or a character class which is open to the right side.
 */
public class NoClosingBracketException extends InvalidPatternException {
	private static final long serialVersionUID = 1L;

	/**
	 * Constructor for NoClosingBracketException
	 *
	 * @param indexOfOpeningBracket
	 *            the position of the [ character which has no ] character.
	 * @param openingBracket
	 *            the unclosed bracket.
	 * @param closingBracket
	 *            the missing closing bracket.
	 * @param pattern
	 *            the invalid pattern.
	 */
	public NoClosingBracketException(final int indexOfOpeningBracket,
			final String openingBracket, final String closingBracket,
			final String pattern) {
		super(createMessage(indexOfOpeningBracket, openingBracket,
				closingBracket), pattern);
	}

	private static String createMessage(final int indexOfOpeningBracket,
			final String openingBracket, final String closingBracket) {
		return MessageFormat.format(JGitText.get().noClosingBracket,
				closingBracket, openingBracket,
				Integer.valueOf(indexOfOpeningBracket));
	}
}