Source Code Cross Referenced for AbstractProcessor.java in  » 6.0-JDK-Modules-com.sun » stream-buffer » com » sun » xml » stream » buffer » 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 com.sun » stream buffer » com.sun.xml.stream.buffer 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The contents of this file are subject to the terms
003:         * of the Common Development and Distribution License
004:         * (the "License").  You may not use this file except
005:         * in compliance with the License.
006:         * 
007:         * You can obtain a copy of the license at
008:         * https://jwsdp.dev.java.net/CDDLv1.0.html
009:         * See the License for the specific language governing
010:         * permissions and limitations under the License.
011:         * 
012:         * When distributing Covered Code, include this CDDL
013:         * HEADER in each file and include the License file at
014:         * https://jwsdp.dev.java.net/CDDLv1.0.html  If applicable,
015:         * add the following below this CDDL HEADER, with the
016:         * fields enclosed by brackets "[]" replaced with your
017:         * own identifying information: Portions Copyright [yyyy]
018:         * [name of copyright owner]
019:         */
020:        package com.sun.xml.stream.buffer;
021:
022:        /**
023:         * Base class for classes that processes {@link XMLStreamBuffer}
024:         * and produces infoset in API-specific form.
025:         */
026:        public abstract class AbstractProcessor extends
027:                AbstractCreatorProcessor {
028:            protected static final int STATE_ILLEGAL = 0;
029:
030:            protected static final int STATE_DOCUMENT = 1;
031:            protected static final int STATE_DOCUMENT_FRAGMENT = 2;
032:            protected static final int STATE_ELEMENT_U_LN_QN = 3;
033:            protected static final int STATE_ELEMENT_P_U_LN = 4;
034:            protected static final int STATE_ELEMENT_U_LN = 5;
035:            protected static final int STATE_ELEMENT_LN = 6;
036:            protected static final int STATE_TEXT_AS_CHAR_ARRAY_SMALL = 7;
037:            protected static final int STATE_TEXT_AS_CHAR_ARRAY_MEDIUM = 8;
038:            protected static final int STATE_TEXT_AS_CHAR_ARRAY_COPY = 9;
039:            protected static final int STATE_TEXT_AS_STRING = 10;
040:            protected static final int STATE_TEXT_AS_OBJECT = 11;
041:            protected static final int STATE_COMMENT_AS_CHAR_ARRAY_SMALL = 12;
042:            protected static final int STATE_COMMENT_AS_CHAR_ARRAY_MEDIUM = 13;
043:            protected static final int STATE_COMMENT_AS_CHAR_ARRAY_COPY = 14;
044:            protected static final int STATE_COMMENT_AS_STRING = 15;
045:            protected static final int STATE_PROCESSING_INSTRUCTION = 16;
046:            protected static final int STATE_END = 17;
047:            protected static final int[] _eiiStateTable = new int[256];
048:
049:            protected static final int STATE_NAMESPACE_ATTRIBUTE = 1;
050:            protected static final int STATE_NAMESPACE_ATTRIBUTE_P = 2;
051:            protected static final int STATE_NAMESPACE_ATTRIBUTE_P_U = 3;
052:            protected static final int STATE_NAMESPACE_ATTRIBUTE_U = 4;
053:            protected static final int[] _niiStateTable = new int[256];
054:
055:            protected static final int STATE_ATTRIBUTE_U_LN_QN = 1;
056:            protected static final int STATE_ATTRIBUTE_P_U_LN = 2;
057:            protected static final int STATE_ATTRIBUTE_U_LN = 3;
058:            protected static final int STATE_ATTRIBUTE_LN = 4;
059:            protected static final int STATE_ATTRIBUTE_U_LN_QN_OBJECT = 5;
060:            protected static final int STATE_ATTRIBUTE_P_U_LN_OBJECT = 6;
061:            protected static final int STATE_ATTRIBUTE_U_LN_OBJECT = 7;
062:            protected static final int STATE_ATTRIBUTE_LN_OBJECT = 8;
063:            protected static final int[] _aiiStateTable = new int[256];
064:
065:            static {
066:                /*
067:                 * Create a state table from information items and options.
068:                 * The swtich statement using such states will often generate a more
069:                 * efficient byte code representation that can be hotspotted using
070:                 * jump tables.
071:                 */
072:                _eiiStateTable[T_DOCUMENT] = STATE_DOCUMENT;
073:                _eiiStateTable[T_DOCUMENT_FRAGMENT] = STATE_DOCUMENT_FRAGMENT;
074:                _eiiStateTable[T_ELEMENT_U_LN_QN] = STATE_ELEMENT_U_LN_QN;
075:                _eiiStateTable[T_ELEMENT_P_U_LN] = STATE_ELEMENT_P_U_LN;
076:                _eiiStateTable[T_ELEMENT_U_LN] = STATE_ELEMENT_U_LN;
077:                _eiiStateTable[T_ELEMENT_LN] = STATE_ELEMENT_LN;
078:                _eiiStateTable[T_TEXT_AS_CHAR_ARRAY_SMALL] = STATE_TEXT_AS_CHAR_ARRAY_SMALL;
079:                _eiiStateTable[T_TEXT_AS_CHAR_ARRAY_MEDIUM] = STATE_TEXT_AS_CHAR_ARRAY_MEDIUM;
080:                _eiiStateTable[T_TEXT_AS_CHAR_ARRAY_COPY] = STATE_TEXT_AS_CHAR_ARRAY_COPY;
081:                _eiiStateTable[T_TEXT_AS_STRING] = STATE_TEXT_AS_STRING;
082:                _eiiStateTable[T_TEXT_AS_OBJECT] = STATE_TEXT_AS_OBJECT;
083:                _eiiStateTable[T_COMMENT_AS_CHAR_ARRAY_SMALL] = STATE_COMMENT_AS_CHAR_ARRAY_SMALL;
084:                _eiiStateTable[T_COMMENT_AS_CHAR_ARRAY_MEDIUM] = STATE_COMMENT_AS_CHAR_ARRAY_MEDIUM;
085:                _eiiStateTable[T_COMMENT_AS_CHAR_ARRAY_COPY] = STATE_COMMENT_AS_CHAR_ARRAY_COPY;
086:                _eiiStateTable[T_COMMENT_AS_STRING] = STATE_COMMENT_AS_STRING;
087:                _eiiStateTable[T_PROCESSING_INSTRUCTION] = STATE_PROCESSING_INSTRUCTION;
088:                _eiiStateTable[T_END] = STATE_END;
089:
090:                _niiStateTable[T_NAMESPACE_ATTRIBUTE] = STATE_NAMESPACE_ATTRIBUTE;
091:                _niiStateTable[T_NAMESPACE_ATTRIBUTE_P] = STATE_NAMESPACE_ATTRIBUTE_P;
092:                _niiStateTable[T_NAMESPACE_ATTRIBUTE_P_U] = STATE_NAMESPACE_ATTRIBUTE_P_U;
093:                _niiStateTable[T_NAMESPACE_ATTRIBUTE_U] = STATE_NAMESPACE_ATTRIBUTE_U;
094:
095:                _aiiStateTable[T_ATTRIBUTE_U_LN_QN] = STATE_ATTRIBUTE_U_LN_QN;
096:                _aiiStateTable[T_ATTRIBUTE_P_U_LN] = STATE_ATTRIBUTE_P_U_LN;
097:                _aiiStateTable[T_ATTRIBUTE_U_LN] = STATE_ATTRIBUTE_U_LN;
098:                _aiiStateTable[T_ATTRIBUTE_LN] = STATE_ATTRIBUTE_LN;
099:                _aiiStateTable[T_ATTRIBUTE_U_LN_QN_OBJECT] = STATE_ATTRIBUTE_U_LN_QN_OBJECT;
100:                _aiiStateTable[T_ATTRIBUTE_P_U_LN_OBJECT] = STATE_ATTRIBUTE_P_U_LN_OBJECT;
101:                _aiiStateTable[T_ATTRIBUTE_U_LN_OBJECT] = STATE_ATTRIBUTE_U_LN_OBJECT;
102:                _aiiStateTable[T_ATTRIBUTE_LN_OBJECT] = STATE_ATTRIBUTE_LN_OBJECT;
103:            }
104:
105:            protected XMLStreamBuffer _buffer;
106:
107:            /**
108:             * True if this processor should create a fragment of XML, without the start/end document markers.
109:             */
110:            protected boolean _fragmentMode;
111:
112:            protected boolean _stringInterningFeature = false;
113:
114:            /**
115:             * Number of remaining XML element trees that should be visible
116:             * through this {@link AbstractProcessor}.
117:             */
118:            protected int _treeCount;
119:
120:            /**
121:             * @deprecated
122:             *      Use {@link #setBuffer(XMLStreamBuffer, boolean)}
123:             */
124:            protected final void setBuffer(XMLStreamBuffer buffer) {
125:                setBuffer(buffer, buffer.isFragment());
126:            }
127:
128:            protected final void setBuffer(XMLStreamBuffer buffer,
129:                    boolean fragmentMode) {
130:                _buffer = buffer;
131:                _fragmentMode = fragmentMode;
132:
133:                _currentStructureFragment = _buffer.getStructure();
134:                _structure = _currentStructureFragment.getArray();
135:                _structurePtr = _buffer.getStructurePtr();
136:
137:                _currentStructureStringFragment = _buffer.getStructureStrings();
138:                _structureStrings = _currentStructureStringFragment.getArray();
139:                _structureStringsPtr = _buffer.getStructureStringsPtr();
140:
141:                _currentContentCharactersBufferFragment = _buffer
142:                        .getContentCharactersBuffer();
143:                _contentCharactersBuffer = _currentContentCharactersBufferFragment
144:                        .getArray();
145:                _contentCharactersBufferPtr = _buffer
146:                        .getContentCharactersBufferPtr();
147:
148:                _currentContentObjectFragment = _buffer.getContentObjects();
149:                _contentObjects = _currentContentObjectFragment.getArray();
150:                _contentObjectsPtr = _buffer.getContentObjectsPtr();
151:
152:                _stringInterningFeature = _buffer.hasInternedStrings();
153:                _treeCount = _buffer.treeCount;
154:            }
155:
156:            protected final int peekStructure() {
157:                if (_structurePtr < _structure.length) {
158:                    return _structure[_structurePtr] & 255;
159:                }
160:
161:                return readFromNextStructure(0);
162:            }
163:
164:            protected final int readStructure() {
165:                if (_structurePtr < _structure.length) {
166:                    return _structure[_structurePtr++] & 255;
167:                }
168:
169:                return readFromNextStructure(1);
170:            }
171:
172:            protected final int readEiiState() {
173:                return _eiiStateTable[readStructure()];
174:            }
175:
176:            protected final int readStructure16() {
177:                return (readStructure() << 8) | readStructure();
178:            }
179:
180:            private int readFromNextStructure(int v) {
181:                _structurePtr = v;
182:                _currentStructureFragment = _currentStructureFragment.getNext();
183:                _structure = _currentStructureFragment.getArray();
184:                return _structure[0] & 255;
185:            }
186:
187:            protected final String readStructureString() {
188:                if (_structureStringsPtr < _structureStrings.length) {
189:                    return _structureStrings[_structureStringsPtr++];
190:                }
191:
192:                _structureStringsPtr = 1;
193:                _currentStructureStringFragment = _currentStructureStringFragment
194:                        .getNext();
195:                _structureStrings = _currentStructureStringFragment.getArray();
196:                return _structureStrings[0];
197:            }
198:
199:            protected final String readContentString() {
200:                return (String) readContentObject();
201:            }
202:
203:            protected final char[] readContentCharactersCopy() {
204:                return (char[]) readContentObject();
205:            }
206:
207:            protected final int readContentCharactersBuffer(int length) {
208:                if (_contentCharactersBufferPtr + length < _contentCharactersBuffer.length) {
209:                    final int start = _contentCharactersBufferPtr;
210:                    _contentCharactersBufferPtr += length;
211:                    return start;
212:                }
213:
214:                _contentCharactersBufferPtr = length;
215:                _currentContentCharactersBufferFragment = _currentContentCharactersBufferFragment
216:                        .getNext();
217:                _contentCharactersBuffer = _currentContentCharactersBufferFragment
218:                        .getArray();
219:                return 0;
220:            }
221:
222:            protected final Object readContentObject() {
223:                if (_contentObjectsPtr < _contentObjects.length) {
224:                    return _contentObjects[_contentObjectsPtr++];
225:                }
226:
227:                _contentObjectsPtr = 1;
228:                _currentContentObjectFragment = _currentContentObjectFragment
229:                        .getNext();
230:                _contentObjects = _currentContentObjectFragment.getArray();
231:                return _contentObjects[0];
232:            }
233:
234:            protected final StringBuilder _qNameBuffer = new StringBuilder();
235:
236:            protected final String getQName(String prefix, String localName) {
237:                _qNameBuffer.append(prefix).append(':').append(localName);
238:                final String qName = _qNameBuffer.toString();
239:                _qNameBuffer.setLength(0);
240:                return (_stringInterningFeature) ? qName.intern() : qName;
241:            }
242:
243:            protected final String getPrefixFromQName(String qName) {
244:                int pIndex = qName.indexOf(':');
245:                if (_stringInterningFeature) {
246:                    return (pIndex != -1) ? qName.substring(0, pIndex).intern()
247:                            : "";
248:                } else {
249:                    return (pIndex != -1) ? qName.substring(0, pIndex) : "";
250:                }
251:            }
252:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.