1 /* 2 * The contents of this file are subject to the terms of the Common Development 3 * and Distribution License (the License). You may not use this file except in 4 * compliance with the License. 5 * 6 * You can obtain a copy of the License at http://www.netbeans.org/cddl.html 7 * or http://www.netbeans.org/cddl.txt. 8 * 9 * When distributing Covered Code, include this CDDL Header Notice in each file 10 * and include the License file at http://www.netbeans.org/cddl.txt. 11 * If applicable, add the following below the CDDL Header, with the fields 12 * enclosed by brackets [] replaced by your own identifying information: 13 * "Portions Copyrighted [year] [name of copyright owner]" 14 * 15 * The Original Software is NetBeans. The Initial Developer of the Original 16 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun 17 * Microsystems, Inc. All Rights Reserved. 18 */ 19 20 package org.netbeans.editor; 21 22 /** 23 * A given object can publish this interface if it allows 24 * an efficient access to its gap-based data storage 25 * and wants to give its clients a hint about how to access 26 * the data efficiently. 27 * <P>For example {@link javax.swing.text.Document} instance 28 * having gap-based document content can allow to get an instance 29 * of GapStart as a property:<PRE> 30 * GapStart gs = (GapStart)doc.getProperty(GapStart.class); 31 * int gapStart = gs.getGapStart(); 32 * <PRE> 33 * Once the start of the gap is known the client can optimize 34 * access to the document's data. For example if the client 35 * does not care about the chunks in which it gets the document's data 36 * it can access the characters so that no character copying is done:<PRE> 37 * Segment text = new Segment(); 38 * doc.getText(0, gapStart, text); // document's data below gap 39 * ... 40 * doc.getText(gapStart, doc.getLength(), text); // document's data over gap 41 * ... 42 * <PRE> 43 * 44 * @author Miloslav Metelka 45 * @version 1.00 46 */ 47 48 public interface GapStart { 49 50 /** 51 * Get the begining of the gap in the object's gap-based data. 52 * @return >=0 and <= total size of the data of the object. 53 */ 54 public int getGapStart(); 55 56 } 57