1
/*******************************************************************************
2
* Copyright (c) 2002, 2009 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
9
* Rational Software - Initial API and implementation
10
*******************************************************************************/
11
package org.eclipse.cdt.core.model;
13
import java.util.EventObject;
17
* A buffer changed event describes how a buffer has changed. These events are
18
* used in <code>IBufferChangedListener</code> notifications.
20
* For text insertions, <code>getOffset</code> is the offset
21
* of the first inserted character, <code>getText</code> is the
22
* inserted text, and <code>getLength</code> is 0.
25
* For text removals, <code>getOffset</code> is the offset
26
* of the first removed character, <code>getText</code> is <code>null</code>,
27
* and <code>getLength</code> is the length of the text that was removed.
30
* For replacements (including <code>IBuffer.setContents</code>),
31
* <code>getOffset</code> is the offset
32
* of the first replaced character, <code>getText</code> is the replacement
33
* text, and <code>getLength</code> is the length of the original text
37
* When a buffer is closed, <code>getOffset</code> is 0, <code>getLength</code>
38
* is 0, and <code>getText</code> is <code>null</code>.
41
* @noextend This class is not intended to be subclassed by clients.
43
* Instances of this class are automatically created by the C model.
47
* This class is similar to the JDT BufferChangedEvent class.
50
public class BufferChangedEvent extends EventObject {
52
* Comment for <code>serialVersionUID</code>
54
private static final long serialVersionUID = 3979268036526355761L;
57
* The length of text that has been modified in the buffer.
62
* The offset into the buffer where the modification took place.
67
* The text that was modified.
72
* Creates a new buffer changed event indicating that the given buffer has changed.
74
public BufferChangedEvent(IBuffer buffer, int offset, int length, String text) {
81
* Returns the buffer which has changed.
83
* @return the buffer affected by the change
85
public IBuffer getBuffer() {
86
return (IBuffer) source;
89
* Returns the length of text removed or replaced in the buffer, or
90
* 0 if text has been inserted into the buffer.
92
* @return the length of the original text fragment modified by the
93
* buffer change (<code> 0 </code> in case of insertion).
95
public int getLength() {
99
* Returns the index of the first character inserted, removed, or replaced
102
* @return the source offset of the textual manipulation in the buffer
104
public int getOffset() {
108
* Returns the text that was inserted, the replacement text,
109
* or <code>null</code> if text has been removed.
111
* @return the text corresponding to the buffer change (<code> null </code>
112
* in case of deletion).
114
public String getText() {