Source Code Cross Referenced for CharBuffer.java in  » Parser » chaperon-3.0 » net » sourceforge » chaperon » process » extended » 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 » Parser » chaperon 3.0 » net.sourceforge.chaperon.process.extended 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Copyright (C) Chaperon. All rights reserved.
003:         *  -------------------------------------------------------------------------
004:         *  This software is published under the terms of the Apache Software License
005:         *  version 1.1, a copy of which has been included  with this distribution in
006:         *  the LICENSE file.
007:         */
008:
009:        package net.sourceforge.chaperon.process.extended;
010:
011:        public class CharBuffer {
012:            public CharBufferEntry head = null;
013:            public CharBufferEntry tail = null;
014:            public CharBufferEntry current = null;
015:            public int position;
016:
017:            public void push(char[] text, int position, int length) {
018:                if (head == null) {
019:                    head = new CharBufferEntry(text, position, length, null);
020:                    tail = head;
021:                    current = head;
022:                    this .position = position;
023:                } else {
024:                    tail = new CharBufferEntry(text, position, length, tail);
025:
026:                    if ((this .position == (current.position + current.length))
027:                            && (current.next == tail)) {
028:                        current = current.next;
029:                        this .position = current.position;
030:                    }
031:                }
032:            }
033:
034:            public char read() {
035:                if ((position < (current.position + current.length))
036:                        && (current != null)) {
037:                    char c = current.text[position];
038:
039:                    position++;
040:                    if ((position == (current.position + current.length))
041:                            && (current.next != null)) {
042:                        current = current.next;
043:                        position = current.position;
044:                    }
045:
046:                    return c;
047:                } else
048:                    throw new IllegalStateException("Buffer is empty");
049:            }
050:
051:            public char peek() {
052:                if ((position < (current.position + current.length))
053:                        && (current != null))
054:                    return current.text[position];
055:                else
056:                    throw new IllegalStateException("Buffer is empty");
057:            }
058:
059:            public boolean available() {
060:                return (current != null)
061:                        && (position < (current.position + current.length));
062:            }
063:
064:            public int remaining() {
065:                int remaining = (current.position + current.length) - position;
066:                CharBufferEntry next = current.next;
067:                while (next != null) {
068:                    remaining += next.length;
069:                    next = next.next;
070:                }
071:
072:                return remaining;
073:            }
074:
075:            public void back() {
076:                if (position > current.position)
077:                    position--;
078:                else if (current.previous != null) {
079:                    current = current.previous;
080:                    position = (current.position + current.length) - 1;
081:                } else
082:                    throw new IllegalStateException("Couldn't move back");
083:            }
084:
085:            public void clear() {
086:                head = null;
087:                tail = null;
088:                current = null;
089:            }
090:
091:            public class CharBufferEntry {
092:                public char[] text;
093:                public int position;
094:                public int length;
095:                public CharBufferEntry previous = null;
096:                public CharBufferEntry next = null;
097:
098:                public CharBufferEntry(char[] text, int position, int length,
099:                        CharBufferEntry previous) {
100:                    this.text = text;
101:                    this.position = position;
102:                    this.length = length;
103:                    this.previous = previous;
104:                    if (previous != null)
105:                        previous.next = this;
106:                }
107:            }
108:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.