1 /*******************************************************************************
2 * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v0.5
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v05.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
20 * of the first inserted character, <code>getText</code> is the
21 * inserted text, and <code>getLength</code> is 0.
24 * For text removals, <code>getOffset</code> is the offset
25 * of the first removed character, <code>getText</code> is <code>null</code>,
26 * and <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
31 * of the first replaced character, <code>getText</code> is the replacement
32 * text, and <code>getLength</code> is the length of the original text
36 * When a buffer is closed, <code>getOffset</code> is 0, <code>getLength</code>
37 * is 0, and <code>getText</code> is <code>null</code>.
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 changed.
66 public BufferChangedEvent(IBuffer buffer, int offset, int length, String text) {
73 * Returns the buffer which has changed.
75 * @return the buffer affected by the change
77 public IBuffer getBuffer() {
78 return (IBuffer) source;
81 * Returns the length of text removed or replaced in the buffer, or
82 * 0 if text has been inserted into the buffer.
84 * @return the length of the original text fragment modified by the
85 * buffer change (<code> 0 </code> in case of insertion).
87 public int getLength() {
91 * Returns the index of the first character inserted, removed, or replaced
94 * @return the source offset of the textual manipulation in the buffer
96 public int getOffset() {
100 * Returns the text that was inserted, the replacement text,
101 * or <code>null</code> if text has been removed.
103 * @return the text corresponding to the buffer change (<code> null </code>
104 * in case of deletion).
106 public String getText() {