Source Code Cross Referenced for SimpleCharStream.java in  » Portal » Open-Portal » com » sun » portal » rproxy » connectionhandler » webdav » 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 » Portal » Open Portal » com.sun.portal.rproxy.connectionhandler.webdav 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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