1/**2** Redistribution and use in source and binary forms, with or without3* modification, are permitted provided that the following conditions are4* met :5*6* . Redistributions of source code must retain the above copyright7* notice, this list of conditions and the following disclaimer.8*9* . Redistributions in binary form must reproduce the above copyright10* notice, this list of conditions and the following disclaimer in the11* documentation and/or other materials provided with the distribution.12*13* . The name of the author may not be used to endorse or promote products14* derived from this software without specific prior written permission.15*16* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR17* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE19* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,20* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR22* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)23* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,24* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN25* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE26* POSSIBILITY OF SUCH DAMAGE.27*28* $Id$29*/30 31packagepalmed.edit.text; 32 33importjava.io.IOException; 34importjava.io.InputStream; 35importjava.io.OutputStream; 36importpalmed.edit.util.Coordinate; 37 38/**39** This interface defines a chunk of text.40*41* @author Mathieu Champlon42* @version $Revision$ $Date$43*/44interfaceIChunkextendsICachable 45 { 46/**47** Retrieve the height of this chunk.48* <p>49* It slightly differs from the height of the underlying text as the first line is considered as part of the50* previous chunk and therefore is not counted.51* <p>52* Actually returns the height of the underlying text - 1.53*54* @return the height of the chunk55*/56intgetHeight(); 57 58/**59** Test the modification flag.60*61* @return whether the text has been modified since it has been read or written62*/63booleanhasBeenModified(); 64 65/**66** Call a functor if the given line number is inside the chunk.67*68* @param functor the functor69* @param line the absolute line number70* @return the possibly updated by the functor number of lines in the chunk71*/72inthandle( ILineExtractor functor,intline ); 73 74/**75** Call a functor if the area defined by given coordinates intersects the chunk.76*77* @param functor the functor78* @param start the absolute starting position of this chunk79* @param from the absolute coordinate of the beginning of the area80* @param to the absolute coordinate of the end of the area81* @return the absolute ending position of this chunk82*/83 Coordinate handle( ITextExtractor functor, Coordinate start, Coordinate from, Coordinate to ); 84 85/**86** Count the number of columns and lines.87*88* @param size the size to increment89* @param previous the length of the last line of the previous chunk90* @return the length of the last line of this chunk91*/92intcount( Coordinate size,intprevious ); 93 94voidread( InputStream stream ) throws IOException; 95 96voidwrite( OutputStream stream ) throws IOException; 97 }