Source Code Cross Referenced for SimpleCharStream.java in  » Workflow-Engines » jbpm-jpdl-3.2.2 » org » jbpm » jpdl » el » 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 » jbpm jpdl 3.2.2 » org.jbpm.jpdl.el.parser 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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