KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > util > jxpath > NamespacesTablePointer


1 /*
2  * Copyright 2005 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.cocoon.util.jxpath;
17
18 import org.apache.cocoon.xml.NamespacesTable;
19 import org.apache.commons.jxpath.ri.QName;
20 import org.apache.commons.jxpath.ri.model.NodeIterator;
21 import org.apache.commons.jxpath.ri.model.NodePointer;
22
23 /**
24  * A JXPath <code>Pointer</code> that tracks namespaces defined by a {@link NamespacesTable}.
25  * This class is to be used to inform JXPath of the namespaces declared in a host environment
26  * (e.g. JXTemplateGenerator) using
27  * <a HREF="http://jakarta.apache.org/commons/jxpath/apidocs/org/apache/commons/jxpath/JXPathContext.html#setNamespaceContextPointer(org.apache.commons.jxpath.Pointer)">JXPathContext.setNamespaceContextPointer()</a>.
28  *
29  * @since 2.1.8
30  * @version $Id: NamespacesTablePointer.java 231266 2005-08-10 15:38:10Z sylvain $
31  */

32 public class NamespacesTablePointer extends NodePointer {
33     
34     private NamespacesTable namespaces;
35
36     public NamespacesTablePointer(NamespacesTable namespaces) {
37         super(null);
38         this.namespaces = namespaces;
39     }
40
41     public String JavaDoc getNamespaceURI(String JavaDoc prefix) {
42         return namespaces.getUri(prefix);
43     }
44
45     protected String JavaDoc getDefaultNamespaceURI() {
46         return namespaces.getUri("");
47     }
48
49     public NodeIterator namespaceIterator() {
50         return null;
51     }
52     
53     //-------------------------------------------------------------------------
54
// Dummy implementation of abstract methods
55
//-------------------------------------------------------------------------
56

57     public boolean isLeaf() {
58         return true;
59     }
60
61     public boolean isCollection() {
62         return false;
63     }
64
65     public int getLength() {
66         return 0;
67     }
68
69     public QName getName() {
70         return null;
71     }
72
73     public Object JavaDoc getBaseValue() {
74         return null;
75     }
76
77     public Object JavaDoc getImmediateNode() {
78         return null;
79     }
80
81     public void setValue(Object JavaDoc value) {
82         // ignore
83
}
84
85     public int compareChildNodePointers(NodePointer arg0, NodePointer arg1) {
86         return -1;
87     }
88 }
89
Popular Tags