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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? dom4jconfiguration.java

?? 解觖java技術中后臺無法上傳數給的情況
?? JAVA
字號:
package net.myvietnam.mvncore.configuration;

/* ====================================================================
 * The Apache Software License, Version 1.1
 *
 * Copyright (c) 2002-2003 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 acknowledgement:
 *       "This product includes software developed by the
 *        Apache Software Foundation (http://www.apache.org/)."
 *    Alternately, this acknowledgement may appear in the software itself,
 *    if and wherever such third-party acknowledgements normally appear.
 *
 * 4. The names "The Jakarta Project", "Commons", 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 names 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/>.
 */

import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URL;
import java.util.Iterator;
import java.util.List;

import org.dom4j.Attribute;
import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.SAXReader;
import org.dom4j.io.XMLWriter;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.exception.NestableRuntimeException;

/**
 * Reads a XML configuration file.
 *
 * To retrieve the value of an attribute of an element, use
 * <code>X.Y.Z[@attribute]</code>.  The '@' symbol was chosen for
 * consistency with XPath.
 *
 * Setting property values will <b>NOT</b> automatically persist
 * changes to disk, unless <code>autoSave=true</code>.
 *
 * @author <a href="mailto:kelvint@apache.org">Kelvin Tan</a>
 * @author <a href="mailto:dlr@apache.org">Daniel Rall</a>
 * @since 0.8.1
 */
public class DOM4JConfiguration extends XMLConfiguration
{
    // For conformance with xpath
    private static final char ATTRIB_MARKER = '@';
    private static final String ATTRIB_START_MARKER = "[" + ATTRIB_MARKER;

    /**
     * For consistency with properties files.  Access nodes via an
     * "A.B.C" notation.
     */
    private static final String NODE_DELIMITER = ".";

    /**
     * A handle to our data source.
     */
    private String fileName;

    /**
     * The XML document from our data source.
     */
    private Document document;

    /**
     * If true, modifications are immediately persisted.
     */
    private boolean autoSave = false;

    /**
     * Empty construtor.  You must provide a file/fileName
     * and call the load method
     *
     */
    public DOM4JConfiguration()
    {
    }

    /**
     * Attempts to load the XML file as a resource from the
     * classpath. The XML file must be located somewhere in the
     * classpath.
     *
     * @param resource Name of the resource
     * @exception Exception If error reading data source.
     * @see DOM4JConfiguration#DOM4JConfiguration(File)
     */
    public DOM4JConfiguration(String resource) throws Exception
    {
        setFile(resourceURLToFile(resource));
        load();
    }

    /**
     * Attempts to load the XML file.
     *
     * @param file File object representing the XML file.
     * @exception Exception If error reading data source.
     */
    public DOM4JConfiguration(File file) throws Exception
    {
        setFile(file);
        load();
    }

    public void load() throws Exception
    {

        document = new SAXReader().read(
        ConfigurationUtils.getURL(getBasePath(), getFileName()));
        initProperties(document.getRootElement(), new StringBuffer());

    }

    private static File resourceURLToFile(String resource)
    {
        URL confURL = DOM4JConfiguration.class.getClassLoader().getResource(resource);
        if (confURL == null)
        {
            confURL = ClassLoader.getSystemResource(resource);
        }
        return new File(confURL.getFile());
    }

    /**
     * Loads and initializes from the XML file.
     *
     * @param element The element to start processing from.  Callers
     * should supply the root element of the document.
     * @param hierarchy
     */
    private void initProperties(Element element, StringBuffer hierarchy)
    {
        for (Iterator it = element.elementIterator(); it.hasNext();)
        {
            StringBuffer subhierarchy = new StringBuffer(hierarchy.toString());
            Element child = (Element) it.next();
            String nodeName = child.getName();
            String nodeValue = child.getTextTrim();
            subhierarchy.append(nodeName);
            if (nodeValue.length() > 0)
            {
                super.addProperty(subhierarchy.toString(), nodeValue);
            }

            // Add attributes as x.y{ATTRIB_START_MARKER}att{ATTRIB_END_MARKER}
            List attributes = child.attributes();
            for (int j = 0, k = attributes.size(); j < k; j++)
            {
                Attribute a = (Attribute) attributes.get(j);
                String attName = subhierarchy.toString() + '[' + ATTRIB_MARKER + a.getName() + ']';
                String attValue = a.getValue();
                super.addProperty(attName, attValue);
            }
            StringBuffer buf = new StringBuffer(subhierarchy.toString());
            initProperties(child, buf.append('.'));
        }
    }

    /**
     * Calls super method, and also ensures the underlying {@link
     * Document} is modified so changes are persisted when saved.
     *
     * @param name
     * @param value
     */
    public void addProperty(String name, Object value)
    {
        super.addProperty(name, value);
        setXmlProperty(name, value);
        possiblySave();
    }

    /**
     * Calls super method, and also ensures the underlying {@link
     * Document} is modified so changes are persisted when saved.
     *
     * @param name
     * @param value
     */
    public void setProperty(String name, Object value)
    {
        super.setProperty(name, value);
        setXmlProperty(name, value);
        possiblySave();
    }

