Source Code Cross Referenced for NullElementPointer.java in  » Library » Apache-commons-jxpath-1.2-src » org » apache » commons » jxpath » ri » model » beans » 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 » Library » Apache commons jxpath 1.2 src » org.apache.commons.jxpath.ri.model.beans 
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:        package org.apache.commons.jxpath.ri.model.beans;
017:
018:        import org.apache.commons.jxpath.JXPathContext;
019:        import org.apache.commons.jxpath.ri.QName;
020:        import org.apache.commons.jxpath.ri.model.NodePointer;
021:
022:        /**
023:         * Used when there is a need to construct a Pointer for a collection element
024:         * that does not exist.  For example, if the path is "foo[3]", but the
025:         * collection "foo" only has one element or is empty or is null, the
026:         * NullElementPointer can be used to capture this situation without putting a
027:         * regular NodePointer into an invalid state.  Just create a NullElementPointer
028:         * with index 2 (= 3 - 1) and a "foo" pointer as the parent.
029:         *
030:         * @author Dmitri Plotnikov
031:         * @version $Revision: 1.17 $ $Date: 2004/03/25 03:49:50 $
032:         */
033:        public class NullElementPointer extends CollectionPointer {
034:
035:            public NullElementPointer(NodePointer parent, int index) {
036:                super (parent, (Object) null);
037:                this .index = index;
038:            }
039:
040:            public QName getName() {
041:                return null;
042:            }
043:
044:            public Object getBaseValue() {
045:                return null;
046:            }
047:
048:            public Object getImmediateNode() {
049:                return null;
050:            }
051:
052:            public boolean isLeaf() {
053:                return true;
054:            }
055:
056:            public boolean isCollection() {
057:                return false;
058:            }
059:
060:            public PropertyPointer getPropertyPointer() {
061:                return new NullPropertyPointer(this );
062:            }
063:
064:            public NodePointer getValuePointer() {
065:                return new NullPointer(this , getName());
066:            }
067:
068:            public void setValue(Object value) {
069:                throw new UnsupportedOperationException(
070:                        "Collection element does not exist: " + this );
071:            }
072:
073:            public boolean isActual() {
074:                return false;
075:            }
076:
077:            public boolean isContainer() {
078:                return true;
079:            }
080:
081:            public NodePointer createPath(JXPathContext context) {
082:                return parent.createChild(context, null, index);
083:            }
084:
085:            public NodePointer createPath(JXPathContext context, Object value) {
086:                return parent.createChild(context, null, index, value);
087:            }
088:
089:            public int hashCode() {
090:                return getImmediateParentPointer().hashCode() + index;
091:            }
092:
093:            public boolean equals(Object object) {
094:                if (object == this ) {
095:                    return true;
096:                }
097:
098:                if (!(object instanceof  NullElementPointer)) {
099:                    return false;
100:                }
101:
102:                NullElementPointer other = (NullElementPointer) object;
103:                return getImmediateParentPointer() == other
104:                        .getImmediateParentPointer()
105:                        && index == other.index;
106:            }
107:
108:            public int getLength() {
109:                return 0;
110:            }
111:
112:            public String asPath() {
113:                StringBuffer buffer = new StringBuffer();
114:                NodePointer parent = getImmediateParentPointer();
115:                if (parent != null) {
116:                    buffer.append(parent.asPath());
117:                }
118:                if (index != WHOLE_COLLECTION) {
119:                    // Address the list[1][2] case
120:                    if (parent != null && parent.getIndex() != WHOLE_COLLECTION) {
121:                        buffer.append("/.");
122:                    } else if (parent != null
123:                            && parent.getImmediateParentPointer() != null
124:                            && parent.getImmediateParentPointer().getIndex() != WHOLE_COLLECTION) {
125:                        buffer.append("/.");
126:                    }
127:                    buffer.append("[").append(index + 1).append(']');
128:                }
129:
130:                return buffer.toString();
131:            }
132:        }
w_w__w_.__j_a__v_a__2__s__.c___om__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.