1 /* 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 */ 21 package com.sun.org.apache.xml.internal.security.transforms.params; 22 23 24 25 import com.sun.org.apache.xml.internal.security.transforms.TransformParam; 26 import com.sun.org.apache.xml.internal.security.utils.Constants; 27 import com.sun.org.apache.xml.internal.security.utils.SignatureElementProxy; 28 import org.w3c.dom.Document; 29 import org.w3c.dom.NodeList; 30 import 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 */ 40 public 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 } | 1 /* 2 * reserved comment block 3 * DO NOT REMOVE OR ALTER! 4 */ 5 /** 6 * Licensed to the Apache Software Foundation (ASF) under one 7 * or more contributor license agreements. See the NOTICE file 8 * distributed with this work for additional information 9 * regarding copyright ownership. The ASF licenses this file 10 * to you under the Apache License, Version 2.0 (the 11 * "License"); you may not use this file except in compliance 12 * with the License. You may obtain a copy of the License at 13 * 14 * http://www.apache.org/licenses/LICENSE-2.0 15 * 16 * Unless required by applicable law or agreed to in writing, 17 * software distributed under the License is distributed on an 18 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 19 * KIND, either express or implied. See the License for the 20 * specific language governing permissions and limitations 21 * under the License. 22 */ 23 package com.sun.org.apache.xml.internal.security.transforms.params; 24 25 26 import com.sun.org.apache.xml.internal.security.transforms.TransformParam; 27 import com.sun.org.apache.xml.internal.security.utils.Constants; 28 import com.sun.org.apache.xml.internal.security.utils.SignatureElementProxy; 29 import org.w3c.dom.Document; 30 import org.w3c.dom.NodeList; 31 import org.w3c.dom.Text; 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 */ 40 public 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 if (this.constructionElement.getChildNodes() != null) { 58 NodeList nl = this.constructionElement.getChildNodes(); 59 60 for (int i = 0; i < nl.getLength(); i++) { 61 this.constructionElement.removeChild(nl.item(i)); 62 } 63 } 64 65 Text xpathText = this.doc.createTextNode(xpath); 66 this.constructionElement.appendChild(xpathText); 67 } 68 69 /** 70 * Returns the TEXT value of the <CODE>ds:XPath</CODE> Element. 71 * 72 * @return the TEXT value of the <CODE>ds:XPath</CODE> Element. 73 */ 74 public String getXPath() { 75 return this.getTextFromTextChild(); 76 } 77 78 /** @inheritDoc */ 79 public String getBaseLocalName() { 80 return Constants._TAG_XPATH; 81 } 82 } |