亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專(zhuān)輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? xmlutils.java

?? java 開(kāi)發(fā)的sip軟電話(huà) 源碼 jain sip
?? JAVA
字號(hào):
/* ====================================================================
 * The Apache Software License, Version 1.1
 *
 * Copyright (c) 2000 The Apache Software Foundation.  All rights
 * reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation included with the redistribution,
 *    if any, must include the following acknowledgment:
 *       "This product includes software developed by the
 *        Apache Software Foundation (http://www.apache.org/)."
 *    Alternately, this acknowledgment may appear in the software itself,
 *    if and wherever such third-party acknowledgments normally appear.
 *
 * 4. The names "Apache" and "Apache Software Foundation" must
 *    not be used to endorse or promote products derived from this
 *    software without prior written permission. For written
 *    permission, please contact apache@apache.org.
 *
 * 5. Products derived from this software may not be called "Apache",
 *    nor may "Apache" appear in their name, without prior written
 *    permission of the Apache Software Foundation.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of the Apache Software Foundation.  For more
 * information on the Apache Software Foundation, please see
 * <http://www.apache.org/>.
 *
 * Portions of this software are based upon public domain software
 * originally written at the National Center for Supercomputing Applications,
 * University of Illinois, Urbana-Champaign.
 */
package net.java.mais.gui.config.xml;

import java.io.File;
import java.io.PrintStream;
import java.io.Writer;

import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;

import org.w3c.dom.CDATASection;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.Text;

/**
 * Common XML Tasks
 *
 * @author Damian Minkov
 */
public class XMLUtils
{
    static
    {
        //avoid trace messages in this class
    }

    /**
     * Get the attribute with given name's value
     * @param node the node which attribute's value is returned
     * @param name name of the attribute
     * @return the value af the attribute
     */
    public static String getAttributeByName(Node node, String name)
    {
        try
        {
            if(node == null)
                return null;

            Node attribute = node.getAttributes().getNamedItem(name);
            if(attribute == null)
                return null;
            else
                return attribute.getNodeValue().trim();
        }
        finally
        {
        }
    }

    /**
     * Get the data of the element , no matter whether it is
     * TXT ot CDATA
     *
     * @param parentNode the node which data is returned
     * @return the TEXT or CDATA of the parentNode
     */
    public static String getElementTextValue(Element parentNode)
    {
        try
        {
            Text text = getElementTextNode(parentNode);
            if(text != null)
                return text.getData();
            else
                return null;
        }
        finally
        {
        }
    }

    /**
     * Sets element TEXT data
     *
     * @param e the element
     * @param data the new data
     */
    public static void setElementTextValue(Element e, String data)
    {
        try
        {
            Text txt = getElementTextNode(e);
            if(txt != null)
                txt.setData(data);
            else
            {
                txt = e.getOwnerDocument().createTextNode(data);
                e.appendChild(txt);
            }
        }
        finally
        {
        }
    }

    /**
     * Sets element CDATA data
     *
     * @param e the lement
     * @param data the new data
     */
    public static void setElementCDataValue(Element e, String data)
    {
        try
        {
            CDATASection txt = getElementCDataNode(e);
            if(txt != null)
                txt.setData(data);
            else
            {
                txt = e.getOwnerDocument().createCDATASection(data);
                e.appendChild(txt);
            }
        }
        finally
        {
        }
    }

    /**
     * Gets CDATA value of an element
     * @param e the element
     * @return CDATA value of element e
     */
    public static String getElementCDataValue(Element e)
    {
        try
        {
            CDATASection text = getElementCDataNode(e);
            if(text != null)
                return text.getData().trim();
            else
                return null;
        }
        finally
        {
        }
    }


    /**
     * Returns element's CDATA Node
     * @param element the element which CDATA node is returned
     * @return CDATA node
     */
    public static CDATASection getElementCDataNode(Element element)
    {
        try
        {
            return (CDATASection)getChildNodeByType(element, Node.CDATA_SECTION_NODE);
        }
        finally
        {
        }
    }

    /**
     * Returns element's TEXT Node
     * @param element the element which TEXT node is returned
     * @return TEXT node
     */
    public static Text getElementTextNode(Element element)
    {
        try
        {
           return (Text)getChildNodeByType(element, Node.TEXT_NODE);
        }
        finally
        {
        }
    }


