KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > core > DocumentAdapter


1 /*******************************************************************************
2  * Copyright (c) 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 package org.eclipse.jdt.internal.core;
12
13 import org.eclipse.jdt.core.IBuffer;
14 import org.eclipse.jface.text.BadLocationException;
15 import org.eclipse.jface.text.Document;
16
17 /*
18  * Adapts an IBuffer to IDocument
19  */

20 public class DocumentAdapter extends Document {
21     
22     private IBuffer buffer;
23     
24     public DocumentAdapter(IBuffer buffer) {
25         super(buffer.getContents());
26         this.buffer = buffer;
27     }
28
29     public void set(String JavaDoc text) {
30         super.set(text);
31         this.buffer.setContents(text);
32     }
33
34     public void replace(int offset, int length, String JavaDoc text) throws BadLocationException {
35         super.replace(offset, length, text);
36         this.buffer.replace(offset, length, text);
37     }
38
39 }
40
Popular Tags