KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jface > text > IDocumentPartitionerExtension2


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
12 package org.eclipse.jface.text;
13
14
15 /**
16  * Extension interface for {@link org.eclipse.jface.text.IDocumentPartitioner}.
17  * <p>
18  * Extends the original concept of a document partitioner to answer the position
19  * categories that are used to manage the partitioning information.
20  * <p>
21  * This extension also introduces the concept of open and delimited partitions.
22  * A delimited partition has a predefined textual token delimiting its start and
23  * end, while an open partition can fill any space between two delimited
24  * partitions.
25  * </p>
26  * <p>
27  * An open partition of length zero can occur between two delimited partitions,
28  * thus having the same offset as the following delimited partition. The
29  * document start and end are considered to be delimiters of open partitions,
30  * i.e. there may be a zero-length partition between the document start and a
31  * delimited partition starting at offset 0.
32  * </p>
33  *
34  * @since 3.0
35  */

36 public interface IDocumentPartitionerExtension2 {
37
38     /**
39      * Returns the position categories that this partitioners uses in order to manage
40      * the partitioning information of the documents. Returns <code>null</code> if
41      * no position category is used.
42      *
43      * @return the position categories used to manage partitioning information or <code>null</code>
44      */

45     String JavaDoc[] getManagingPositionCategories();
46
47
48     /* zero-length partition support */
49
50     /**
51      * Returns the content type of the partition containing the given offset in
52      * the connected document. There must be a document connected to this
53      * partitioner.
54      * <p>
55      * If <code>preferOpenPartitions</code> is <code>true</code>,
56      * precedence is given to an open partition ending at <code>offset</code>
57      * over a delimited partition starting at <code>offset</code>.
58      * <p>
59      * This method replaces {@link IDocumentPartitioner#getContentType(int)}and
60      * behaves like it when <code>prepreferOpenPartitions</code> is
61      * <code>false</code>, i.e. precedence is always given to the partition
62      * that does not end at <code>offset</code>.
63      * </p>
64      *
65      * @param offset the offset in the connected document
66      * @param preferOpenPartitions <code>true</code> if precedence should be
67      * given to a open partition ending at <code>offset</code> over
68      * a delimited partition starting at <code>offset</code>
69      * @return the content type of the offset's partition
70      */

71     String JavaDoc getContentType(int offset, boolean preferOpenPartitions);
72
73     /**
74      * Returns the partition containing the given offset of the connected
75      * document. There must be a document connected to this partitioner.
76      * <p>
77      * If <code>preferOpenPartitions</code> is <code>true</code>,
78      * precedence is given to an open partition ending at <code>offset</code>
79      * over a delimited partition starting at <code>offset</code>.
80      * <p>
81      * This method replaces {@link IDocumentPartitioner#getPartition(int)}and
82      * behaves like it when <preferOpenPartitions</code> is <code>false
83      * </code>, i.e. precedence is always given to the partition that does not
84      * end at <code>offset</code>.
85      * </p>
86      *
87      * @param offset the offset for which to determine the partition
88      * @param preferOpenPartitions <code>true</code> if precedence should be
89      * given to a open partition ending at <code>offset</code> over
90      * a delimited partition starting at <code>offset</code>
91      * @return the partition containing the offset
92      */

93     ITypedRegion getPartition(int offset, boolean preferOpenPartitions);
94
95     /**
96      * Returns the partitioning of the given range of the connected document.
97      * There must be a document connected to this partitioner.
98      * <p>
99      * If <code>includeZeroLengthPartitions</code> is <code>true</code>, a
100      * zero-length partition of an open partition type (usually the default
101      * partition) is included between two delimited partitions. If it is
102      * <code>false</code>, no zero-length partitions are included.
103      * </p>
104      * <p>
105      * This method replaces
106      * {@link IDocumentPartitioner#computePartitioning(int, int)}and behaves
107      * like it when <code>includeZeroLengthPartitions</code> is
108      * <code>false</code>.
109      * </p>
110      *
111      * @param offset the offset of the range of interest
112      * @param length the length of the range of interest
113      * @param includeZeroLengthPartitions <code>true</code> if zero-length
114      * partitions should be returned as part of the computed
115      * partitioning
116      * @return the partitioning of the range
117      */

118     ITypedRegion[] computePartitioning(int offset, int length, boolean includeZeroLengthPartitions);
119 }
120
Popular Tags