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


001:        package net.sf.saxon.expr;
002:
003:        import net.sf.saxon.om.DocumentInfo;
004:        import net.sf.saxon.om.Item;
005:        import net.sf.saxon.om.NamePool;
006:        import net.sf.saxon.om.NodeInfo;
007:        import net.sf.saxon.trans.StaticError;
008:        import net.sf.saxon.trans.XPathException;
009:        import net.sf.saxon.type.ItemType;
010:        import net.sf.saxon.type.TypeHierarchy;
011:        import net.sf.saxon.pattern.NodeKindTest;
012:
013:        import java.io.PrintStream;
014:
015:        /**
016:         * An expression whose value is always a set of nodes containing a single node,
017:         * the document root. This corresponds to the XPath Expression "/", including the implicit
018:         * "/" at the start of a path expression with a leading "/".
019:         */
020:
021:        public class RootExpression extends SingleNodeExpression {
022:
023:            /**
024:             * Simplify an expression
025:             * @return the simplified expression
026:             */
027:
028:            public Expression simplify(StaticContext env) throws StaticError {
029:                return this ;
030:            }
031:
032:            /**
033:             * Is this expression the same as another expression?
034:             */
035:
036:            public boolean equals(Object other) {
037:                return (other instanceof  RootExpression);
038:            }
039:
040:            /**
041:             * Specify that the expression returns a singleton
042:             */
043:
044:            public final int computeCardinality() {
045:                return StaticProperty.EXACTLY_ONE;
046:            }
047:
048:            /**
049:             * Determine the data type of the items returned by this expression
050:             *
051:             * @return Type.NODE
052:             * @param th
053:             */
054:
055:            public ItemType getItemType(TypeHierarchy th) {
056:                return NodeKindTest.DOCUMENT;
057:            }
058:
059:            /**
060:             * get HashCode for comparing two expressions
061:             */
062:
063:            public int hashCode() {
064:                return "RootExpression".hashCode();
065:            }
066:
067:            /**
068:             * Return the first element selected by this Expression
069:             * @param context The evaluation context
070:             * @return the NodeInfo of the first selected element, or null if no element
071:             * is selected
072:             */
073:
074:            public NodeInfo getNode(XPathContext context) throws XPathException {
075:                Item current = context.getContextItem();
076:                if (current == null) {
077:                    dynamicError(
078:                            "Finding root of tree: the context item is undefined",
079:                            "XPDY0002", context);
080:                }
081:                if (current instanceof  NodeInfo) {
082:                    DocumentInfo doc = ((NodeInfo) current).getDocumentRoot();
083:                    if (doc == null) {
084:                        dynamicError(
085:                                "The root of the tree containing the context item is not a document node",
086:                                "XPDY0050", context);
087:                    }
088:                    return doc;
089:                }
090:                typeError(
091:                        "Finding root of tree: the context item is not a node",
092:                        "XPTY0020", context);
093:                // dummy return; we never get here
094:                return null;
095:            }
096:
097:            /**
098:             * Determine which aspects of the context the expression depends on. The result is
099:             * a bitwise-or'ed value composed from constants such as StaticProperty.VARIABLES and
100:             * StaticProperty.CURRENT_NODE
101:             */
102:
103:            public int getIntrinsicDependencies() {
104:                return StaticProperty.DEPENDS_ON_CONTEXT_DOCUMENT
105:                        | StaticProperty.SINGLE_DOCUMENT_NODESET
106:                        | StaticProperty.CONTEXT_DOCUMENT_NODESET;
107:            }
108:
109:            /**
110:             * Diagnostic print of expression structure
111:             */
112:
113:            public void display(int level, NamePool pool, PrintStream out) {
114:                out.println(ExpressionTool.indent(level) + '/');
115:            }
116:
117:        }
118:
119:        //
120:        // The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
121:        // you may not use this file except in compliance with the License. You may obtain a copy of the
122:        // License at http://www.mozilla.org/MPL/
123:        //
124:        // Software distributed under the License is distributed on an "AS IS" basis,
125:        // WITHOUT WARRANTY OF ANY KIND, either express or implied.
126:        // See the License for the specific language governing rights and limitations under the License.
127:        //
128:        // The Original Code is: all this file.
129:        //
130:        // The Initial Developer of the Original Code is Michael H. Kay.
131:        //
132:        // Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
133:        //
134:        // Contributor(s): none.
135:        //
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.