KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > org > apache > xml > internal > security > transforms > params > XPathContainer


1 /*
2  * Copyright 1999-2004 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  */

17 package com.sun.org.apache.xml.internal.security.transforms.params;
18
19
20
21 import com.sun.org.apache.xml.internal.security.transforms.TransformParam;
22 import com.sun.org.apache.xml.internal.security.utils.Constants;
23 import com.sun.org.apache.xml.internal.security.utils.SignatureElementProxy;
24 import org.w3c.dom.Document JavaDoc;
25 import org.w3c.dom.NodeList JavaDoc;
26 import org.w3c.dom.Text JavaDoc;
27
28
29 /**
30  * This Object serves both as namespace prefix resolver and as container for
31  * the <CODE>ds:XPath</CODE> Element. It implements the {@link org.w3c.dom.Element} interface
32  * and can be used directly in a DOM tree.
33  *
34  * @author Christian Geuer-Pollmann
35  */

36 public class XPathContainer extends SignatureElementProxy implements TransformParam {
37
38    /**
39     * Constructor XPathContainer
40     *
41     * @param doc
42     */

43    public XPathContainer(Document JavaDoc doc) {
44       super(doc);
45    }
46
47    /**
48     * Sets the TEXT value of the <CODE>ds:XPath</CODE> Element.
49     *
50     * @param xpath
51     */

52    public void setXPath(String JavaDoc xpath) {
53
54       if (this._constructionElement.getChildNodes() != null) {
55          NodeList JavaDoc nl = this._constructionElement.getChildNodes();
56
57          for (int i = 0; i < nl.getLength(); i++) {
58             this._constructionElement.removeChild(nl.item(i));
59          }
60       }
61
62       Text JavaDoc xpathText = this._doc.createTextNode(xpath);
63       this._constructionElement.appendChild(xpathText);
64    }
65
66    /**
67     * Returns the TEXT value of the <CODE>ds:XPath</CODE> Element.
68     *
69     * @return the TEXT value of the <CODE>ds:XPath</CODE> Element.
70     */

71    public String JavaDoc getXPath() {
72       return this.getTextFromTextChild();
73    }
74
75    /** @inheritDoc */
76    public String JavaDoc getBaseLocalName() {
77       return Constants._TAG_XPATH;
78    }
79 }
80
Popular Tags