3261N/A * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * A plain document that maintains no character attributes. The 0N/A * default element structure for this document is a map of the lines in 0N/A * the text. The Element returned by getDefaultRootElement is 0N/A * a map of the lines, and each child element represents a line. 0N/A * This model does not maintain any character level attributes, 0N/A * but each line can be tagged with an arbitrary set of attributes. 0N/A * Line to offset, and offset to line translations can be quickly 0N/A * performed using the default root element. The structure information 0N/A * of the DocumentEvent's fired by edits will indicate the line 0N/A * structure changes. 0N/A * The default content storage management is performed by a 0N/A * gapped buffer implementation (GapContent). It supports 0N/A * editing reasonably large documents with good efficiency when 0N/A * the edits are contiguous or clustered, as is typical. 0N/A * <strong>Warning:</strong> 0N/A * Serialized objects of this class will not be compatible with 0N/A * future Swing releases. The current serialization support is 0N/A * appropriate for short term storage or RMI between applications running 0N/A * the same version of Swing. As of 1.4, support for long term storage 0N/A * of all JavaBeans<sup><font size="-2">TM</font></sup> 0N/A * has been added to the <code>java.beans</code> package. 0N/A * @author Timothy Prinzing 0N/A * @see AbstractDocument 0N/A * Name of the attribute that specifies the tab 0N/A * size for tabs contained in the content. The 0N/A * type for the value is Integer. 0N/A * Name of the attribute that specifies the maximum 0N/A * length of a line, if there is a maximum length. 0N/A * The type for the value is Integer. 0N/A * Constructs a plain text document. A default model using 0N/A * <code>GapContent</code> is constructed and set. 0N/A * Constructs a plain text document. A default root element is created, 0N/A * and the tab size set to 8. 0N/A * @param c the container for the content 0N/A * Inserts some content into the document. 0N/A * Inserting content causes a write lock to be held while the 0N/A * actual changes are taking place, followed by notification 0N/A * to the observers on the thread that grabbed the write lock. 0N/A * This method is thread safe, although most Swing methods 0N/A * are not. Please see 0N/A * to Use Threads</A> for more information. 0N/A * @param offs the starting offset >= 0 0N/A * @param str the string to insert; does nothing with null/empty strings 0N/A * @param a the attributes for the inserted content 0N/A * @exception BadLocationException the given insert position is not a valid 0N/A * position within the document 0N/A * @see Document#insertString 0N/A // fields don't want to have multiple lines. We may provide a field-specific 0N/A // model in the future in which case the filtering logic here will no longer 0N/A for (
int i =
0; i < n; i++) {
0N/A * Gets the default root element for the document model. 0N/A * @see Document#getDefaultRootElement 0N/A * Creates the root element to be used to represent the 0N/A * default document structure. 0N/A * @return the element base 0N/A * Get the paragraph element containing the given position. Since this 0N/A * document only models lines, it returns the line instead. 0N/A * Updates document structure as a result of text insertion. This 0N/A * will happen within a write lock. Since this document simply 0N/A * maps out lines, we refresh the line map. 0N/A * @param chng the change event describing the dit 0N/A * @param attr the set of attributes for the inserted text 0N/A * Updates any document structure as a result of text removal. 0N/A * This will happen within a write lock. Since the structure 0N/A * represents a line map, this just checks to see if the 0N/A * removal spans lines. If it does, the two lines outside 0N/A * of the removal area are joined together. 0N/A * @param chng the change event describing the edit 0N/A // a line was removed 0N/A //Check for the composed text element 0N/A // Inserts the composed text of an input method. The line element 0N/A // where the composed text is inserted into becomes an branch element 0N/A // which contains leaf elements of the composed text and the text