Source Code Cross Referenced for AbstractCreator.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 creates {@link MutableXMLStreamBuffer}
024:         * and from infoset in API-specific form.
025:         */
026:        public class AbstractCreator extends AbstractCreatorProcessor {
027:
028:            protected MutableXMLStreamBuffer _buffer;
029:
030:            public void setXMLStreamBuffer(MutableXMLStreamBuffer buffer) {
031:                if (buffer == null) {
032:                    throw new NullPointerException("buffer cannot be null");
033:                }
034:                setBuffer(buffer);
035:            }
036:
037:            public MutableXMLStreamBuffer getXMLStreamBuffer() {
038:                return _buffer;
039:            }
040:
041:            protected final void createBuffer() {
042:                setBuffer(new MutableXMLStreamBuffer());
043:            }
044:
045:            /**
046:             * Should be called whenever a new tree is stored on the buffer.
047:             */
048:            protected final void increaseTreeCount() {
049:                _buffer.treeCount++;
050:            }
051:
052:            protected final void setBuffer(MutableXMLStreamBuffer buffer) {
053:                _buffer = buffer;
054:
055:                _currentStructureFragment = _buffer.getStructure();
056:                _structure = _currentStructureFragment.getArray();
057:                _structurePtr = 0;
058:
059:                _currentStructureStringFragment = _buffer.getStructureStrings();
060:                _structureStrings = _currentStructureStringFragment.getArray();
061:                _structureStringsPtr = 0;
062:
063:                _currentContentCharactersBufferFragment = _buffer
064:                        .getContentCharactersBuffer();
065:                _contentCharactersBuffer = _currentContentCharactersBufferFragment
066:                        .getArray();
067:                _contentCharactersBufferPtr = 0;
068:
069:                _currentContentObjectFragment = _buffer.getContentObjects();
070:                _contentObjects = _currentContentObjectFragment.getArray();
071:                _contentObjectsPtr = 0;
072:            }
073:
074:            protected final void setHasInternedStrings(
075:                    boolean hasInternedStrings) {
076:                _buffer.setHasInternedStrings(hasInternedStrings);
077:            }
078:
079:            protected final void storeStructure(int b) {
080:                _structure[_structurePtr++] = (byte) b;
081:                if (_structurePtr == _structure.length) {
082:                    resizeStructure();
083:                }
084:            }
085:
086:            protected final void resizeStructure() {
087:                _structurePtr = 0;
088:                if (_currentStructureFragment.getNext() != null) {
089:                    _currentStructureFragment = _currentStructureFragment
090:                            .getNext();
091:                    _structure = _currentStructureFragment.getArray();
092:                } else {
093:                    _structure = new byte[_structure.length];
094:                    _currentStructureFragment = new FragmentedArray(_structure,
095:                            _currentStructureFragment);
096:                }
097:            }
098:
099:            protected final void storeStructureString(String s) {
100:                _structureStrings[_structureStringsPtr++] = s;
101:                if (_structureStringsPtr == _structureStrings.length) {
102:                    resizeStructureStrings();
103:                }
104:            }
105:
106:            protected final void resizeStructureStrings() {
107:                _structureStringsPtr = 0;
108:                if (_currentStructureStringFragment.getNext() != null) {
109:                    _currentStructureStringFragment = _currentStructureStringFragment
110:                            .getNext();
111:                    _structureStrings = _currentStructureStringFragment
112:                            .getArray();
113:                } else {
114:                    _structureStrings = new String[_structureStrings.length];
115:                    _currentStructureStringFragment = new FragmentedArray(
116:                            _structureStrings, _currentStructureStringFragment);
117:                }
118:            }
119:
120:            protected final void storeContentString(String s) {
121:                storeContentObject(s);
122:            }
123:
124:            protected final void storeContentCharacters(int type, char[] ch,
125:                    int start, int length) {
126:                if (_contentCharactersBufferPtr + length >= _contentCharactersBuffer.length) {
127:                    if (length >= 512) {
128:                        storeStructure(type | CONTENT_TYPE_CHAR_ARRAY_COPY);
129:                        storeContentCharactersCopy(ch, start, length);
130:                        return;
131:                    }
132:                    resizeContentCharacters();
133:                }
134:
135:                if (length < CHAR_ARRAY_LENGTH_SMALL_SIZE) {
136:                    storeStructure(type | CHAR_ARRAY_LENGTH_SMALL);
137:                    storeStructure(length);
138:                    System.arraycopy(ch, start, _contentCharactersBuffer,
139:                            _contentCharactersBufferPtr, length);
140:                    _contentCharactersBufferPtr += length;
141:                } else if (length < CHAR_ARRAY_LENGTH_MEDIUM_SIZE) {
142:                    storeStructure(type | CHAR_ARRAY_LENGTH_MEDIUM);
143:                    storeStructure(length >> 8);
144:                    storeStructure(length & 255);
145:                    System.arraycopy(ch, start, _contentCharactersBuffer,
146:                            _contentCharactersBufferPtr, length);
147:                    _contentCharactersBufferPtr += length;
148:                } else {
149:                    storeStructure(type | CONTENT_TYPE_CHAR_ARRAY_COPY);
150:                    storeContentCharactersCopy(ch, start, length);
151:                }
152:            }
153:
154:            protected final void resizeContentCharacters() {
155:                _contentCharactersBufferPtr = 0;
156:                if (_currentContentCharactersBufferFragment.getNext() != null) {
157:                    _currentContentCharactersBufferFragment = _currentContentCharactersBufferFragment
158:                            .getNext();
159:                    _contentCharactersBuffer = _currentContentCharactersBufferFragment
160:                            .getArray();
161:                } else {
162:                    _contentCharactersBuffer = new char[_contentCharactersBuffer.length];
163:                    _currentContentCharactersBufferFragment = new FragmentedArray(
164:                            _contentCharactersBuffer,
165:                            _currentContentCharactersBufferFragment);
166:                }
167:            }
168:
169:            protected final void storeContentCharactersCopy(char[] ch,
170:                    int start, int length) {
171:                char[] copyOfCh = new char[length];
172:                System.arraycopy(ch, start, copyOfCh, 0, length);
173:                storeContentObject(copyOfCh);
174:            }
175:
176:            protected final Object peekAtContentObject() {
177:                return _contentObjects[_contentObjectsPtr];
178:            }
179:
180:            protected final void storeContentObject(Object s) {
181:                _contentObjects[_contentObjectsPtr++] = s;
182:                if (_contentObjectsPtr == _contentObjects.length) {
183:                    resizeContentObjects();
184:                }
185:            }
186:
187:            protected final void resizeContentObjects() {
188:                _contentObjectsPtr = 0;
189:                if (_currentContentObjectFragment.getNext() != null) {
190:                    _currentContentObjectFragment = _currentContentObjectFragment
191:                            .getNext();
192:                    _contentObjects = _currentContentObjectFragment.getArray();
193:                } else {
194:                    _contentObjects = new Object[_contentObjects.length];
195:                    _currentContentObjectFragment = new FragmentedArray(
196:                            _contentObjects, _currentContentObjectFragment);
197:                }
198:            }
199:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.