1 /*******************************************************************************
2 * Copyright (c) 2000, 2003 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package net.sourceforge.phpdt.core;
13 import java.util.EventObject;
16 * A buffer changed event describes how a buffer has changed. These events are
17 * used in <code>IBufferChangedListener</code> notifications.
19 * For text insertions, <code>getOffset</code> is the offset of the first
20 * inserted character, <code>getText</code> is the inserted text, and
21 * <code>getLength</code> is 0.
24 * For text removals, <code>getOffset</code> is the offset of the first
25 * removed character, <code>getText</code> is <code>null</code>, and
26 * <code>getLength</code> is the length of the text that was removed.
29 * For replacements (including <code>IBuffer.setContents</code>),
30 * <code>getOffset</code> is the offset of the first replaced character,
31 * <code>getText</code> is the replacement text, and <code>getLength</code>
32 * is the length of the original text that was replaced.
35 * When a buffer is closed, <code>getOffset</code> is 0,
36 * <code>getLength</code> is 0, and <code>getText</code> is
40 * This class is not intended to be instantiated or subclassed by clients.
41 * Instances of this class are automatically created by the Java model.
46 public class BufferChangedEvent extends EventObject {
49 * The length of text that has been modified in the buffer.
54 * The offset into the buffer where the modification took place.
59 * The text that was modified.
64 * Creates a new buffer changed event indicating that the given buffer has
76 public BufferChangedEvent(IBuffer buffer, int offset, int length,
85 * Returns the buffer which has changed.
87 * @return the buffer affected by the change
89 public IBuffer getBuffer() {
90 return (IBuffer) source;
94 * Returns the length of text removed or replaced in the buffer, or 0 if
95 * text has been inserted into the buffer.
97 * @return the length of the original text fragment modified by the buffer
98 * change (<code> 0 </code> in case of insertion).
100 public int getLength() {
105 * Returns the index of the first character inserted, removed, or replaced
108 * @return the source offset of the textual manipulation in the buffer
110 public int getOffset() {
115 * Returns the text that was inserted, the replacement text, or
116 * <code>null</code> if text has been removed.
118 * @return the text corresponding to the buffer change (<code> null </code>
119 * in case of deletion).
121 public String getText() {