01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.cocoon.util.jxpath;
18:
19: import org.apache.cocoon.xml.NamespacesTable;
20: import org.apache.commons.jxpath.ri.QName;
21: import org.apache.commons.jxpath.ri.model.NodeIterator;
22: import org.apache.commons.jxpath.ri.model.NodePointer;
23:
24: /**
25: * A JXPath <code>Pointer</code> that tracks namespaces defined by a {@link NamespacesTable}.
26: * This class is to be used to inform JXPath of the namespaces declared in a host environment
27: * (e.g. JXTemplateGenerator) using
28: * <a href="http://jakarta.apache.org/commons/jxpath/apidocs/org/apache/commons/jxpath/JXPathContext.html#setNamespaceContextPointer(org.apache.commons.jxpath.Pointer)">JXPathContext.setNamespaceContextPointer()</a>.
29: *
30: * @since 2.1.8
31: * @version $Id: NamespacesTablePointer.java 433543 2006-08-22 06:22:54Z crossley $
32: */
33: public class NamespacesTablePointer extends NodePointer {
34:
35: private NamespacesTable namespaces;
36:
37: public NamespacesTablePointer(NamespacesTable namespaces) {
38: super (null);
39: this .namespaces = namespaces;
40: }
41:
42: public String getNamespaceURI(String prefix) {
43: return namespaces.getUri(prefix);
44: }
45:
46: protected String getDefaultNamespaceURI() {
47: return namespaces.getUri("");
48: }
49:
50: public NodeIterator namespaceIterator() {
51: return null;
52: }
53:
54: //-------------------------------------------------------------------------
55: // Dummy implementation of abstract methods
56: //-------------------------------------------------------------------------
57:
58: public boolean isLeaf() {
59: return true;
60: }
61:
62: public boolean isCollection() {
63: return false;
64: }
65:
66: public int getLength() {
67: return 0;
68: }
69:
70: public QName getName() {
71: return null;
72: }
73:
74: public Object getBaseValue() {
75: return null;
76: }
77:
78: public Object getImmediateNode() {
79: return null;
80: }
81:
82: public void setValue(Object value) {
83: // ignore
84: }
85:
86: public int compareChildNodePointers(NodePointer arg0,
87: NodePointer arg1) {
88: return -1;
89: }
90: }
|