Source Code Cross Referenced for CharWrapVector.java in  » Web-Framework » RSF » uk » org » ponder » stringutil » 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 » Web Framework » RSF » uk.org.ponder.stringutil 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package uk.org.ponder.stringutil;
002:
003:        //import uk.org.ponder.util.Logger;
004:
005:        import uk.org.ponder.arrayutil.ArrayUtil;
006:
007:        /** This class allows chunk-wise manipulation of character data, in the form of 
008:         * a vector of CharWrap objects.
009:         */
010:
011:        public class CharWrapVector {
012:            private CharWrap[] storage;
013:            private int filled;
014:
015:            /** Constructs a new CharWrapVector with the specified initial size.
016:             * @param size The initial size of the new CharWrapVector.
017:             */
018:
019:            public CharWrapVector(int size) {
020:                if (size < 10)
021:                    size = 10;
022:                storage = new CharWrap[size];
023:                filled = 0;
024:            }
025:
026:            /** Returns the contents of this CharWrapVector as an array of CharWrap. The represented
027:             * data will start at index 0 of this array.
028:             * @return The contents of this CharWrapVector as an array of CharWrap.
029:             */
030:
031:            public CharWrap[] getArray() {
032:                return storage;
033:            }
034:
035:            private void expand(int newsize) {
036:                //    Logger.println("Expand from "+storage.length+" to "+newsize, Logger.DEBUG_INFORMATIONAL);
037:                storage = (CharWrap[]) ArrayUtil.expand(storage, newsize);
038:            }
039:
040:            /** Appends the supplied CharWrap object onto the end of this CharWrapVector.
041:             * @param toappend The CharWrap to be appended.
042:             */
043:
044:            public void append(CharWrap toappend) {
045:                if (filled == storage.length)
046:                    expand(storage.length * 2);
047:                storage[filled] = toappend;
048:                filled++;
049:            }
050:
051:            /** Appends the specified portion of the supplied CharWrapVector onto the end of this
052:             * CharWrapVector.
053:             * @param other The CharWrapVector holding the CharWraps to be appended.
054:             * @param offset The start index of the CharWraps to be appended.
055:             * @param length The number of CharWraps to be appended.
056:             */
057:
058:            public void append(CharWrapVector other, int offset, int length) {
059:                if (filled + length > storage.length)
060:                    expand(filled + length > storage.length * 2 ? filled
061:                            + length : storage.length * 2);
062:                /*
063:                Logger.println("About to call System.arraycopy: ol "+other.storage.length+" offset "
064:                	   +offset+" l "+storage.length+" filled "+filled+" length "+length,
065:                	   Logger.DEBUG_INFORMATIONAL);
066:                 */
067:                System
068:                        .arraycopy(other.storage, offset, storage, filled,
069:                                length);
070:                filled += length;
071:            }
072:
073:            /** This method compares the range of this vector with a range of the same length
074:             * in another. If there is a mismatch, the index of the mismatch is returned - otherwise
075:             * it returns -1.
076:             * @param thisoffset The offset within this CharWrapVector to begin the comparison at.
077:             * @param other The other CharWrapVector to compare this object with.
078:             * @param otheroffset The offset within the other CharWrapVector to begin the comparison at.
079:             * @param length The common length of the segments to be compared from each CharWrapVector.
080:             * @return -1 if the specified ranges match exactly, otherwise the index of the mismatch
081:             * point from the offset position.
082:             */
083:
084:            public int compareRange(int this offset, CharWrapVector other,
085:                    int otheroffset, int length) {
086:                for (int i = 0; i < length; ++i) {
087:                    if (!(storage[this offset + i]
088:                            .equals(other.storage[otheroffset + i])))
089:                        return i;
090:                }
091:                return -1;
092:            }
093:
094:            /** Returns the number of elements in this CharWrapVector.
095:             * @return The number of elements in this CharWrapVector.
096:             */
097:            public int size() {
098:                return filled;
099:            }
100:
101:            /** Returns the CharWrap object at the specified index.
102:             * @param i The index of the required CharWrap object.
103:             * @return The CharWrap object at the specified index.
104:             */
105:            public CharWrap charWrapAt(int i) {
106:                return storage[i];
107:            }
108:
109:            /** Converts this CharWrapVector to a String for debugging purposes. Word boundaries
110:             * are represented with the character |.
111:             * @return The data in this CharWrapVector as a String for debugging purposes.
112:             */
113:
114:            public String toDebugString() {
115:                CharWrap togo = new CharWrap();
116:                for (int i = 0; i < filled; ++i) {
117:                    togo.append('|').append(storage[i]).append('|');
118:                }
119:                return togo.toString();
120:            }
121:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.