Source Code Cross Referenced for DocCacheSupport.java in  » Swing-Library » abeille-forms-designer » org » netbeans » editor » 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 » Swing Library » abeille forms designer » org.netbeans.editor 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *                 Sun Public License Notice
003:         * 
004:         * The contents of this file are subject to the Sun Public License
005:         * Version 1.0 (the "License"). You may not use this file except in
006:         * compliance with the License. A copy of the License is available at
007:         * http://www.sun.com/
008:         * 
009:         * The Original Code is NetBeans. The Initial Developer of the Original
010:         * Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun
011:         * Microsystems, Inc. All Rights Reserved.
012:         */
013:
014:        package org.netbeans.editor;
015:
016:        import java.io.IOException;
017:        import java.io.Writer;
018:
019:        import javax.swing.text.BadLocationException;
020:
021:        /**
022:         * DocCacheSupport is a base class for caching document which is got by some
023:         * reader and enable its editing.
024:         * 
025:         * @author Miloslav Metelka
026:         * @version 1.00
027:         */
028:
029:        abstract class DocCacheSupport {
030:
031:            private static final int SAVE_BUFFER_LEN = 16384;
032:
033:            /** Current document length in characters */
034:            protected int docLen;
035:
036:            /** Count of characters read */
037:            long statCharsRead;
038:            /** Count of characters written */
039:            long statCharsWritten;
040:
041:            /**
042:             * Reading from the temporary storage into destination buffer.
043:             * 
044:             * @param pos
045:             *            position in temp storage
046:             * @param buffer
047:             *            target storage
048:             * @param offset
049:             *            offset in buffer
050:             * @param len
051:             *            length of data in buffer to write
052:             */
053:            public abstract void read(int pos, char buffer[], int offset,
054:                    int len) throws BadLocationException;
055:
056:            /**
057:             * Write buffer at the specified position. Rewrites part of the document. It
058:             * can write beyond the end of the document, however the initial position
059:             * must be inside or at the end of the document.
060:             * 
061:             * @param pos
062:             *            position in temp storage
063:             * @param buffer
064:             *            buffer with source data
065:             * @param offset
066:             *            offset of data in buffer
067:             * @param len
068:             *            length of data in buffer
069:             */
070:            public abstract void write(int pos, char buffer[], int offset,
071:                    int len) throws BadLocationException;
072:
073:            /**
074:             * Insert buffer into the document at specified position.
075:             * 
076:             * @param pos
077:             *            insertion position in temp storage document
078:             * @param buffer
079:             *            source buffer with insertion data
080:             * @param offset
081:             *            offset of data in the buffer
082:             * @param len
083:             *            length of data in buffer
084:             */
085:            public abstract void insert(int pos, char buffer[], int offset,
086:                    int len) throws BadLocationException;
087:
088:            /**
089:             * Insert string into the document at specified position.
090:             * 
091:             * @param pos
092:             *            insertion position in temp storage document
093:             * @param text
094:             *            text to insert
095:             * @param offset
096:             *            offset of data in the buffer
097:             * @param len
098:             *            length of data in buffer
099:             */
100:            public abstract void insertString(int pos, String text, int offset,
101:                    int len) throws BadLocationException;
102:
103:            /**
104:             * Delete a specified count of chars at specified position.
105:             * 
106:             * @param pos
107:             *            position of removal in temp storage
108:             * @param len
109:             *            length of data to remove
110:             */
111:            public abstract void remove(int pos, int len)
112:                    throws BadLocationException;
113:
114:            /**
115:             * Helps to do less allocations if the initial file size is known. By
116:             * default it's not implemented.
117:             * 
118:             * @param capacity
119:             *            space that will be preallocated
120:             */
121:            public void ensureCapacity(int capacity) {
122:            }
123:
124:            /**
125:             * Saving the tepmorary document to a writer.
126:             * 
127:             * @param writer
128:             *            writer where to write data from temp storage
129:             */
130:            public void save(Writer writer) throws IOException {
131:                char saveBuffer[] = new char[SAVE_BUFFER_LEN];
132:                int actPos = 0, len;
133:                while (actPos < docLen) {
134:                    len = Math.min(docLen - actPos, SAVE_BUFFER_LEN);
135:                    try {
136:                        read(actPos, saveBuffer, 0, len);
137:                    } catch (BadLocationException e) {
138:                        if (Boolean.getBoolean("netbeans.debug.exceptions")) { // NOI18N
139:                            e.printStackTrace();
140:                        }
141:                    }
142:                    writer.write(saveBuffer, 0, len);
143:                    actPos += len;
144:                }
145:                writer.flush(); // flush the stream at the end
146:            }
147:
148:            /**
149:             * Destroy the CacheSupport (delete temp file etc.)
150:             */
151:            public void destroy() {
152:            }
153:
154:            /** Getter: Document length */
155:            public final int getDocLength() {
156:                return docLen;
157:            }
158:
159:            public boolean supportsDirectMode() {
160:                return false;
161:            }
162:
163:            public char[] getDirectModeBuffer() {
164:                return null;
165:            }
166:
167:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.