KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > api > editor > guards > InteriorSection


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 package org.netbeans.api.editor.guards;
20
21 import javax.swing.text.Position JavaDoc;
22 import org.netbeans.modules.editor.guards.InteriorSectionImpl;
23
24 /**
25  * Represents an advanced guarded section.
26  * It consists of three pieces: a header, body, and footer.
27  * The header and footer are guarded but the body is not.
28  */

29 public final class InteriorSection extends GuardedSection {
30     /**
31      * Creates new section.
32      * @param name Name of the new section.
33      */

34     InteriorSection(InteriorSectionImpl impl) {
35         super(impl);
36     }
37
38     /**
39      * Sets the text of the body.
40      * @param text the new text
41      */

42     public void setBody(String JavaDoc text) {
43         getImpl().setBody(text);
44     }
45     
46     /**
47      * Returns the contents of the body part of the section. If the
48      * section is invalid the method returns null.
49      * @return contents of the body or null, if the section is not valid.
50      */

51     public String JavaDoc getBody() {
52         return getImpl().getBody();
53     }
54
55     /**
56      * Sets the text of the header.
57      * @param text the new text
58      */

59     public void setHeader(String JavaDoc text) {
60         getImpl().setHeader(text);
61     }
62
63     /**
64      * Returns the contents of the header part of the section. If the
65      * section is invalid the method returns null.
66      * @return contents of the header or null, if the section is not valid.
67      */

68     public String JavaDoc getHeader() {
69         return getImpl().getHeader();
70     }
71
72     /**
73      * Sets the text of the footer.
74      * Note that the footer of the section must have exactly one line.
75      * So, all interior newline characters will be replaced by spaces.
76      *
77      * @param text the new text
78      */

79     public void setFooter(String JavaDoc text) {
80         getImpl().setFooter(text);
81     }
82
83     /**
84      * Returns the contents of the footer part of the guarded section.
85      * The method will return null, if the section is not valid.
86      * @return contents of the footer part, or null if the section is not valid.
87      */

88     public String JavaDoc getFooter() {
89         return getImpl().getFooter();
90     }
91     
92     /**
93      * Returns a position where the body starts
94      * @return the start position of the body part
95      */

96     public Position JavaDoc getBodyStartPosition() {
97         return getImpl().getBodyStartPosition();
98     }
99     
100     /**
101      * Returns a position where the body ends
102      * @return the end position of the body part
103      */

104     public Position JavaDoc getBodyEndPosition() {
105         return getImpl().getBodyEndPosition();
106     }
107     
108     InteriorSectionImpl getImpl() {
109         return (InteriorSectionImpl) super.getImpl();
110     }
111
112     /*
113     public String toString() {
114       StringBuffer buf = new StringBuffer("InteriorSection:"+name); // NOI18N
115       try {
116         buf.append("HEADER:\""); // NOI18N
117         buf.append(header.getText());
118         buf.append("\"");
119         buf.append("BODY:\""); // NOI18N
120         buf.append(body.getText());
121         buf.append("\"");
122         buf.append("BOTTOM:\""); // NOI18N
123         buf.append(bottom.getText());
124         buf.append("\"");
125       }
126       catch (Exception e) {
127         buf.append("EXCEPTION:"); // NOI18N
128         buf.append(e.getMessage());
129       }
130       return buf.toString();
131     }*/

132 }
133
Popular Tags