    private static Node getChildNodeByType(Element element, short nodeType)
    {
        if(element == null)
            return null;

        NodeList nodes = element.getChildNodes();
        if(nodes == null || nodes.getLength() < 1)
            return null;

        Node node;
        String data;
        for(int i = 0; i < nodes.getLength(); i++)
        {
            node = nodes.item(i);
            short type = node.getNodeType();
            if(type == nodeType)
            {
                if(type == Node.TEXT_NODE || type == Node.CDATA_SECTION_NODE)
                {
                    data = ((Text)node).getData();
                    if(data == null || data.trim().length() < 1)
                        continue;
                }

                return node;
            }
        }

        return null;
    }

    /**
     * Writes the specified document to the given file.
     * The default encoding is UTF-8.
     *
     * @param out the output File
     * @param document the document to be writen
     */
    public static void writeXML(File out, Document document)
    {
        try {
            DOMSource domSource = new DOMSource(document);
            StreamResult streamResult = new StreamResult(out);
            TransformerFactory tf = TransformerFactory.newInstance();
            Transformer serializer = tf.newTransformer();
            serializer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
            serializer.setOutputProperty(OutputKeys.INDENT, "yes");
            serializer.transform(domSource, streamResult);
//			printChildElements((Element)document.getFirstChild(), System.out, true, "");
        }
        catch (TransformerException ex) {
        }
        catch (IllegalArgumentException ex) {
        }
        finally {
        }
    }


