Source Code Cross Referenced for ACLFileReader.java in  » 6.0-JDK-Modules » j2me » com » sun » satsa » acl » 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 » 6.0 JDK Modules » j2me » com.sun.satsa.acl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *   
003:         *
004:         * Copyright  1990-2007 Sun Microsystems, Inc. All Rights Reserved.
005:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006:         * 
007:         * This program is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU General Public License version
009:         * 2 only, as published by the Free Software Foundation.
010:         * 
011:         * This program is distributed in the hope that it will be useful, but
012:         * WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014:         * General Public License version 2 for more details (a copy is
015:         * included at /legal/license.txt).
016:         * 
017:         * You should have received a copy of the GNU General Public License
018:         * version 2 along with this work; if not, write to the Free Software
019:         * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020:         * 02110-1301 USA
021:         * 
022:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023:         * Clara, CA 95054 or visit www.sun.com if you need additional
024:         * information or have any questions.
025:         */
026:
027:        package com.sun.satsa.acl;
028:
029:        import java.io.Reader;
030:        import java.io.IOException;
031:
032:        /**
033:         * This class represents file reader for file that describes access control
034:         * information.
035:         */
036:        public class ACLFileReader {
037:
038:            /**
039:             * Input data reader.
040:             */
041:            Reader in;
042:
043:            /**
044:             * Constructor.
045:             * @param r input data reader.
046:             */
047:            public ACLFileReader(Reader r) {
048:
049:                lineBuffer = new char[128];
050:                in = r;
051:            }
052:
053:            /**
054:             * Temporary data array.
055:             */
056:            char[] lineBuffer;
057:
058:            /** Horizontal Tab - Unicode character 0x09. */
059:            protected static final int HT = 0x09;
060:
061:            /** Line Feed - Unicode character 0x0A. */
062:            protected static final int LF = 0x0A;
063:
064:            /** Carrage Return - Unicode character 0x0D. */
065:            protected static final int CR = 0x0D;
066:
067:            /** End Of File - Unicode character 0x1A. */
068:            protected static final int EOF = 0x1A;
069:
070:            /** SPace - Unicode character 0x20. */
071:            protected static final int SP = 0x20;
072:
073:            /**
074:             * Current line number.
075:             */
076:            protected int lineNumber = 1;
077:
078:            /**
079:             * Temporary variable used in parsing.
080:             */
081:            protected char savedChar = 0;
082:
083:            /**
084:             * Read one word.
085:             * @return the word.
086:             * @throws IOException if I/O error occurs.
087:             */
088:            public String readWord() throws IOException {
089:
090:                if (savedChar == '{') {
091:                    savedChar = 0;
092:                    return "{";
093:                }
094:
095:                if (savedChar == '}') {
096:                    savedChar = 0;
097:                    return "}";
098:                }
099:
100:                int room = lineBuffer.length;
101:                int offset = 0;
102:                boolean comment = false;
103:                int c;
104:
105:                for (;;) {
106:                    c = in.read();
107:                    if (c == -1) {
108:                        // LF or CR LF ends a line
109:                        break;
110:                    }
111:
112:                    if (c == '#') {
113:                        comment = true;
114:                    }
115:
116:                    if (c == LF) {
117:                        lineNumber++;
118:                        comment = false;
119:                    }
120:
121:                    if (comment) {
122:                        continue;
123:                    }
124:
125:                    if (c == LF || c == CR || c == EOF || c == HT || c == SP) {
126:                        if (offset == 0) {
127:                            continue;
128:                        }
129:                        break;
130:                    }
131:
132:                    if (c == '{' || c == '}') {
133:                        if (offset == 0) {
134:                            lineBuffer[offset++] = (char) c;
135:                        } else {
136:                            savedChar = (char) c;
137:                        }
138:                        break;
139:                    }
140:
141:                    if (--room < 0) {
142:                        char[] temp = new char[offset + 128];
143:                        room = temp.length - offset - 1;
144:                        System.arraycopy(lineBuffer, 0, temp, 0, offset);
145:                        lineBuffer = temp;
146:                    }
147:
148:                    lineBuffer[offset++] = (char) c;
149:                }
150:
151:                if ((c == -1) && (offset <= 0)) {
152:                    return null;
153:                }
154:
155:                return new String(lineBuffer, 0, offset).trim();
156:            }
157:
158:            /**
159:             * Read current line without any modification.
160:             * @return the current line value.
161:             * @throws IOException if I/O error occurs.
162:             */
163:            public String readLine() throws IOException {
164:
165:                int room;
166:                int offset = 0;
167:                int c;
168:                char[] temp;
169:
170:                room = lineBuffer.length;
171:
172:                for (;;) {
173:                    c = in.read();
174:
175:                    if (c == LF) {
176:                        lineNumber++;
177:                    }
178:
179:                    if (c == -1 || c == LF) {
180:                        // LF or CR LF ends a line
181:                        break;
182:                    }
183:
184:                    /*
185:                     * throw away carrage returns and the end of file character.
186:                     */
187:                    if (c == CR || c == EOF) {
188:                        continue;
189:                    }
190:
191:                    if (--room < 0) {
192:                        temp = new char[offset + 128];
193:                        room = temp.length - offset - 1;
194:                        System.arraycopy(lineBuffer, 0, temp, 0, offset);
195:                        lineBuffer = temp;
196:                    }
197:
198:                    lineBuffer[offset++] = (char) c;
199:                }
200:
201:                if ((c == -1) && (offset <= 0)) {
202:                    return null;
203:                }
204:
205:                return new String(lineBuffer, 0, offset).trim();
206:            }
207:
208:            /**
209:             * Reads one word, converts it into unsigned byte value.
210:             * @return unsigned byte value.
211:             * @throws IOException if I/O error occurs.
212:             */
213:            public int readByte() throws IOException {
214:                return Integer.parseInt(readWord(), 16) & 0xff;
215:            }
216:
217:            /**
218:             * Check that the next word is equal to specified one.
219:             * @param s the word value.
220:             * @throws IOException if I/O error occurs.
221:             */
222:            public void checkWord(String s) throws IOException {
223:
224:                if (!readWord().equals(s)) {
225:                    throw new IOException();
226:                }
227:            }
228:
229:            /**
230:             * Returns the current line number.
231:             * @return the current line number.
232:             */
233:            public int getLineNumber() {
234:                return lineNumber;
235:            }
236:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.