Source Code Cross Referenced for XStringForChars.java in  » XML » xalan » org » apache » xpath » objects » 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 » XML » xalan » org.apache.xpath.objects 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 1999-2004 The Apache Software Foundation.
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         *     http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:        /*
017:         * $Id: XStringForChars.java,v 1.9 2004/08/17 19:25:40 jycli Exp $
018:         */
019:        package org.apache.xpath.objects;
020:
021:        import org.apache.xalan.res.XSLMessages;
022:        import org.apache.xml.utils.FastStringBuffer;
023:        import org.apache.xpath.res.XPATHErrorResources;
024:
025:        /**
026:         * This class will wrap a FastStringBuffer and allow for
027:         */
028:        public class XStringForChars extends XString {
029:            static final long serialVersionUID = -2235248887220850467L;
030:            /** The start position in the fsb. */
031:            int m_start;
032:
033:            /** The length of the string. */
034:            int m_length;
035:
036:            protected String m_strCache = null;
037:
038:            /**
039:             * Construct a XNodeSet object.
040:             *
041:             * @param val FastStringBuffer object this will wrap, must be non-null.
042:             * @param start The start position in the array.
043:             * @param length The number of characters to read from the array.
044:             */
045:            public XStringForChars(char[] val, int start, int length) {
046:                super (val);
047:                m_start = start;
048:                m_length = length;
049:                if (null == val)
050:                    throw new IllegalArgumentException(
051:                            XSLMessages
052:                                    .createXPATHMessage(
053:                                            XPATHErrorResources.ER_FASTSTRINGBUFFER_CANNOT_BE_NULL,
054:                                            null)); //"The FastStringBuffer argument can not be null!!");
055:            }
056:
057:            /**
058:             * Construct a XNodeSet object.
059:             *
060:             * @param val String object this will wrap.
061:             */
062:            private XStringForChars(String val) {
063:                super (val);
064:                throw new IllegalArgumentException(
065:                        XSLMessages
066:                                .createXPATHMessage(
067:                                        XPATHErrorResources.ER_XSTRINGFORCHARS_CANNOT_TAKE_STRING,
068:                                        null)); //"XStringForChars can not take a string for an argument!");
069:            }
070:
071:            /**
072:             * Cast result object to a string.
073:             *
074:             * @return The string this wraps or the empty string if null
075:             */
076:            public FastStringBuffer fsb() {
077:                throw new RuntimeException(
078:                        XSLMessages
079:                                .createXPATHMessage(
080:                                        XPATHErrorResources.ER_FSB_NOT_SUPPORTED_XSTRINGFORCHARS,
081:                                        null)); //"fsb() not supported for XStringForChars!");
082:            }
083:
084:            /**
085:             * Cast result object to a string.
086:             *
087:             * @return The string this wraps or the empty string if null
088:             */
089:            public void appendToFsb(org.apache.xml.utils.FastStringBuffer fsb) {
090:                fsb.append((char[]) m_obj, m_start, m_length);
091:            }
092:
093:            /**
094:             * Tell if this object contains a java String object.
095:             * 
096:             * @return true if this XMLString can return a string without creating one.
097:             */
098:            public boolean hasString() {
099:                return (null != m_strCache);
100:            }
101:
102:            /**
103:             * Cast result object to a string.
104:             *
105:             * @return The string this wraps or the empty string if null
106:             */
107:            public String str() {
108:                if (null == m_strCache)
109:                    m_strCache = new String((char[]) m_obj, m_start, m_length);
110:
111:                return m_strCache;
112:            }
113:
114:            /**
115:             * Since this object is incomplete without the length and the offset, we 
116:             * have to convert to a string when this function is called.
117:             *
118:             * @return The java String representation of this object.
119:             */
120:            public Object object() {
121:                return str();
122:            }
123:
124:            /**
125:             * Directly call the
126:             * characters method on the passed ContentHandler for the
127:             * string-value. Multiple calls to the
128:             * ContentHandler's characters methods may well occur for a single call to
129:             * this method.
130:             *
131:             * @param ch A non-null reference to a ContentHandler.
132:             *
133:             * @throws org.xml.sax.SAXException
134:             */
135:            public void dispatchCharactersEvents(org.xml.sax.ContentHandler ch)
136:                    throws org.xml.sax.SAXException {
137:                ch.characters((char[]) m_obj, m_start, m_length);
138:            }
139:
140:            /**
141:             * Directly call the
142:             * comment method on the passed LexicalHandler for the
143:             * string-value.
144:             *
145:             * @param lh A non-null reference to a LexicalHandler.
146:             *
147:             * @throws org.xml.sax.SAXException
148:             */
149:            public void dispatchAsComment(org.xml.sax.ext.LexicalHandler lh)
150:                    throws org.xml.sax.SAXException {
151:                lh.comment((char[]) m_obj, m_start, m_length);
152:            }
153:
154:            /**
155:             * Returns the length of this string.
156:             *
157:             * @return  the length of the sequence of characters represented by this
158:             *          object.
159:             */
160:            public int length() {
161:                return m_length;
162:            }
163:
164:            /**
165:             * Returns the character at the specified index. An index ranges
166:             * from <code>0</code> to <code>length() - 1</code>. The first character
167:             * of the sequence is at index <code>0</code>, the next at index
168:             * <code>1</code>, and so on, as for array indexing.
169:             *
170:             * @param      index   the index of the character.
171:             * @return     the character at the specified index of this string.
172:             *             The first character is at index <code>0</code>.
173:             * @exception  IndexOutOfBoundsException  if the <code>index</code>
174:             *             argument is negative or not less than the length of this
175:             *             string.
176:             */
177:            public char charAt(int index) {
178:                return ((char[]) m_obj)[index + m_start];
179:            }
180:
181:            /**
182:             * Copies characters from this string into the destination character
183:             * array.
184:             *
185:             * @param      srcBegin   index of the first character in the string
186:             *                        to copy.
187:             * @param      srcEnd     index after the last character in the string
188:             *                        to copy.
189:             * @param      dst        the destination array.
190:             * @param      dstBegin   the start offset in the destination array.
191:             * @exception IndexOutOfBoundsException If any of the following
192:             *            is true:
193:             *            <ul><li><code>srcBegin</code> is negative.
194:             *            <li><code>srcBegin</code> is greater than <code>srcEnd</code>
195:             *            <li><code>srcEnd</code> is greater than the length of this
196:             *                string
197:             *            <li><code>dstBegin</code> is negative
198:             *            <li><code>dstBegin+(srcEnd-srcBegin)</code> is larger than
199:             *                <code>dst.length</code></ul>
200:             * @exception NullPointerException if <code>dst</code> is <code>null</code>
201:             */
202:            public void getChars(int srcBegin, int srcEnd, char dst[],
203:                    int dstBegin) {
204:                System.arraycopy((char[]) m_obj, m_start + srcBegin, dst,
205:                        dstBegin, srcEnd);
206:            }
207:
208:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.