Source Code Cross Referenced for Sets.java in  » XML » XPath-Saxon » net » sf » saxon » exslt » 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 » XPath Saxon » net.sf.saxon.exslt 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.sf.saxon.exslt;
002:
003:        import net.sf.saxon.expr.*;
004:        import net.sf.saxon.om.Item;
005:        import net.sf.saxon.om.NodeInfo;
006:        import net.sf.saxon.om.SequenceIterator;
007:        import net.sf.saxon.sort.GlobalOrderComparer;
008:        import net.sf.saxon.trans.DynamicError;
009:        import net.sf.saxon.trans.XPathException;
010:        import net.sf.saxon.value.SingletonNode;
011:
012:        /**
013:         * This class implements extension functions in the
014:         * http://exslt.org/sets namespace. <p>
015:         */
016:
017:        public abstract class Sets {
018:
019:            private Sets() {
020:            }
021:
022:            /**
023:             * Return the intersection of two node-sets
024:             * @param p1 The first node-set
025:             * @param p2 The second node-set
026:             * @return A node-set containing all nodes that are in both p1 and p2
027:             */
028:
029:            public static SequenceIterator intersection(SequenceIterator p1,
030:                    SequenceIterator p2) throws XPathException {
031:                return new IntersectionEnumeration(p1, p2, GlobalOrderComparer
032:                        .getInstance());
033:            }
034:
035:            /**
036:             * Return the difference of two node-sets
037:             * @param p1 The first node-set
038:             * @param p2 The second node-set
039:             * @return A node-set containing all nodes that are in p1 and not in p2
040:             */
041:
042:            public static SequenceIterator difference(SequenceIterator p1,
043:                    SequenceIterator p2) throws XPathException {
044:                return new DifferenceEnumeration(p1, p2, GlobalOrderComparer
045:                        .getInstance());
046:            }
047:
048:            /**
049:             * Determine whether two node-sets contain at least one node in common
050:             * @param p1 The first node-set
051:             * @param p2 The second node-set
052:             * @return true if p1 and p2 contain at least one node in common (i.e. if the intersection
053:             * is not empty)
054:             */
055:
056:            public static boolean hasSameNode(SequenceIterator p1,
057:                    SequenceIterator p2) throws XPathException {
058:                SequenceIterator intersection = new IntersectionEnumeration(p1,
059:                        p2, GlobalOrderComparer.getInstance());
060:                return intersection.next() != null;
061:            }
062:
063:            /**
064:             * Find all the nodes in ns1 that are before the first node in ns2.
065:             * Return empty set if ns2 is empty,
066:             */
067:
068:            public static SequenceIterator leading(XPathContext context,
069:                    SequenceIterator ns1, SequenceIterator ns2)
070:                    throws XPathException {
071:
072:                NodeInfo first = null;
073:
074:                // Find the first node in ns2 (in document order)
075:
076:                GlobalOrderComparer comparer = GlobalOrderComparer
077:                        .getInstance();
078:                while (true) {
079:                    Item item = ns2.next();
080:                    if (item == null) {
081:                        if (first == null) {
082:                            return ns1;
083:                        }
084:                        break;
085:                    }
086:                    if (item instanceof  NodeInfo) {
087:                        NodeInfo node = (NodeInfo) item;
088:                        if (first == null) {
089:                            first = node;
090:                        } else {
091:                            if (comparer.compare(node, first) < 0) {
092:                                first = node;
093:                            }
094:                        }
095:                    } else {
096:                        DynamicError e = new DynamicError(
097:                                "Operand of leading() contains an item that is not a node");
098:                        e.setXPathContext(context);
099:                        throw e;
100:                    }
101:                }
102:
103:                // Filter ns1 to select nodes that come before this one
104:
105:                Expression filter = new IdentityComparison(
106:                        new ContextItemExpression(), Token.PRECEDES,
107:                        new SingletonNode(first));
108:
109:                return new FilterIterator(ns1, filter, context);
110:
111:            }
112:
113:            /**
114:             * Find all the nodes in ns1 that are after the first node in ns2.
115:             * Return empty set if ns2 is empty,
116:             */
117:
118:            public static SequenceIterator trailing(XPathContext c,
119:                    SequenceIterator ns1, SequenceIterator ns2)
120:                    throws XPathException {
121:
122:                return net.sf.saxon.functions.Extensions.after(c, ns1, ns2);
123:            }
124:
125:        }
126:
127:        //
128:        // The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
129:        // you may not use this file except in compliance with the License. You may obtain a copy of the
130:        // License at http://www.mozilla.org/MPL/
131:        //
132:        // Software distributed under the License is distributed on an "AS IS" basis,
133:        // WITHOUT WARRANTY OF ANY KIND, either express or implied.
134:        // See the License for the specific language governing rights and limitations under the License.
135:        //
136:        // The Original Code is: all this file.
137:        //
138:        // The Initial Developer of the Original Code is Michael H. Kay.
139:        //
140:        // Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
141:        //
142:        // Contributor(s): none.
143:        //
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.