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

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

?? dom4jconfiguration.java

?? java servlet著名論壇源代碼
?? 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一区二区三区免费野_久草精品视频
日韩欧美视频一区| 亚洲精品视频观看| 日韩理论在线观看| 免费av网站大全久久| 成人蜜臀av电影| 欧美欧美欧美欧美| 亚洲视频一区在线| 国产呦精品一区二区三区网站| 一本一道久久a久久精品| 久久综合九色综合97婷婷| 亚洲一区二区免费视频| 99久久免费国产| 久久久久99精品一区| 免费成人在线网站| 欧美日韩成人在线一区| 亚洲激情第一区| 99这里都是精品| 亚洲国产成人在线| 国产精品中文字幕一区二区三区| 91精品国产福利| 天堂va蜜桃一区二区三区漫画版| 91社区在线播放| 国产精品福利一区二区三区| 国产麻豆欧美日韩一区| 精品久久久久久无| 麻豆精品一二三| 日韩一二三四区| 久久精品久久综合| 日韩一区二区三区av| 日本在线观看不卡视频| 欧美一区二区三区四区视频 | 亚洲欧洲日韩在线| 国产成人精品www牛牛影视| 337p粉嫩大胆噜噜噜噜噜91av| 久久99热狠狠色一区二区| 欧美另类久久久品| 婷婷一区二区三区| 欧美一区二区在线免费播放| 天堂在线一区二区| 7777精品伊人久久久大香线蕉| 亚洲成人自拍一区| 在线不卡的av| 狠狠色狠狠色合久久伊人| 久久久久国产成人精品亚洲午夜| 欧美优质美女网站| 亚洲图片自拍偷拍| 欧美一区二区久久久| 久久av中文字幕片| 欧美精品一区二区三区蜜臀| 成人h精品动漫一区二区三区| 国产精品久久精品日日| 不卡视频在线观看| 亚洲福中文字幕伊人影院| 日韩你懂的在线观看| 国产精品综合久久| 国产精品久久久久久久第一福利| 在线一区二区视频| 奇米影视一区二区三区小说| 久久久99精品久久| 91亚洲午夜精品久久久久久| 日韩1区2区3区| 中文字幕成人网| 欧美午夜精品理论片a级按摩| 精品无人码麻豆乱码1区2区 | 亚洲激情第一区| 日韩精品一区二区三区中文不卡| 99精品热视频| 美女在线视频一区| 成人欧美一区二区三区在线播放| 欧美精品日韩综合在线| 国产不卡视频在线观看| 亚洲一卡二卡三卡四卡五卡| 日本一区二区三区国色天香 | 蜜芽一区二区三区| 国产精品女同一区二区三区| 3d动漫精品啪啪一区二区竹菊| 国产成人夜色高潮福利影视| 亚洲成人精品一区| 中文字幕不卡的av| 日韩精品一区二区三区在线| 色综合亚洲欧洲| 国产不卡视频在线播放| 日本成人在线看| 亚洲精品一二三| 国产精品狼人久久影院观看方式| 欧美一级免费观看| 色综合久久久久网| 粉嫩欧美一区二区三区高清影视 | 99re亚洲国产精品| 精品一区二区在线免费观看| 亚洲一区二区三区四区五区中文| 久久色在线观看| 日韩午夜av电影| 欧美日韩久久久一区| 91蜜桃在线观看| 欧美精品一区在线观看| 一本大道久久精品懂色aⅴ| 国产在线一区观看| 久久国产精品区| 免费一级片91| 日韩国产精品久久久久久亚洲| 亚洲一区二区在线免费看| 国产精品网站一区| 久久精品人人做人人综合| 91精品国产综合久久蜜臀| 欧美午夜精品免费| 在线观看亚洲一区| 在线观看免费一区| 色婷婷av一区二区三区gif| 99国产精品国产精品久久| 成人avav在线| 一本大道久久精品懂色aⅴ| 99精品在线免费| 一本一本大道香蕉久在线精品| a级精品国产片在线观看| 成人免费看视频| 99国产麻豆精品| 欧美色图天堂网| 欧美性受极品xxxx喷水| 欧美日本视频在线| 在线播放亚洲一区| 日韩一区和二区| 精品电影一区二区| 久久嫩草精品久久久精品一| 欧美国产精品久久| 亚洲视频电影在线| 亚洲一区在线看| 日本女优在线视频一区二区| 经典三级在线一区| 国产寡妇亲子伦一区二区| 成人app网站| 欧美性色综合网| 亚洲精品一区二区三区香蕉| 欧美极品少妇xxxxⅹ高跟鞋 | 国产高清不卡一区| 日韩欧美精品在线视频| 国产午夜精品久久久久久久| 亚洲欧洲精品成人久久奇米网| 一区二区三国产精华液| 五月天久久比比资源色| 国产真实乱对白精彩久久| 99国产精品久久久久久久久久| 欧美久久久久久久久中文字幕| 欧美videos中文字幕| 国产精品视频观看| 亚洲va欧美va人人爽午夜| 韩国中文字幕2020精品| 91小视频在线免费看| 91精品麻豆日日躁夜夜躁| 欧美激情一区二区三区| 亚洲国产成人tv| 国产精品77777| 欧美二区在线观看| 国产午夜亚洲精品不卡| 亚洲综合在线五月| 韩国欧美一区二区| 在线观看亚洲成人| 26uuu欧美| 午夜国产精品一区| 成人国产精品免费观看动漫| 欧美一区二区黄| 亚洲免费大片在线观看| 国产制服丝袜一区| 欧美日韩成人综合在线一区二区 | 成人激情电影免费在线观看| 欧美日韩久久久一区| 久久久一区二区三区| 亚洲国产另类av| 99热99精品| 国产偷国产偷亚洲高清人白洁| 亚洲福利视频导航| 不卡一区中文字幕| 337p粉嫩大胆色噜噜噜噜亚洲| 午夜电影一区二区| 色八戒一区二区三区| 国产婷婷精品av在线| 青青草原综合久久大伊人精品优势| 99热99精品| 中日韩免费视频中文字幕| 美国十次综合导航| 欧美日韩一区中文字幕| 自拍偷拍亚洲激情| 不卡一区在线观看| 中文一区一区三区高中清不卡| 国模套图日韩精品一区二区 | 日韩女优电影在线观看| 亚洲444eee在线观看| 在线视频综合导航| 亚洲精品第1页| 日本韩国一区二区三区视频| 亚洲欧美日韩久久| av一区二区三区在线| 欧美激情在线看| 成人高清视频免费观看| 欧美国产精品久久| 成人免费的视频| 亚洲欧美另类在线| 色婷婷久久一区二区三区麻豆| 亚洲激情图片一区| 在线观看免费成人|