
org.jitsi.impl.configuration.xml.XMLConfUtils Maven / Gradle / Ivy
/*
* Copyright @ 2015 Atlassian Pty Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jitsi.impl.configuration.xml;
import org.jitsi.util.xml.*;
import org.w3c.dom.*;
/**
* Common XML Tasks.
*
* @author Damian Minkov
* @author Emil Ivov
*/
public class XMLConfUtils extends XMLUtils
{
/**
* Returns the element which is at the end of the specified
* String chain.
* <great...grandparent>...<grandparent>.<parent>.>child<
* @param parent the xml element that is the parent of the root of this
* chain.
* @param chain a String array containing the names of all the child's
* parent nodes.
* @return the node represented by the specified chain
*/
public static Element getChildElementByChain(Element parent,
String[] chain)
{
if(chain == null)
return null;
Element e = parent;
for(int i=0; iString elements which represents the
* path to be created. Each element of path up to and including the
* index pathLength - 1
must be valid XML (element) names
* @param pathLength the length of the specified path
* @return the component at the end of the newly created path.
*/
public static Element createLastPathComponent(
Document doc,
String[] path, int pathLength)
{
if (doc == null)
throw new IllegalArgumentException("doc must not be null");
if (path == null)
throw new IllegalArgumentException("path must not be null");
Element parent = (Element)doc.getFirstChild();
if (parent == null)
throw new IllegalArgumentException("parentmust not be null");
Element e = parent;
for (int i = 0; i < pathLength; i++)
{
String pathEl = path[i];
Element newEl = findChild(e, pathEl);
if (newEl == null)
{
newEl = doc.createElement(pathEl);
e.appendChild(newEl);
}
e = newEl;
}
return e;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy