Source Code Cross Referenced for TextLine.java in  » IDE » J » org » armedbear » j » 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
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE » J » org.armedbear.j 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * TextLine.java
003:         *
004:         * Copyright (C) 1998-2002 Peter Graves
005:         * $Id: TextLine.java,v 1.3 2002/10/03 15:23:55 piso Exp $
006:         *
007:         * This program is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU General Public License
009:         * as published by the Free Software Foundation; either version 2
010:         * of the License, or (at your option) any later version.
011:         *
012:         * This program is distributed in the hope that it will be useful,
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
015:         * GNU General Public License for more details.
016:         *
017:         * You should have received a copy of the GNU General Public License
018:         * along with this program; if not, write to the Free Software
019:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
020:         */
021:
022:        package org.armedbear.j;
023:
024:        import java.io.UnsupportedEncodingException;
025:
026:        public class TextLine extends AbstractLine implements  Line {
027:            private static final int SAVED = 0x0001;
028:            private static final int NEW = 0x0002;
029:
030:            private int flags;
031:            private String text;
032:            private String originalText;
033:            private int bits;
034:
035:            protected TextLine() {
036:            }
037:
038:            public TextLine(String s) {
039:                text = s;
040:            }
041:
042:            protected final void init(String s) {
043:                text = s;
044:            }
045:
046:            public final synchronized int flags() {
047:                return flags;
048:            }
049:
050:            public final synchronized void setFlags(int flags) {
051:                this .flags = flags;
052:            }
053:
054:            public final synchronized String getText() {
055:                return text != null ? text : "";
056:            }
057:
058:            public final synchronized void setText(String s) {
059:                if (originalText == null)
060:                    originalText = text;
061:                text = s;
062:                if (text != null && text.equals(originalText))
063:                    originalText = null;
064:                bits &= ~SAVED;
065:            }
066:
067:            public final String getOriginalText() {
068:                return originalText;
069:            }
070:
071:            public final void setOriginalText(String s) {
072:                originalText = s;
073:            }
074:
075:            public final boolean isModified() {
076:                return originalText != null || isNew();
077:            }
078:
079:            public final boolean isNew() {
080:                return (bits & NEW) == NEW;
081:            }
082:
083:            public final void setNew(boolean b) {
084:                if (b)
085:                    bits |= NEW;
086:                else
087:                    bits &= ~NEW;
088:            }
089:
090:            public final boolean isSaved() {
091:                return (bits & SAVED) == SAVED;
092:            }
093:
094:            public final void setSaved(boolean b) {
095:                if (b)
096:                    bits |= SAVED;
097:                else
098:                    bits &= ~SAVED;
099:            }
100:
101:            public final void unmodified() {
102:                originalText = null;
103:                bits &= (~SAVED & ~NEW);
104:            }
105:
106:            public final char charAt(int i) {
107:                return getText().charAt(i);
108:            }
109:
110:            public final String substring(int beginIndex) {
111:                return getText().substring(beginIndex);
112:            }
113:
114:            public final String substring(int beginIndex, int endIndex) {
115:                return getText().substring(beginIndex, endIndex);
116:            }
117:
118:            public final String trim() {
119:                return getText().trim();
120:            }
121:
122:            public final int length() {
123:                return getText().length();
124:            }
125:
126:            public final int getWidth() {
127:                return length() * Display.getCharWidth();
128:            }
129:
130:            public final byte[] getBytes(String encoding)
131:                    throws UnsupportedEncodingException {
132:                byte[] bytes = getText().getBytes(encoding);
133:                if (bytes.length >= 2) {
134:                    if ((bytes[0] == (byte) 0xfe && bytes[1] == (byte) 0xff)
135:                            || (bytes[0] == (byte) 0xff && bytes[1] == (byte) 0xfe)) {
136:                        // Get rid of byte order mark.
137:                        byte[] newBytes = new byte[bytes.length - 2];
138:                        for (int i = 0; i < newBytes.length; i++)
139:                            newBytes[i] = bytes[i + 2];
140:                        return newBytes;
141:                    }
142:                }
143:                return bytes;
144:            }
145:
146:            public final boolean isBlank() {
147:                String s = getText();
148:
149:                for (int i = s.length(); i-- > 0;)
150:                    if (!Character.isWhitespace(s.charAt(i)))
151:                        return false;
152:
153:                return true;
154:            }
155:
156:            // Copies text, original text, and bit flags only.
157:            public Line copy() {
158:                TextLine line = new TextLine(text);
159:                line.originalText = originalText;
160:                line.bits = bits;
161:                return line;
162:            }
163:
164:            // Copies text, original text, and bit flags only.
165:            public void copy(Line line) {
166:                if (line instanceof  TextLine) {
167:                    TextLine textLine = (TextLine) line;
168:                    text = textLine.text;
169:                    originalText = textLine.originalText;
170:                    bits = textLine.bits;
171:                } else
172:                    Debug.bug();
173:            }
174:        }
www.java2java.com | Contact Us
Copyright 2010 - 2030 Java Source and Support. All rights reserved.
All other trademarks are property of their respective owners.