Source Code Cross Referenced for XPathUtils.java in  » IDE-Netbeans » xml » org » netbeans » modules » xml » xpath » ext » 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 » IDE Netbeans » xml » org.netbeans.modules.xml.xpath.ext 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Utils.java
003:         * 
004:         * Created on 31.08.2007, 15:40:45
005:         * 
006:         * To change this template, choose Tools | Templates
007:         * and open the template in the editor.
008:         */
009:
010:        package org.netbeans.modules.xml.xpath.ext;
011:
012:        import javax.xml.namespace.NamespaceContext;
013:        import javax.xml.namespace.QName;
014:        import org.netbeans.modules.xml.schema.model.ElementReference;
015:        import org.netbeans.modules.xml.schema.model.Form;
016:        import org.netbeans.modules.xml.schema.model.GlobalAttribute;
017:        import org.netbeans.modules.xml.schema.model.GlobalElement;
018:        import org.netbeans.modules.xml.schema.model.LocalAttribute;
019:        import org.netbeans.modules.xml.schema.model.LocalElement;
020:        import org.netbeans.modules.xml.schema.model.SchemaComponent;
021:
022:        /**
023:         * Utility class.
024:         * 
025:         * @author nk160297
026:         */
027:        public class XPathUtils {
028:
029:            /**
030:             * Converts the qName to a String. 
031:             * Only the prefix and the local part is used. 
032:             * The namespace URI is ignored. 
033:             * 
034:             * This method is intended to print an entity.
035:             */
036:            public static String qNameObjectToString(QName qName) {
037:                String prefix = qName.getPrefix();
038:                if (prefix == null || prefix.length() == 0) {
039:                    return qName.getLocalPart();
040:                } else {
041:                    return prefix + ":" + qName.getLocalPart();
042:                }
043:
044:            }
045:
046:            /**
047:             * Converts the qName to a String. 
048:             * Only the prefix and the namespace URI is used. 
049:             * The local part is ignored. 
050:             * 
051:             * This method is intended to print a namespace which is held in a QName.
052:             */
053:            public static String gNameNamespaceToString(QName qName) {
054:                String prefix = qName.getPrefix();
055:                String nsUri = qName.getNamespaceURI();
056:                //
057:                if (prefix == null || prefix.length() == 0) {
058:                    return "{" + nsUri + "}";
059:                } else {
060:                    return "{" + nsUri + "}" + prefix;
061:                }
062:            }
063:
064:            /**
065:             * Check if the namespace URI is specified for the name. 
066:             * If the name isn't specified, then try resolve it from the prefix.
067:             * Returns the corrected name if possible. Otherwise returns old name.
068:             * @param nsContext
069:             * @param name
070:             * @return
071:             */
072:            public static QName resolvePrefix(NamespaceContext nsContext,
073:                    QName name) {
074:                String nsUri = name.getNamespaceURI();
075:                if (nsUri == null || nsUri.length() == 0 && nsContext != null) {
076:                    //
077:                    String nsPrefix = name.getPrefix();
078:                    nsUri = nsContext.getNamespaceURI(nsPrefix);
079:                    //
080:                    if (nsUri != null) {
081:                        String localPart = name.getLocalPart();
082:                        QName newName = new QName(nsUri, localPart);
083:                        name = newName;
084:                    }
085:                }
086:                //
087:                return name;
088:            }
089:
090:            public static boolean equalsIgnorNsUri(QName qName1, QName qName2) {
091:                return (qName1.getLocalPart().equals(qName2.getLocalPart()))
092:                        && (qName1.getPrefix().equals(qName2.getPrefix()));
093:            }
094:
095:            public static boolean samePredicatesArr(
096:                    XPathPredicateExpression[] predArr1,
097:                    XPathPredicateExpression[] predArr2) {
098:                //
099:                // Compare predicates count
100:                int counter1 = predArr1 == null ? 0 : predArr1.length;
101:                int counter2 = predArr2 == null ? 0 : predArr2.length;
102:                if (counter1 != counter2) {
103:                    return false;
104:                }
105:                // Compare predicates one by one
106:                for (int index = 0; index < counter1; index++) {
107:                    XPathPredicateExpression predicate1 = predArr1[index];
108:                    XPathPredicateExpression predicate2 = predArr2[index];
109:                    String predText1 = predicate1.getExpressionString();
110:                    String predText2 = predicate2.getExpressionString();
111:                    if (!(predText1.equals(predText2))) {
112:                        return false;
113:                    }
114:                }
115:                return true;
116:            }
117:
118:            /**
119:             * Determines if a namespace prefix is required for the specified schema component. 
120:             * @param sComp
121:             * @return
122:             */
123:            public static boolean isPrefixRequired(SchemaComponent sComp) {
124:                if (sComp instanceof  LocalElement) {
125:                    Form form = ((LocalElement) sComp).getFormEffective();
126:                    if (form == Form.QUALIFIED) {
127:                        return true;
128:                    } else {
129:                        return false;
130:                    }
131:                } else if (sComp instanceof  GlobalElement) {
132:                    return true;
133:                } else if (sComp instanceof  LocalAttribute) {
134:                    Form form = ((LocalAttribute) sComp).getFormEffective();
135:                    if (form == Form.QUALIFIED) {
136:                        return true;
137:                    } else {
138:                        return false;
139:                    }
140:                } else if (sComp instanceof  GlobalElement
141:                        || sComp instanceof  ElementReference
142:                        || sComp instanceof  GlobalAttribute) {
143:                    // all global objects have to be with a prefix
144:                    return true;
145:                }
146:                //
147:                assert true : "Unsupported schema component in the BPEL mapper tree!"; // NOI18N
148:                return false;
149:            }
150:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.