    /**
     * Sets the property value in our document tree, auto-saving if
     * appropriate.
     *
     * @param name The name of the element to set a value for.
     * @param value The value to set.
     */
    private void setXmlProperty(String name, Object value)
    {
        String[] nodes = StringUtils.split(name, NODE_DELIMITER);
        String attName = null;
        Element element = document.getRootElement();
        for (int i = 0; i < nodes.length; i++)
        {
            String eName = nodes[i];
            int index = eName.indexOf(ATTRIB_START_MARKER);
            if (index > -1)
            {
                attName = eName.substring(index + ATTRIB_START_MARKER.length(), eName.length() - 1);
                eName = eName.substring(0, index);
            }
            // If we don't find this part of the property in the XML heirarchy
            // we add it as a new node
            if (element.element(eName) == null && attName == null)
            {
                element.addElement(eName);
            }
            element = element.element(eName);
        }

        if (attName == null)
        {
            element.setText((String) value);
        }
        else
        {
            element.addAttribute(attName, (String) value);
        }
    }

    /**
     * Calls super method, and also ensures the underlying {@link
     * Document} is modified so changes are persisted when saved.
     *
     * @param name The name of the property to clear.
     */
    public void clearProperty(String name)
    {
        super.clearProperty(name);
        clearXmlProperty(name);
        possiblySave();
    }

    private void clearXmlProperty(String name)
    {
        String[] nodes = StringUtils.split(name, NODE_DELIMITER);
        String attName = null;
        Element element = document.getRootElement();
        for (int i = 0; i < nodes.length; i++)
        {
            String eName = nodes[i];
            int index = eName.indexOf(ATTRIB_START_MARKER);
            if (index > -1)
            {
                attName = eName.substring(index + ATTRIB_START_MARKER.length(), eName.length() - 1);
                eName = eName.substring(0, index);
            }
            element = element.element(eName);
            if (element == null)
            {
                return;
            }
        }

        if (attName == null)
        {
            element.remove(element.element(nodes[nodes.length - 1]));
        }
        else
        {
            element.remove(element.attribute(attName));
        }
    }

    /**
     */
    private void possiblySave()
    {
        if (autoSave)
        {
            try
            {
                save();
            }
            catch (IOException e)
            {
                throw new NestableRuntimeException("Failed to auto-save", e);
            }
        }
    }

    /**
     * If true, changes are automatically persisted.
     * @param autoSave
     */
    public void setAutoSave(boolean autoSave)
    {
        this.autoSave = autoSave;
    }

    public synchronized void save() throws IOException
    {
        XMLWriter writer = null;
        OutputStream out = null;
        try
        {
            OutputFormat outputter = OutputFormat.createPrettyPrint();
            out = new BufferedOutputStream(new FileOutputStream(getFile()));
            writer = new XMLWriter(out, outputter);
            writer.write(document);
        }
        finally
        {
            if (out != null)
            {
                out.close();
            }

            if (writer != null)
            {
                writer.close();
            }
        }
    }
    /**
     * Returns the file.
     * @return File
     */
    public File getFile()
    {
        return ConfigurationUtils.constructFile(getBasePath(), getFileName());
    }

    /**
     * Sets the file.
     * @param file The file to set
     */
    public void setFile(File file)
    {
        this.fileName = file.getAbsolutePath();
    }

    public void setFileName(String fileName)
    {

        this.fileName = fileName;

    }