    public static void writeXML(Writer   writer,
                                Document document,
                                String   doctypeSystem,
                                String   doctypePublic)
    {
        try
       {

           DOMSource domSource = new DOMSource(document);
           StreamResult streamResult = new StreamResult(writer);
           TransformerFactory tf = TransformerFactory.newInstance();
           Transformer serializer = tf.newTransformer();
           if(doctypeSystem != null)
                   serializer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, doctypeSystem);
            if(doctypePublic != null)
                   serializer.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, doctypePublic);
           serializer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
           serializer.setOutputProperty(OutputKeys.INDENT, "yes");
           serializer.transform(domSource, streamResult);
//			printChildElements((Element)document.getFirstChild(), System.out, true, "");
       }
       catch(TransformerException ex)
       {
       }
       catch(IllegalArgumentException ex)
       {
       }
       finally
       {
       }

    }

    /**
     * Returns the element which is at the end of the specified
     * chain  <parent><child><grandchild>...
     * @param element
     * @param chain
     * @return
     */
    public static Element getChildElementByChain(Element element, String[] chain, boolean create)
    {
        if(chain == null)
            return null;
        Element e = element;
        for(int i=0; i<chain.length; i++)
        {
            if(e == null)
                return null;
            e = getChildElementByTagName(e, chain[i]);
        }
        return e;
    }

    /**
     * Creates (only if necessary) and returns the element which is at the end of the specified
     * path.
     * @param doc the target document where the specified path should be created
     * @param path a dot separated string indicating the path to be created
     * @return the component at the end of the newly created path.
     */
    public static Element createLastPathComponent(Document doc, String[] path)
    {
        Element parent = (Element)doc.getFirstChild();
        if(   path   == null
           || parent == null
           || doc   == null)
            throw new IllegalArgumentException("Document parent and path must not be null");

        Element e = parent;
        for(int i=0; i < path.length; i++)
        {
            Element newEl = getChildElementByTagName(e, path[i]);
            if(newEl == null)
            {
                newEl = doc.createElement(path[i]);
                e.appendChild(newEl);
            }
            e = newEl;
        }
        return e;
    }

    /**
     * Returns the child element with the specified tagName for the specified parent element
     * @param parent
     * @param tagName
     * @return
     */
    public static Element getChildElementByTagName(Element parent, String tagName)
    {
        if(parent == null || tagName == null)
            return null;

        NodeList nodes = parent.getChildNodes();
        Node node;
        int len = nodes.getLength();
        for(int i = 0; i < len; i++)
        {
            node = nodes.item(i);
            if(node.getNodeType() == Node.ELEMENT_NODE && ((Element)node).getNodeName().equals(tagName))
                return (Element)node;
        }

        return null;
    }

    /**
     * Used for debuging
     *
     * @param parent Element
     * @param out PrintStream
     * @param deep boolean
     * @param prefix String
     */
    private static void printChildElements(Element parent, PrintStream out, boolean deep, String prefix)
    {
        out.print(prefix + "<" + parent.getNodeName());
        NamedNodeMap attrs = parent.getAttributes();
        Node node;
        for(int i = 0; i < attrs.getLength(); i++)
        {
            node = attrs.item(i);
            out.print(" " + node.getNodeName() + "=\"" + node.getNodeValue() + "\"");
        }
        out.println(">");

        String data = getElementTextValue(parent);
        if(data != null && data.trim().length() > 0)
            out.println(prefix + "\t" + data);

        data = getElementCDataValue(parent);
        if(data != null && data.trim().length() > 0)
            out.println(prefix + "\t<![CDATA[" + data + "]]>");

        NodeList nodes = parent.getChildNodes();
        for(int i = 0; i < nodes.getLength(); i++)
        {
            node = nodes.item(i);
            if(node.getNodeType() == Node.ELEMENT_NODE)
            {
                if(deep)
                    printChildElements((Element)node, out, deep, prefix + "\t");
                else
                    out.println(prefix + node.getNodeName());
            }
        }

        out.println(prefix + "</" + parent.getNodeName() + ">");
    }

}

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美三级三级三级爽爽爽| 一区二区三区四区在线免费观看| 欧美美女一区二区在线观看| 日本韩国精品一区二区在线观看| 97aⅴ精品视频一二三区| 91在线免费视频观看| 91免费看`日韩一区二区| 91高清在线观看| 91电影在线观看| 欧美性猛交xxxx黑人交| 欧美三级资源在线| 欧美日韩免费电影| 日韩无一区二区| 精品国产乱码久久久久久老虎| 精品美女被调教视频大全网站| 日韩一级片在线观看| 精品久久国产97色综合| 久久亚洲精品国产精品紫薇| 久久久久国产精品麻豆| 国产精品久久久久久久久久免费看| 亚洲国产精华液网站w| 中文字幕在线播放不卡一区| 亚洲综合精品久久| 日韩成人av影视| 精品一区二区三区免费播放| 国产精品一区在线| 成人av在线资源| 一本一道综合狠狠老| 欧美日韩精品欧美日韩精品| 日韩欧美在线综合网| 欧美激情在线观看视频免费| 亚洲欧洲三级电影| 欧美日韩精品欧美日韩精品一综合| 91精品在线一区二区| 久久亚洲捆绑美女| 亚洲精品视频自拍| 麻豆精品视频在线观看视频| 国产精品亚洲а∨天堂免在线| www.99精品| 337p亚洲精品色噜噜狠狠| 久久精品欧美一区二区三区不卡| 亚洲素人一区二区| 日韩高清在线电影| 国产盗摄一区二区| 欧美伊人久久久久久久久影院| 欧美sm极限捆绑bd| 亚洲人成精品久久久久久| 日韩av午夜在线观看| 国产成人99久久亚洲综合精品| 91久久精品国产91性色tv| 欧美成人女星排名| 亚洲美女淫视频| 精品亚洲成a人| 色94色欧美sute亚洲线路一久| 日韩欧美一级在线播放| 亚洲精品老司机| 精彩视频一区二区三区| 色哟哟亚洲精品| 久久伊人蜜桃av一区二区| 亚洲国产成人tv| k8久久久一区二区三区| 日韩免费福利电影在线观看| 亚洲乱码日产精品bd| 国产精品一二三四五| 欧美日韩国产电影| 自拍偷拍亚洲欧美日韩| 国内精品不卡在线| 91精品在线免费观看| 一区二区三区波多野结衣在线观看| 国产不卡在线一区| 日韩一区二区在线看| 夜夜嗨av一区二区三区网页| 国产成人午夜99999| 日韩免费观看高清完整版在线观看| 亚洲精品高清在线| 成人午夜精品在线| 亚洲精品一区二区三区四区高清| 亚洲va在线va天堂| 色噜噜狠狠色综合欧洲selulu| 国产亚洲1区2区3区| 久久电影网站中文字幕| 欧美肥妇free| 亚洲一区二区欧美日韩| 91丝袜国产在线播放| 国产精品久久久一本精品| 国产一区二区三区国产| 日韩美女在线视频| 青青草国产成人99久久| 欧美久久一二三四区| 亚洲国产综合视频在线观看| 日本久久电影网| 伊人夜夜躁av伊人久久| 色悠久久久久综合欧美99| 中文字幕在线观看不卡视频| 波多野结衣的一区二区三区| 中文字幕av一区二区三区高| 国产成人精品午夜视频免费| 久久久高清一区二区三区| 毛片不卡一区二区| 欧美一区2区视频在线观看| 香蕉加勒比综合久久| 欧美日韩免费视频| 污片在线观看一区二区| 91精品啪在线观看国产60岁| 日韩av一区二区在线影视| 欧美日韩国产在线播放网站| 亚洲成人tv网| 日韩午夜av一区| 久久精品国产久精国产| 日韩免费成人网| 国产乱子伦一区二区三区国色天香| 久久嫩草精品久久久精品| 国产精品一区一区三区| 国产精品另类一区| 色综合中文字幕| 免费在线看成人av| 日韩免费观看2025年上映的电影| 免费不卡在线观看| 久久免费美女视频| thepron国产精品| 一区二区不卡在线播放| 欧美蜜桃一区二区三区| 免费高清视频精品| 国产欧美日韩不卡| 日本黄色一区二区| 蜜臀av性久久久久蜜臀av麻豆 | www国产精品av| 丁香婷婷综合激情五月色| 17c精品麻豆一区二区免费| 欧美色网站导航| 久久精品国产一区二区| 国产欧美精品区一区二区三区| 国产69精品久久久久毛片| 亚洲综合成人在线| 精品国产免费人成电影在线观看四季| 国产一区二区女| 亚洲欧美在线视频观看| 777亚洲妇女| 国产成人一区二区精品非洲| 亚洲一区二区在线播放相泽| 精品剧情v国产在线观看在线| 99久久综合色| 美美哒免费高清在线观看视频一区二区| 久久婷婷国产综合国色天香 | 中文字幕在线不卡一区| 欧美日韩成人综合在线一区二区| 久久99久久99小草精品免视看| 中文字幕 久热精品 视频在线 | 亚洲国产电影在线观看| 在线观看亚洲专区| 精品一区二区三区不卡| 亚洲柠檬福利资源导航| 精品精品欲导航| 91福利在线导航| 国产精品99久久久久久似苏梦涵| 樱桃视频在线观看一区| 久久久久九九视频| 欧美日韩情趣电影| eeuss鲁片一区二区三区 | 日韩三级高清在线| 91免费看片在线观看| 国产在线精品不卡| 偷拍亚洲欧洲综合| 中文字幕一区av| 久久久久久久综合色一本| 欧美群妇大交群的观看方式| yourporn久久国产精品| 极品少妇xxxx精品少妇偷拍| 亚洲一区在线看| 国产精品亲子伦对白| 日韩欧美在线1卡| 欧美日韩中文字幕一区| 成人听书哪个软件好| 久久综合综合久久综合| 亚洲一区二区综合| 中文字幕乱码久久午夜不卡 | 亚洲国产精品一区二区久久恐怖片| 中文字幕欧美日韩一区| 精品欧美久久久| 欧美人与z0zoxxxx视频| 色屁屁一区二区| 国产高清在线精品| 精品一区二区三区欧美| 免费久久99精品国产| 亚洲一区二区三区视频在线播放 | 亚洲成人av一区二区三区| 日韩美女视频一区| 国产视频一区二区在线观看| 欧美电影精品一区二区| 日韩三级精品电影久久久| 欧美乱熟臀69xxxxxx| 欧美亚洲尤物久久| 99久久久精品| 99亚偷拍自图区亚洲| 粉嫩欧美一区二区三区高清影视 | 欧洲人成人精品| 91福利国产精品| 在线视频你懂得一区二区三区| 成人av中文字幕| 97久久久精品综合88久久|