Source Code Cross Referenced for UnionChildIterator.java in  » XML » xalan » org » apache » xpath » axes » 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.axes 
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: UnionChildIterator.java,v 1.6 2004/08/17 19:25:34 jycli Exp $
018:         */
019:        package org.apache.xpath.axes;
020:
021:        import org.apache.xml.dtm.DTMIterator;
022:        import org.apache.xpath.XPathContext;
023:        import org.apache.xpath.objects.XObject;
024:        import org.apache.xpath.patterns.NodeTest;
025:
026:        /**
027:         * This class defines a simplified type of union iterator that only 
028:         * tests along the child axes.  If the conditions are right, it is 
029:         * much faster than using a UnionPathIterator.
030:         */
031:        public class UnionChildIterator extends ChildTestIterator {
032:            static final long serialVersionUID = 3500298482193003495L;
033:            /**
034:             * Even though these may hold full LocPathIterators, this array does 
035:             * not have to be cloned, since only the node test and predicate 
036:             * portion are used, and these only need static information.  However, 
037:             * also note that index predicates can not be used!
038:             */
039:            private PredicatedNodeTest[] m_nodeTests = null;
040:
041:            /**
042:             * Constructor for UnionChildIterator
043:             */
044:            public UnionChildIterator() {
045:                super (null);
046:            }
047:
048:            /**
049:             * Add a node test to the union list.
050:             *
051:             * @param test reference to a NodeTest, which will be added 
052:             * directly to the list of node tests (in other words, it will 
053:             * not be cloned).  The parent of this test will be set to 
054:             * this object.
055:             */
056:            public void addNodeTest(PredicatedNodeTest test) {
057:
058:                // Increase array size by only 1 at a time.  Fix this
059:                // if it looks to be a problem.
060:                if (null == m_nodeTests) {
061:                    m_nodeTests = new PredicatedNodeTest[1];
062:                    m_nodeTests[0] = test;
063:                } else {
064:                    PredicatedNodeTest[] tests = m_nodeTests;
065:                    int len = m_nodeTests.length;
066:
067:                    m_nodeTests = new PredicatedNodeTest[len + 1];
068:
069:                    System.arraycopy(tests, 0, m_nodeTests, 0, len);
070:
071:                    m_nodeTests[len] = test;
072:                }
073:                test.exprSetParent(this );
074:            }
075:
076:            /**
077:             * This function is used to fixup variables from QNames to stack frame 
078:             * indexes at stylesheet build time.
079:             * @param vars List of QNames that correspond to variables.  This list 
080:             * should be searched backwards for the first qualified name that 
081:             * corresponds to the variable reference qname.  The position of the 
082:             * QName in the vector from the start of the vector will be its position 
083:             * in the stack frame (but variables above the globalsTop value will need 
084:             * to be offset to the current stack frame).
085:             */
086:            public void fixupVariables(java.util.Vector vars, int globalsSize) {
087:                super .fixupVariables(vars, globalsSize);
088:                if (m_nodeTests != null) {
089:                    for (int i = 0; i < m_nodeTests.length; i++) {
090:                        m_nodeTests[i].fixupVariables(vars, globalsSize);
091:                    }
092:                }
093:            }
094:
095:            /**
096:             * Test whether a specified node is visible in the logical view of a
097:             * TreeWalker or NodeIterator. This function will be called by the
098:             * implementation of TreeWalker and NodeIterator; it is not intended to
099:             * be called directly from user code.
100:             * @param n  The node to check to see if it passes the filter or not.
101:             * @return  a constant to determine whether the node is accepted,
102:             *   rejected, or skipped, as defined  above .
103:             */
104:            public short acceptNode(int n) {
105:                XPathContext xctxt = getXPathContext();
106:                try {
107:                    xctxt.pushCurrentNode(n);
108:                    for (int i = 0; i < m_nodeTests.length; i++) {
109:                        PredicatedNodeTest pnt = m_nodeTests[i];
110:                        XObject score = pnt.execute(xctxt, n);
111:                        if (score != NodeTest.SCORE_NONE) {
112:                            // Note that we are assuming there are no positional predicates!
113:                            if (pnt.getPredicateCount() > 0) {
114:                                if (pnt.executePredicates(n, xctxt))
115:                                    return DTMIterator.FILTER_ACCEPT;
116:                            } else
117:                                return DTMIterator.FILTER_ACCEPT;
118:
119:                        }
120:                    }
121:                } catch (javax.xml.transform.TransformerException se) {
122:
123:                    // TODO: Fix this.
124:                    throw new RuntimeException(se.getMessage());
125:                } finally {
126:                    xctxt.popCurrentNode();
127:                }
128:                return DTMIterator.FILTER_SKIP;
129:            }
130:
131:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.