KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jface > text > source > ICharacterPairMatcher


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jface.text.source;
12
13 import org.eclipse.jface.text.IDocument;
14 import org.eclipse.jface.text.IRegion;
15
16 /**
17  * A character pair matcher finds to a character at a certain document offset
18  * the matching peer character. It is the matchers responsibility to define the
19  * concepts of "matching" and "peer". The matching process starts at a given
20  * offset. Starting of this offset, the matcher chooses a character close to
21  * this offset. The anchor defines whether the chosen character is left or right
22  * of the initial offset. The matcher then searches for the matching peer
23  * character of the chosen character and if it finds one, delivers the minimal
24  * region of the document that contains both characters.
25  *
26  * @since 2.1
27  */

28 public interface ICharacterPairMatcher {
29
30     /**
31      * Indicates the anchor value "right".
32      */

33     int RIGHT= 0;
34     /**
35      * Indicates the anchor value "left".
36      */

37     int LEFT= 1;
38
39
40     /**
41      * Disposes this pair matcher.
42      */

43     void dispose();
44
45     /**
46      * Clears this pair matcher. I.e. the matcher throws away all state it might
47      * remember and prepares itself for a new call of the <code>match</code>
48      * method.
49      */

50     void clear();
51
52     /**
53      * Starting at the given offset, the matcher chooses a character close to this offset.
54      * The matcher then searches for the matching peer character of the chosen character
55      * and if it finds one, returns the minimal region of the document that contains both characters.
56      * It returns <code>null</code> if there is no peer character.
57      *
58      * @param iDocument the document to work on
59      * @param i the start offset
60      * @return the minimal region containing the peer characters
61      */

62     IRegion match(IDocument iDocument, int i);
63
64     /**
65      * Returns the anchor for the region of the matching peer characters. The anchor
66      * says whether the character that has been chosen to search for its peer character
67      * has been left or right of the initial offset.
68      *
69      * @return <code>RIGHT</code> or <code>LEFT</code>
70      */

71     int getAnchor();
72 }
73
Popular Tags