01: /*
02: * The contents of this file are subject to the terms of the Common Development
03: * and Distribution License (the License). You may not use this file except in
04: * compliance with the License.
05: *
06: * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
07: * or http://www.netbeans.org/cddl.txt.
08: *
09: * When distributing Covered Code, include this CDDL Header Notice in each file
10: * and include the License file at http://www.netbeans.org/cddl.txt.
11: * If applicable, add the following below the CDDL Header, with the fields
12: * enclosed by brackets [] replaced by your own identifying information:
13: * "Portions Copyrighted [year] [name of copyright owner]"
14: *
15: * Portions Copyrighted 2007 Sun Microsystems, Inc.
16: */
17: package org.netbeans.modules.bpel.model.api.support;
18:
19: import java.util.Iterator;
20: import javax.xml.XMLConstants;
21: import javax.xml.namespace.NamespaceContext;
22:
23: /**
24: * This namespace context is a wrapper.
25: * It delegates almost all execution to the BPEL Namespace context.
26: * The only case which it processes self is the call of the getNamespaceURI()
27: * with the empty prefix. The BPEL namespace context returns a default
28: * namespace in such case. But this class returns NULL namespace.
29: * The XPath expressions in the BPEL don't use the default namespace!
30: *
31: * @author nk160297
32: */
33: public class BpelXPathNamespaceContext implements NamespaceContext {
34:
35: private NamespaceContext myParentNsContext;
36:
37: public BpelXPathNamespaceContext(NamespaceContext parentNsContext) {
38: myParentNsContext = parentNsContext;
39: }
40:
41: public String getNamespaceURI(String prefix) {
42: if (prefix == null || prefix.length() == 0) {
43: return XMLConstants.NULL_NS_URI;
44: } else {
45: return myParentNsContext.getNamespaceURI(prefix);
46: }
47: }
48:
49: public String getPrefix(String namespaceURI) {
50: return myParentNsContext.getPrefix(namespaceURI);
51: }
52:
53: public Iterator getPrefixes(String namespaceURI) {
54: return myParentNsContext.getPrefixes(namespaceURI);
55: }
56:
57: }
|