Source Code Cross Referenced for SimpleCharStream.java in  » Workflow-Engines » osbl-1_0 » org » concern » model » parser » 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 » Workflow Engines » osbl 1_0 » org.concern.model.parser 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Generated By:JavaCC: Do not edit this line. SimpleCharStream.java Version 3.0 */
002:        package org.concern.model.parser;
003:
004:        /**
005:         * An implementation of interface CharStream, where the stream is assumed to
006:         * contain only ASCII characters (without unicode processing).
007:         */
008:
009:        public class SimpleCharStream {
010:            public static final boolean staticFlag = false;
011:            int bufsize;
012:            int available;
013:            int tokenBegin;
014:            public int bufpos = -1;
015:            protected int bufline[];
016:            protected int bufcolumn[];
017:
018:            protected int column = 0;
019:            protected int line = 1;
020:
021:            protected boolean prevCharIsCR = false;
022:            protected boolean prevCharIsLF = false;
023:
024:            protected java.io.Reader inputStream;
025:
026:            protected char[] buffer;
027:            protected int maxNextCharInd = 0;
028:            protected int inBuf = 0;
029:
030:            protected void ExpandBuff(boolean wrapAround) {
031:                char[] newbuffer = new char[bufsize + 2048];
032:                int newbufline[] = new int[bufsize + 2048];
033:                int newbufcolumn[] = new int[bufsize + 2048];
034:
035:                try {
036:                    if (wrapAround) {
037:                        System.arraycopy(buffer, tokenBegin, newbuffer, 0,
038:                                bufsize - tokenBegin);
039:                        System.arraycopy(buffer, 0, newbuffer, bufsize
040:                                - tokenBegin, bufpos);
041:                        buffer = newbuffer;
042:
043:                        System.arraycopy(bufline, tokenBegin, newbufline, 0,
044:                                bufsize - tokenBegin);
045:                        System.arraycopy(bufline, 0, newbufline, bufsize
046:                                - tokenBegin, bufpos);
047:                        bufline = newbufline;
048:
049:                        System.arraycopy(bufcolumn, tokenBegin, newbufcolumn,
050:                                0, bufsize - tokenBegin);
051:                        System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize
052:                                - tokenBegin, bufpos);
053:                        bufcolumn = newbufcolumn;
054:
055:                        maxNextCharInd = (bufpos += (bufsize - tokenBegin));
056:                    } else {
057:                        System.arraycopy(buffer, tokenBegin, newbuffer, 0,
058:                                bufsize - tokenBegin);
059:                        buffer = newbuffer;
060:
061:                        System.arraycopy(bufline, tokenBegin, newbufline, 0,
062:                                bufsize - tokenBegin);
063:                        bufline = newbufline;
064:
065:                        System.arraycopy(bufcolumn, tokenBegin, newbufcolumn,
066:                                0, bufsize - tokenBegin);
067:                        bufcolumn = newbufcolumn;
068:
069:                        maxNextCharInd = (bufpos -= tokenBegin);
070:                    }
071:                } catch (Throwable t) {
072:                    throw new Error(t.getMessage());
073:                }
074:
075:                bufsize += 2048;
076:                available = bufsize;
077:                tokenBegin = 0;
078:            }
079:
080:            protected void FillBuff() throws java.io.IOException {
081:                if (maxNextCharInd == available) {
082:                    if (available == bufsize) {
083:                        if (tokenBegin > 2048) {
084:                            bufpos = maxNextCharInd = 0;
085:                            available = tokenBegin;
086:                        } else if (tokenBegin < 0)
087:                            bufpos = maxNextCharInd = 0;
088:                        else
089:                            ExpandBuff(false);
090:                    } else if (available > tokenBegin)
091:                        available = bufsize;
092:                    else if ((tokenBegin - available) < 2048)
093:                        ExpandBuff(true);
094:                    else
095:                        available = tokenBegin;
096:                }
097:
098:                int i;
099:                try {
100:                    if ((i = inputStream.read(buffer, maxNextCharInd, available
101:                            - maxNextCharInd)) == -1) {
102:                        inputStream.close();
103:                        throw new java.io.IOException();
104:                    } else
105:                        maxNextCharInd += i;
106:                    return;
107:                } catch (java.io.IOException e) {
108:                    --bufpos;
109:                    backup(0);
110:                    if (tokenBegin == -1)
111:                        tokenBegin = bufpos;
112:                    throw e;
113:                }
114:            }
115:
116:            public char BeginToken() throws java.io.IOException {
117:                tokenBegin = -1;
118:                char c = readChar();
119:                tokenBegin = bufpos;
120:
121:                return c;
122:            }
123:
124:            protected void UpdateLineColumn(char c) {
125:                column++;
126:
127:                if (prevCharIsLF) {
128:                    prevCharIsLF = false;
129:                    line += (column = 1);
130:                } else if (prevCharIsCR) {
131:                    prevCharIsCR = false;
132:                    if (c == '\n') {
133:                        prevCharIsLF = true;
134:                    } else
135:                        line += (column = 1);
136:                }
137:
138:                switch (c) {
139:                case '\r':
140:                    prevCharIsCR = true;
141:                    break;
142:                case '\n':
143:                    prevCharIsLF = true;
144:                    break;
145:                case '\t':
146:                    column--;
147:                    column += (8 - (column & 07));
148:                    break;
149:                default:
150:                    break;
151:                }
152:
153:                bufline[bufpos] = line;
154:                bufcolumn[bufpos] = column;
155:            }
156:
157:            public char readChar() throws java.io.IOException {
158:                if (inBuf > 0) {
159:                    --inBuf;
160:
161:                    if (++bufpos == bufsize)
162:                        bufpos = 0;
163:
164:                    return buffer[bufpos];
165:                }
166:
167:                if (++bufpos >= maxNextCharInd)
168:                    FillBuff();
169:
170:                char c = buffer[bufpos];
171:
172:                UpdateLineColumn(c);
173:                return (c);
174:            }
175:
176:            /**
177:             * @deprecated 
178:             * @see #getEndColumn
179:             */
180:
181:            public int getColumn() {
182:                return bufcolumn[bufpos];
183:            }
184:
185:            /**
186:             * @deprecated 
187:             * @see #getEndLine
188:             */
189:
190:            public int getLine() {
191:                return bufline[bufpos];
192:            }
193:
194:            public int getEndColumn() {
195:                return bufcolumn[bufpos];
196:            }
197:
198:            public int getEndLine() {
199:                return bufline[bufpos];
200:            }
201:
202:            public int getBeginColumn() {
203:                return bufcolumn[tokenBegin];
204:            }
205:
206:            public int getBeginLine() {
207:                return bufline[tokenBegin];
208:            }
209:
210:            public void backup(int amount) {
211:
212:                inBuf += amount;
213:                if ((bufpos -= amount) < 0)
214:                    bufpos += bufsize;
215:            }
216:
217:            public SimpleCharStream(java.io.Reader dstream, int startline,
218:                    int startcolumn, int buffersize) {
219:                inputStream = dstream;
220:                line = startline;
221:                column = startcolumn - 1;
222:
223:                available = bufsize = buffersize;
224:                buffer = new char[buffersize];
225:                bufline = new int[buffersize];
226:                bufcolumn = new int[buffersize];
227:            }
228:
229:            public SimpleCharStream(java.io.Reader dstream, int startline,
230:                    int startcolumn) {
231:                this (dstream, startline, startcolumn, 4096);
232:            }
233:
234:            public SimpleCharStream(java.io.Reader dstream) {
235:                this (dstream, 1, 1, 4096);
236:            }
237:
238:            public void ReInit(java.io.Reader dstream, int startline,
239:                    int startcolumn, int buffersize) {
240:                inputStream = dstream;
241:                line = startline;
242:                column = startcolumn - 1;
243:
244:                if (buffer == null || buffersize != buffer.length) {
245:                    available = bufsize = buffersize;
246:                    buffer = new char[buffersize];
247:                    bufline = new int[buffersize];
248:                    bufcolumn = new int[buffersize];
249:                }
250:                prevCharIsLF = prevCharIsCR = false;
251:                tokenBegin = inBuf = maxNextCharInd = 0;
252:                bufpos = -1;
253:            }
254:
255:            public void ReInit(java.io.Reader dstream, int startline,
256:                    int startcolumn) {
257:                ReInit(dstream, startline, startcolumn, 4096);
258:            }
259:
260:            public void ReInit(java.io.Reader dstream) {
261:                ReInit(dstream, 1, 1, 4096);
262:            }
263:
264:            public SimpleCharStream(java.io.InputStream dstream, int startline,
265:                    int startcolumn, int buffersize) {
266:                this (new java.io.InputStreamReader(dstream), startline,
267:                        startcolumn, 4096);
268:            }
269:
270:            public SimpleCharStream(java.io.InputStream dstream, int startline,
271:                    int startcolumn) {
272:                this (dstream, startline, startcolumn, 4096);
273:            }
274:
275:            public SimpleCharStream(java.io.InputStream dstream) {
276:                this (dstream, 1, 1, 4096);
277:            }
278:
279:            public void ReInit(java.io.InputStream dstream, int startline,
280:                    int startcolumn, int buffersize) {
281:                ReInit(new java.io.InputStreamReader(dstream), startline,
282:                        startcolumn, 4096);
283:            }
284:
285:            public void ReInit(java.io.InputStream dstream) {
286:                ReInit(dstream, 1, 1, 4096);
287:            }
288:
289:            public void ReInit(java.io.InputStream dstream, int startline,
290:                    int startcolumn) {
291:                ReInit(dstream, startline, startcolumn, 4096);
292:            }
293:
294:            public String GetImage() {
295:                if (bufpos >= tokenBegin)
296:                    return new String(buffer, tokenBegin, bufpos - tokenBegin
297:                            + 1);
298:                else
299:                    return new String(buffer, tokenBegin, bufsize - tokenBegin)
300:                            + new String(buffer, 0, bufpos + 1);
301:            }
302:
303:            public char[] GetSuffix(int len) {
304:                char[] ret = new char[len];
305:
306:                if ((bufpos + 1) >= len)
307:                    System.arraycopy(buffer, bufpos - len + 1, ret, 0, len);
308:                else {
309:                    System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret,
310:                            0, len - bufpos - 1);
311:                    System.arraycopy(buffer, 0, ret, len - bufpos - 1,
312:                            bufpos + 1);
313:                }
314:
315:                return ret;
316:            }
317:
318:            public void Done() {
319:                buffer = null;
320:                bufline = null;
321:                bufcolumn = null;
322:            }
323:
324:            /**
325:             * Method to adjust line and column numbers for the start of a token.
326:             */
327:            public void adjustBeginLineColumn(int newLine, int newCol) {
328:                int start = tokenBegin;
329:                int len;
330:
331:                if (bufpos >= tokenBegin) {
332:                    len = bufpos - tokenBegin + inBuf + 1;
333:                } else {
334:                    len = bufsize - tokenBegin + bufpos + 1 + inBuf;
335:                }
336:
337:                int i = 0, j = 0, k = 0;
338:                int nextColDiff = 0, columnDiff = 0;
339:
340:                while (i < len
341:                        && bufline[j = start % bufsize] == bufline[k = ++start
342:                                % bufsize]) {
343:                    bufline[j] = newLine;
344:                    nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j];
345:                    bufcolumn[j] = newCol + columnDiff;
346:                    columnDiff = nextColDiff;
347:                    i++;
348:                }
349:
350:                if (i < len) {
351:                    bufline[j] = newLine++;
352:                    bufcolumn[j] = newCol + columnDiff;
353:
354:                    while (i++ < len) {
355:                        if (bufline[j = start % bufsize] != bufline[++start
356:                                % bufsize])
357:                            bufline[j] = newLine++;
358:                        else
359:                            bufline[j] = newLine;
360:                    }
361:                }
362:
363:                line = bufline[j];
364:                column = bufcolumn[j];
365:            }
366:
367:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.