src/share/classes/javax/swing/text/AbstractDocument.java

Print this page




1792          * @param psOut the output stream
1793          * @param indentAmount the indentation level >= 0
1794          */
1795         public void dump(PrintStream psOut, int indentAmount) {
1796             PrintWriter out;
1797             try {
1798                 out = new PrintWriter(new OutputStreamWriter(psOut,"JavaEsc"),
1799                                       true);
1800             } catch (UnsupportedEncodingException e){
1801                 out = new PrintWriter(psOut,true);
1802             }
1803             indent(out, indentAmount);
1804             if (getName() == null) {
1805                 out.print("<??");
1806             } else {
1807                 out.print("<" + getName());
1808             }
1809             if (getAttributeCount() > 0) {
1810                 out.println("");
1811                 // dump the attributes
1812                 Enumeration names = attributes.getAttributeNames();
1813                 while (names.hasMoreElements()) {
1814                     Object name = names.nextElement();
1815                     indent(out, indentAmount + 1);
1816                     out.println(name + "=" + getAttribute(name));
1817                 }
1818                 indent(out, indentAmount);
1819             }
1820             out.println(">");
1821 
1822             if (isLeaf()) {
1823                 indent(out, indentAmount+1);
1824                 out.print("[" + getStartOffset() + "," + getEndOffset() + "]");
1825                 Content c = getContent();
1826                 try {
1827                     String contentStr = c.getString(getStartOffset(),
1828                                                     getEndOffset() - getStartOffset())/*.trim()*/;
1829                     if (contentStr.length() > 40) {
1830                         contentStr = contentStr.substring(0, 40) + "...";
1831                     }
1832                     out.println("["+contentStr+"]");


2176          */
2177         public int getIndex(TreeNode node) {
2178             for(int counter = getChildCount() - 1; counter >= 0; counter--)
2179                 if(getChildAt(counter) == node)
2180                     return counter;
2181             return -1;
2182         }
2183 
2184         /**
2185          * Returns true if the receiver allows children.
2186          * @return true if the receiver allows children, otherwise false
2187          */
2188         public abstract boolean getAllowsChildren();
2189 
2190 
2191         /**
2192          * Returns the children of the receiver as an
2193          * <code>Enumeration</code>.
2194          * @return the children of the receiver as an <code>Enumeration</code>
2195          */
2196         public abstract Enumeration children();
2197 
2198 
2199         // --- serialization ---------------------------------------------
2200 
2201         private void writeObject(ObjectOutputStream s) throws IOException {
2202             s.defaultWriteObject();
2203             StyleContext.writeAttributeSet(s, attributes);
2204         }
2205 
2206         private void readObject(ObjectInputStream s)
2207             throws ClassNotFoundException, IOException
2208         {
2209             s.defaultReadObject();
2210             MutableAttributeSet attr = new SimpleAttributeSet();
2211             StyleContext.readAttributeSet(s, attr);
2212             AttributeContext context = getAttributeContext();
2213             attributes = context.addAttributes(SimpleAttributeSet.EMPTY, attr);
2214         }
2215 
2216         // ---- variables -----------------------------------------------------


2439             return false;
2440         }
2441 
2442 
2443         // ------ TreeNode ----------------------------------------------
2444 
2445         /**
2446          * Returns true if the receiver allows children.
2447          * @return true if the receiver allows children, otherwise false
2448          */
2449         public boolean getAllowsChildren() {
2450             return true;
2451         }
2452 
2453 
2454         /**
2455          * Returns the children of the receiver as an
2456          * <code>Enumeration</code>.
2457          * @return the children of the receiver
2458          */
2459         public Enumeration children() {
2460             if(nchildren == 0)
2461                 return null;
2462 
2463             Vector<AbstractElement> tempVector = new Vector<AbstractElement>(nchildren);
2464 
2465             for(int counter = 0; counter < nchildren; counter++)
2466                 tempVector.addElement(children[counter]);
2467             return tempVector.elements();
2468         }
2469 
2470         // ------ members ----------------------------------------------
2471 
2472         private AbstractElement[] children;
2473         private int nchildren;
2474         private int lastIndex;
2475     }
2476 
2477     /**
2478      * Implements an element that directly represents content of
2479      * some kind.


2593         public boolean isLeaf() {
2594             return true;
2595         }
2596 
2597         // ------ TreeNode ----------------------------------------------
2598 
2599         /**
2600          * Returns true if the receiver allows children.
2601          * @return true if the receiver allows children, otherwise false
2602          */
2603         public boolean getAllowsChildren() {
2604             return false;
2605         }
2606 
2607 
2608         /**
2609          * Returns the children of the receiver as an
2610          * <code>Enumeration</code>.
2611          * @return the children of the receiver
2612          */
2613         public Enumeration children() {
2614             return null;
2615         }
2616 
2617         // --- serialization ---------------------------------------------
2618 
2619         private void writeObject(ObjectOutputStream s) throws IOException {
2620             s.defaultWriteObject();
2621             s.writeInt(p0.getOffset());
2622             s.writeInt(p1.getOffset());
2623         }
2624 
2625         private void readObject(ObjectInputStream s)
2626             throws ClassNotFoundException, IOException
2627         {
2628             s.defaultReadObject();
2629 
2630             // set the range with positions that track change
2631             int off0 = s.readInt();
2632             int off1 = s.readInt();
2633             try {




1792          * @param psOut the output stream
1793          * @param indentAmount the indentation level &gt;= 0
1794          */
1795         public void dump(PrintStream psOut, int indentAmount) {
1796             PrintWriter out;
1797             try {
1798                 out = new PrintWriter(new OutputStreamWriter(psOut,"JavaEsc"),
1799                                       true);
1800             } catch (UnsupportedEncodingException e){
1801                 out = new PrintWriter(psOut,true);
1802             }
1803             indent(out, indentAmount);
1804             if (getName() == null) {
1805                 out.print("<??");
1806             } else {
1807                 out.print("<" + getName());
1808             }
1809             if (getAttributeCount() > 0) {
1810                 out.println("");
1811                 // dump the attributes
1812                 Enumeration<?> names = attributes.getAttributeNames();
1813                 while (names.hasMoreElements()) {
1814                     Object name = names.nextElement();
1815                     indent(out, indentAmount + 1);
1816                     out.println(name + "=" + getAttribute(name));
1817                 }
1818                 indent(out, indentAmount);
1819             }
1820             out.println(">");
1821 
1822             if (isLeaf()) {
1823                 indent(out, indentAmount+1);
1824                 out.print("[" + getStartOffset() + "," + getEndOffset() + "]");
1825                 Content c = getContent();
1826                 try {
1827                     String contentStr = c.getString(getStartOffset(),
1828                                                     getEndOffset() - getStartOffset())/*.trim()*/;
1829                     if (contentStr.length() > 40) {
1830                         contentStr = contentStr.substring(0, 40) + "...";
1831                     }
1832                     out.println("["+contentStr+"]");


2176          */
2177         public int getIndex(TreeNode node) {
2178             for(int counter = getChildCount() - 1; counter >= 0; counter--)
2179                 if(getChildAt(counter) == node)
2180                     return counter;
2181             return -1;
2182         }
2183 
2184         /**
2185          * Returns true if the receiver allows children.
2186          * @return true if the receiver allows children, otherwise false
2187          */
2188         public abstract boolean getAllowsChildren();
2189 
2190 
2191         /**
2192          * Returns the children of the receiver as an
2193          * <code>Enumeration</code>.
2194          * @return the children of the receiver as an <code>Enumeration</code>
2195          */
2196         public abstract Enumeration<?> children();
2197 
2198 
2199         // --- serialization ---------------------------------------------
2200 
2201         private void writeObject(ObjectOutputStream s) throws IOException {
2202             s.defaultWriteObject();
2203             StyleContext.writeAttributeSet(s, attributes);
2204         }
2205 
2206         private void readObject(ObjectInputStream s)
2207             throws ClassNotFoundException, IOException
2208         {
2209             s.defaultReadObject();
2210             MutableAttributeSet attr = new SimpleAttributeSet();
2211             StyleContext.readAttributeSet(s, attr);
2212             AttributeContext context = getAttributeContext();
2213             attributes = context.addAttributes(SimpleAttributeSet.EMPTY, attr);
2214         }
2215 
2216         // ---- variables -----------------------------------------------------


2439             return false;
2440         }
2441 
2442 
2443         // ------ TreeNode ----------------------------------------------
2444 
2445         /**
2446          * Returns true if the receiver allows children.
2447          * @return true if the receiver allows children, otherwise false
2448          */
2449         public boolean getAllowsChildren() {
2450             return true;
2451         }
2452 
2453 
2454         /**
2455          * Returns the children of the receiver as an
2456          * <code>Enumeration</code>.
2457          * @return the children of the receiver
2458          */
2459         public Enumeration<AbstractElement> children() {
2460             if(nchildren == 0)
2461                 return null;
2462 
2463             Vector<AbstractElement> tempVector = new Vector<AbstractElement>(nchildren);
2464 
2465             for(int counter = 0; counter < nchildren; counter++)
2466                 tempVector.addElement(children[counter]);
2467             return tempVector.elements();
2468         }
2469 
2470         // ------ members ----------------------------------------------
2471 
2472         private AbstractElement[] children;
2473         private int nchildren;
2474         private int lastIndex;
2475     }
2476 
2477     /**
2478      * Implements an element that directly represents content of
2479      * some kind.


2593         public boolean isLeaf() {
2594             return true;
2595         }
2596 
2597         // ------ TreeNode ----------------------------------------------
2598 
2599         /**
2600          * Returns true if the receiver allows children.
2601          * @return true if the receiver allows children, otherwise false
2602          */
2603         public boolean getAllowsChildren() {
2604             return false;
2605         }
2606 
2607 
2608         /**
2609          * Returns the children of the receiver as an
2610          * <code>Enumeration</code>.
2611          * @return the children of the receiver
2612          */
2613         public Enumeration<?> children() {
2614             return null;
2615         }
2616 
2617         // --- serialization ---------------------------------------------
2618 
2619         private void writeObject(ObjectOutputStream s) throws IOException {
2620             s.defaultWriteObject();
2621             s.writeInt(p0.getOffset());
2622             s.writeInt(p1.getOffset());
2623         }
2624 
2625         private void readObject(ObjectInputStream s)
2626             throws ClassNotFoundException, IOException
2627         {
2628             s.defaultReadObject();
2629 
2630             // set the range with positions that track change
2631             int off0 = s.readInt();
2632             int off1 = s.readInt();
2633             try {