Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
blob: 7bf5dcaf69f7f63bed12ae7ee61ea31b245cd7de (plain) (blame)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*******************************************************************************
 * Copyright (c) 2001, 2004 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *     Jens Lukowski/Innoopract - initial renaming/restructuring
 *     
 *******************************************************************************/
package org.eclipse.wst.sse.core.internal.provisional;



/**
 * This type is used to indicate positions and lengths in source. Notice that
 * while getEndOffset and getLength are redundant, given that
 * 
 * <pre>
 * <code>
 *          getEndOffset() == getStartOffset() + getLength(); 
 * </code>
 * </pre>
 * 
 * we provide (require) both since in some cases implementors may be able to
 * provide one or the other more efficiently.
 * 
 * Note: it is not part of the API contract that implementors of IndexedRegion --
 * as a whole collection for a particular source -- must completely cover the
 * original source. They currently often do, so thought I'd mention explicitly
 * this may not always be true.
 * 
 * @plannedfor 1.0
 */
public interface IndexedRegion {

	/**
	 * Can be used to test if the indexed regions contains the test position.
	 * 
	 * @param testPosition
	 * @return true if test position is greater than or equal to start offset
	 *         and less than start offset plus length.
	 */
	boolean contains(int testPosition);

	/**
	 * Can be used to get end offset of source text, relative to beginning of
	 * documnt. Implementers should return -1 if, or some reason, the region
	 * is not valid.
	 * 
	 * @return endoffset
	 */
	int getEndOffset();

	/**
	 * Can be used to get source postion of beginning of indexed region.
	 * Implementers should return -1 if, or some reason, the region is not
	 * valid.
	 * 
	 * @return int position of start of index region.
	 */
	int getStartOffset();

	/**
	 * Can be used to get the length of the source text. Implementers should
	 * return -1 if, or some reason, the region is not valid.
	 * 
	 * @return int position of length of index region.
	 */
	int getLength();

}

Back to the top