KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > text > edits > CopyingRangeMarker


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 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.text.edits;
12
13 import org.eclipse.jface.text.BadLocationException;
14 import org.eclipse.jface.text.IDocument;
15
16 /**
17  * A <code>CopyingRangeMarker</code> can be used to track positions when executing
18  * text edits. Additionally a copying range marker stores a local copy of the
19  * text it captures when it gets executed.
20  *
21  * @since 3.0
22  */

23 public final class CopyingRangeMarker extends TextEdit {
24
25     private String JavaDoc fText;
26
27     /**
28      * Creates a new <tt>CopyRangeMarker</tt> for the given
29      * offset and length.
30      *
31      * @param offset the marker's offset
32      * @param length the marker's length
33      */

34     public CopyingRangeMarker(int offset, int length) {
35         super(offset, length);
36     }
37
38     /*
39      * Copy constructor
40      */

41     private CopyingRangeMarker(CopyingRangeMarker other) {
42         super(other);
43         fText= other.fText;
44     }
45
46     /*
47      * @see TextEdit#doCopy
48      */

49     protected TextEdit doCopy() {
50         return new CopyingRangeMarker(this);
51     }
52
53     /*
54      * @see TextEdit#accept0
55      */

56     protected void accept0(TextEditVisitor visitor) {
57         boolean visitChildren= visitor.visit(this);
58         if (visitChildren) {
59             acceptChildren(visitor);
60         }
61     }
62
63     /*
64      * @see TextEdit#performDocumentUpdating
65      */

66     int performDocumentUpdating(IDocument document) throws BadLocationException {
67         fText= document.get(getOffset(), getLength());
68         fDelta= 0;
69         return fDelta;
70     }
71
72     /*
73      * @see TextEdit#deleteChildren
74      */

75     boolean deleteChildren() {
76         return false;
77     }
78 }
79
Popular Tags