blob: 717889d576f507deb521f8aae8c050f06e0ba46d [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * reserved comment block
3 * DO NOT REMOVE OR ALTER!
4 */
5/*
6 * Copyright 1999-2004 The Apache Software Foundation.
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 *
20 */
21package com.sun.org.apache.xml.internal.security.transforms.params;
22
23
24
25import com.sun.org.apache.xml.internal.security.transforms.TransformParam;
26import com.sun.org.apache.xml.internal.security.utils.Constants;
27import com.sun.org.apache.xml.internal.security.utils.SignatureElementProxy;
28import org.w3c.dom.Document;
29import org.w3c.dom.NodeList;
30import org.w3c.dom.Text;
31
32
33/**
34 * This Object serves both as namespace prefix resolver and as container for
35 * the <CODE>ds:XPath</CODE> Element. It implements the {@link org.w3c.dom.Element} interface
36 * and can be used directly in a DOM tree.
37 *
38 * @author Christian Geuer-Pollmann
39 */
40public class XPathContainer extends SignatureElementProxy implements TransformParam {
41
42 /**
43 * Constructor XPathContainer
44 *
45 * @param doc
46 */
47 public XPathContainer(Document doc) {
48 super(doc);
49 }
50
51 /**
52 * Sets the TEXT value of the <CODE>ds:XPath</CODE> Element.
53 *
54 * @param xpath
55 */
56 public void setXPath(String xpath) {
57
58 if (this._constructionElement.getChildNodes() != null) {
59 NodeList nl = this._constructionElement.getChildNodes();
60
61 for (int i = 0; i < nl.getLength(); i++) {
62 this._constructionElement.removeChild(nl.item(i));
63 }
64 }
65
66 Text xpathText = this._doc.createTextNode(xpath);
67 this._constructionElement.appendChild(xpathText);
68 }
69
70 /**
71 * Returns the TEXT value of the <CODE>ds:XPath</CODE> Element.
72 *
73 * @return the TEXT value of the <CODE>ds:XPath</CODE> Element.
74 */
75 public String getXPath() {
76 return this.getTextFromTextChild();
77 }
78
79 /** @inheritDoc */
80 public String getBaseLocalName() {
81 return Constants._TAG_XPATH;
82 }
83}