    /**
     * Returns the fileName.
     * @return String
     */
    public String getFileName()
    {
        return fileName;
    }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美性猛片aaaaaaa做受| 久久久亚洲精品一区二区三区| 国产亚洲短视频| 色诱亚洲精品久久久久久| 九一九一国产精品| 亚洲综合免费观看高清完整版| 久久久久免费观看| 91精品国产aⅴ一区二区| av毛片久久久久**hd| 国产精品一区二区x88av| 精品国产91久久久久久久妲己| 欧美色图在线观看| 91久久线看在观草草青青| 91亚洲国产成人精品一区二区三 | 欧美日韩大陆一区二区| 99视频热这里只有精品免费| 成人免费精品视频| 91丝袜国产在线播放| 一区二区三区在线观看欧美| 国产精品久久久久久妇女6080| 国产欧美精品一区二区色综合 | 日韩精品一区第一页| 丝袜亚洲另类丝袜在线| 蜜桃精品在线观看| 激情综合色综合久久综合| 国产精品一区二区无线| 懂色av一区二区夜夜嗨| 91视频观看免费| 欧美日韩黄色影视| 精品国产乱码久久久久久影片| 久久综合九色综合97婷婷| 精品国产一区二区三区四区四| 久久久久久久久久久久久久久99 | 欧美成人a视频| 国产区在线观看成人精品| 亚洲欧美日韩在线播放| 免费黄网站欧美| 不卡在线观看av| 欧美丰满少妇xxxxx高潮对白| 久久中文字幕电影| 一区二区三区中文字幕电影| 日本 国产 欧美色综合| 国产在线麻豆精品观看| 欧美性欧美巨大黑白大战| 久久香蕉国产线看观看99| 蜜臀99久久精品久久久久久软件| 亚洲色图20p| 麻豆传媒一区二区三区| 99re6这里只有精品视频在线观看| 欧美麻豆精品久久久久久| 国产欧美一区二区精品性| 亚洲第一在线综合网站| 99视频国产精品| 中文字幕乱码日本亚洲一区二区| 亚洲18色成人| 波多野结衣精品在线| 久久这里只有精品首页| 青青草精品视频| 欧美乱熟臀69xxxxxx| 欧美日韩精品系列| 国产精品欧美久久久久无广告| 日韩国产欧美三级| 欧美日韩一级二级| 亚洲乱码国产乱码精品精98午夜 | 91在线观看地址| 99国内精品久久| 国产亚洲福利社区一区| 国产一区二区三区在线观看免费 | 亚洲欧美在线视频| 懂色av中文一区二区三区 | 亚洲成av人片在线观看无码| 一区二区三区四区乱视频| 99re成人精品视频| 悠悠色在线精品| 欧美久久久一区| 麻豆国产欧美一区二区三区| 精品久久人人做人人爽| 国产一区二区在线观看免费| 国产精品天天看| www.av精品| 午夜一区二区三区在线观看| 亚洲欧美日韩久久| 欧美日本在线观看| 国产一区二区看久久| 国产精品久久综合| 91久久精品一区二区二区| 婷婷开心激情综合| 国产女主播在线一区二区| 91传媒视频在线播放| 免费看日韩精品| 国产精品欧美久久久久无广告| 欧美在线免费播放| 国产成都精品91一区二区三| 一区二区三区中文字幕精品精品 | 麻豆成人91精品二区三区| 日本一区二区动态图| 欧美一区二区国产| 91福利区一区二区三区| 国产精品一线二线三线| 亚洲成a人片在线观看中文| 久久免费的精品国产v∧| 欧美人与性动xxxx| 99久久久久久| 成人午夜视频福利| 国产一区二区三区av电影| 国产精品电影一区二区三区| 日韩久久久久久| 这里只有精品视频在线观看| av成人老司机| 国产盗摄女厕一区二区三区| 亚洲成a人v欧美综合天堂下载| 欧美极品aⅴ影院| 日韩欧美国产精品| 欧美喷水一区二区| 国产精品国产三级国产普通话三级| 欧美一区二区三区的| 欧美嫩在线观看| 欧美日本在线看| 日韩国产精品91| 亚洲女与黑人做爰| 最新久久zyz资源站| 亚洲精品久久久久久国产精华液| 国产精品网站在线播放| 亚洲欧洲av色图| 亚洲精品写真福利| 午夜欧美电影在线观看| 亚洲三级电影网站| 亚洲成av人影院| 国产美女娇喘av呻吟久久| 国产高清精品在线| 成人av免费网站| 94-欧美-setu| 99国产欧美另类久久久精品| 成人午夜视频在线| 99久久er热在这里只有精品15| 国产99久久久国产精品| 亚洲在线中文字幕| 亚洲国产精品自拍| 日韩电影在线观看网站| 老司机免费视频一区二区| 蜜桃精品视频在线观看| 狠狠色2019综合网| 91小视频免费观看| 成人在线综合网| 在线免费不卡电影| 欧美情侣在线播放| 91精品啪在线观看国产60岁| 欧美电影免费观看高清完整版在线 | 一区二区三区不卡在线观看 | 久久精工是国产品牌吗| 亚洲精品菠萝久久久久久久| 一区二区免费看| 免费欧美高清视频| av电影一区二区| 欧洲精品在线观看| 久久亚洲私人国产精品va媚药| 国产人成亚洲第一网站在线播放| 亚洲最大色网站| 久久不见久久见中文字幕免费| 91理论电影在线观看| 欧美精品一区二区三| 亚洲第一在线综合网站| 国产精品一级片在线观看| 欧美色图片你懂的| 国产精品理伦片| 激情综合色综合久久| 欧美综合一区二区三区| 久久久久99精品一区| 日韩理论片中文av| 狠狠久久亚洲欧美| 日韩小视频在线观看专区| 亚洲另类中文字| 久久成人av少妇免费| 一本一本大道香蕉久在线精品| 国产欧美一区二区三区鸳鸯浴| 久久精品国产精品亚洲精品 | 日韩欧美一级精品久久| 免费成人在线网站| 91精品综合久久久久久| 久久亚洲综合色| 久久成人18免费观看| 91亚洲国产成人精品一区二三| 国产精品三级电影| 成人免费毛片嘿嘿连载视频| 欧美日韩国产首页| 国产做a爰片久久毛片| 亚洲精品在线电影| 国产精品白丝jk黑袜喷水| 国产欧美一区二区三区鸳鸯浴| 成人爽a毛片一区二区免费| 国产午夜精品一区二区 | 亚洲免费在线视频一区 二区| 亚洲视频你懂的| 久久成人麻豆午夜电影| 日韩免费福利电影在线观看| 91亚洲永久精品| 国产河南妇女毛片精品久久久 | 国产亚洲成av人在线观看导航| 欧美视频精品在线| 亚洲六月丁香色婷婷综合久久|