Source Code Cross Referenced for Row.java in  » Scripting » oscript-2.10.4 » ti » swing » console » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Scripting » oscript 2.10.4 » ti.swing.console 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*=============================================================================
002:         *     Copyright Texas Instruments, Inc., 2002.  All Rights Reserved.
003:         * 
004:         *  This program is free software; you can redistribute it and/or modify
005:         *  it under the terms of the GNU General Public License as published by
006:         *  the Free Software Foundation; either version 2 of the License, or
007:         *  (at your option) any later version.
008:         * 
009:         *  This program is distributed in the hope that it will be useful,
010:         *  but WITHOUT ANY WARRANTY; without even the implied warranty of
011:         *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
012:         *  GNU General Public License for more details.
013:         * 
014:         *  You should have received a copy of the GNU General Public License
015:         *  along with this program; if not, write to the Free Software
016:         *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
017:         */
018:
019:        package ti.swing.console;
020:
021:        import ti.exceptions.ProgrammingErrorException;
022:
023:        /**
024:         * Row is a utility class used by {@link ConsoleBuffer} to managed data for a 
025:         * particular row.  A row can track whether it needs to be redrawn (see
026:         * {@link #needsRedraw}, and be edited using a similar interface as the console
027:         * itself ({@link #append}, {@link #zap}).  The <code>ConsoleBuffer</code> is 
028:         * responsible for handling line breaks, as the <code>Row</code> has no
029:         * knowledge of the max number of columns per row.
030:         * <p>
031:         * Nothing in this class is synchronized, because everything that could
032:         * potentially need synchronization should be called from the protection
033:         * of synchronized code in {@link ConsoleBuffer}.
034:         * 
035:         * @author Rob Clark
036:         * @version 0.0
037:         */
038:        class Row implements  java.io.Serializable {
039:            /* Internally the data is cached as a string, but converted to StringBuffer
040:             * when it needs editing...
041:             */
042:            private String str = "";
043:            private StringBuffer sb = null;
044:
045:            private final StringBuffer getStringBuffer() {
046:                if (sb == null)
047:                    sb = new StringBuffer(str);
048:                return sb;
049:            }
050:
051:            /**
052:             * @see #getOffset
053:             */
054:            private int offset;
055:
056:            /**
057:             * @see #needsRedraw
058:             */
059:            private boolean dirty = true;
060:            private boolean visible = true;
061:
062:            /**
063:             * Class Constructor.
064:             * 
065:             * @param offset       offset of this row within the console character
066:             * stream
067:             */
068:            Row(int offset) {
069:                this .offset = offset;
070:            }
071:
072:            /**
073:             * The offset of the beginning of this row within the document stream.  
074:             * The offset<sub>i+1</sub> (offset of row i+1) is offset<sub>i</sub> + 
075:             * length<sub>i</sub>
076:             * 
077:             * @return the offset
078:             */
079:            final int getOffset() {
080:                return offset;
081:            }
082:
083:            /**
084:             * Get the number of characters in this row.
085:             */
086:            final int getLength() {
087:                if (sb != null)
088:                    return sb.length();
089:                else
090:                    return str.length();
091:            }
092:
093:            /**
094:             * Get the row data.
095:             * @return a string
096:             */
097:            final String getData() {
098:                if (sb != null) {
099:                    str = sb.toString();
100:                    sb = null;
101:                }
102:
103:                return str;
104:            }
105:
106:            /**
107:             * Does this row need to be re-rendered?  It is automatically marked dirty 
108:             * if the contents are changed (see {@link #append} and {@link #zap}, or
109:             * can be marked dirty (for example if a new region is mapped over a part
110:             * of this row) by calling {@link #markDirty}.
111:             * 
112:             * @return should this row be re-rendered?
113:             * @see #append
114:             * @see #zap
115:             * @see #markDirty
116:             */
117:            final boolean needsRedraw() {
118:                return dirty && visible;
119:            }
120:
121:            /**
122:             * Mark this row as needing to be repainted.
123:             */
124:            final void markDirty() {
125:                dirty = true;
126:            }
127:
128:            /**
129:             * Mark this row as not needing repaint.
130:             */
131:            final void markClean() {
132:                dirty = false;
133:            }
134:
135:            /**
136:             * Indicate whether this row is visible, as in not hidden based on the 
137:             * current clip-rect.
138:             */
139:            final void setVisible(boolean visible) {
140:                this .visible = visible;
141:            }
142:
143:            /**
144:             * Append characters to the end of this row.
145:             * 
146:             * @param cbuf         the character buffer
147:             * @param off          the offset into cbuf to first character to append
148:             * @param len          the number of characters to append
149:             */
150:            final void append(char[] cbuf, int off, int len) {
151:                if ((off + len) > cbuf.length)
152:                    throw new ProgrammingErrorException("cbuf too short");
153:
154:                getStringBuffer().append(cbuf, off, len);
155:                markDirty();
156:            }
157:
158:            /**
159:             * Delete characters from end of this row.
160:             * 
161:             * @param num          the number of characters to delete
162:             */
163:            final void zap(int num) {
164:                int len = getLength();
165:
166:                if (num > len)
167:                    throw new ProgrammingErrorException("num > len");
168:
169:                getStringBuffer().delete(len - num, len);
170:                markDirty();
171:            }
172:        }
173:
174:        /*
175:         *   Local Variables:
176:         *   tab-width: 2
177:         *   indent-tabs-mode: nil
178:         *   mode: java
179:         *   c-indentation-style: java
180:         *   c-basic-offset: 2
181:         *   eval: (c-set-offset 'substatement-open '0)
182:         *   eval: (c-set-offset 'case-label '+)
183:         *   eval: (c-set-offset 'inclass '+)
184:         *   eval: (c-set-offset 'inline-open '0)
185:         *   End:
186:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.