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

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

?? xmlproperties.java

?? 這個是讀取日志文件,并且處理,然后把它插入到數據庫中
?? JAVA
字號:
/**
 * $RCSfile$
 * $Revision: 4798 $
 * $Date: 2006-08-04 02:34:58 +0800 (星期??, 04 八月 2006) $
 *
 * Copyright (C) 2004 Jive Software. All rights reserved.
 *
 * This software is published under the terms of the GNU Public License (GPL),
 * a copy of which is included in this distribution.
 */

package com.jb;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;

import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

/**
 * Provides the the ability to use simple XML property files. Each property is
 * in the form X.Y.Z, which would map to an XML snippet of:
 * <pre>
 * &lt;X&gt;
 *     &lt;Y&gt;
 *         &lt;Z&gt;someValue&lt;/Z&gt;
 *     &lt;/Y&gt;
 * &lt;/X&gt;
 * </pre>
 * <p/>
 * The XML file is passed in to the constructor and must be readable and
 * writtable. Setting property values will automatically persist those value
 * to disk. The file encoding used is UTF-8.
 *
 * @author Derek DeMoro
 * @author Iain Shigeoka
 */
public class XMLProperties {

    private File file;
    private Document document;

    /**
     * Parsing the XML file every time we need a property is slow. Therefore,
     * we use a Map to cache property values that are accessed more than once.
     */
    private Map<String, String> propertyCache = new HashMap<String, String>();

    /**
     * Creates a new XMLPropertiesTest object.
     *
     * @param fileName the full path the file that properties should be read from
     *                 and written to.
     * @throws IOException if an error occurs loading the properties.
     */
    public XMLProperties(String fileName) throws IOException {
        this(new File(fileName));
    }

    /**
     * Loads XML properties from a stream.
     *
     * @param in the input stream of XML.
     * @throws IOException if an exception occurs when reading the stream.
     */
    public XMLProperties(InputStream in) throws IOException {
        Reader reader = new BufferedReader(new InputStreamReader(in));
        buildDoc(reader);
    }

    /**
     * Creates a new XMLPropertiesTest object.
     *
     * @param file the file that properties should be read from and written to.
     * @throws IOException if an error occurs loading the properties.
     */
    public XMLProperties(File file) throws IOException {
        this.file = file;
        if (!file.exists()) {
            // Attempt to recover from this error case by seeing if the
            // tmp file exists. It's possible that the rename of the
            // tmp file failed the last time Jive was running,
            // but that it exists now.
            File tempFile;
            tempFile = new File(file.getParentFile(), file.getName() + ".tmp");
            if (tempFile.exists()) {
            	//TODO
                /*Log.error("WARNING: " + file.getName() + " was not found, but temp file from " +
                        "previous write operation was. Attempting automatic recovery." +
                        " Please check file for data consistency.");*/
                tempFile.renameTo(file);
            }
            // There isn't a possible way to recover from the file not
            // being there, so throw an error.
            else {
                throw new FileNotFoundException("XML properties file does not exist: "
                        + file.getName());
            }
        }
        // Check read and write privs.
        if (!file.canRead()) {
            throw new IOException("XML properties file must be readable: " + file.getName());
        }
        if (!file.canWrite()) {
            throw new IOException("XML properties file must be writable: " + file.getName());
        }

        FileReader reader = new FileReader(file);
        buildDoc(reader);
    }

    /**
     * Returns the value of the specified property.
     *
     * @param name the name of the property to get.
     * @return the value of the specified property.
     */
    public synchronized String getProperty(String name) {
        String value = propertyCache.get(name);
        if (value != null) {
            return value;
        }

        String[] propName = parsePropertyName(name);
        // Search for this property by traversing down the XML heirarchy.
        Element element = document.getRootElement();
        for (int i = 0; i < propName.length; i++) {
            element = element.element(propName[i]);
            if (element == null) {
                // This node doesn't match this part of the property name which
                // indicates this property doesn't exist so return null.
                return null;
            }
        }
        // At this point, we found a matching property, so return its value.
        // Empty strings are returned as null.
        value = element.getTextTrim();
        if ("".equals(value)) {
            return null;
        }
        else {
            // Add to cache so that getting property next time is fast.
            propertyCache.put(name, value);
            return value;
        }
    }

    /**
     * Return all values who's path matches the given property
     * name as a String array, or an empty array if the if there
     * are no children. This allows you to retrieve several values
     * with the same property name. For example, consider the
     * XML file entry:
     * <pre>
     * &lt;foo&gt;
     *     &lt;bar&gt;
     *         &lt;prop&gt;some value&lt;/prop&gt;
     *         &lt;prop&gt;other value&lt;/prop&gt;
     *         &lt;prop&gt;last value&lt;/prop&gt;
     *     &lt;/bar&gt;
     * &lt;/foo&gt;
     * </pre>
     * If you call getProperties("foo.bar.prop") will return a string array containing
     * {"some value", "other value", "last value"}.
     *
     * @param name the name of the property to retrieve
     * @return all child property values for the given node name.
     */
    public String[] getProperties(String name) {
        String[] propName = parsePropertyName(name);
        // Search for this property by traversing down the XML heirarchy,
        // stopping one short.
        Element element = document.getRootElement();
        for (int i = 0; i < propName.length - 1; i++) {
            element = element.element(propName[i]);
            if (element == null) {
                // This node doesn't match this part of the property name which
                // indicates this property doesn't exist so return empty array.
                return new String[]{};
            }
        }
        // We found matching property, return names of children.
        Iterator iter = element.elementIterator(propName[propName.length - 1]);
        List<String> props = new ArrayList<String>();
        String value;
        while (iter.hasNext()) {
            // Empty strings are skipped.
            value = ((Element)iter.next()).getTextTrim();
            if (!"".equals(value)) {
                props.add(value);
            }
        }
        String[] childrenNames = new String[props.size()];
        return props.toArray(childrenNames);
    }

    /**
     * Return all values who's path matches the given property
     * name as a String array, or an empty array if the if there
     * are no children. This allows you to retrieve several values
     * with the same property name. For example, consider the
     * XML file entry:
     * <pre>
     * &lt;foo&gt;
     *     &lt;bar&gt;
     *         &lt;prop&gt;some value&lt;/prop&gt;
     *         &lt;prop&gt;other value&lt;/prop&gt;
     *         &lt;prop&gt;last value&lt;/prop&gt;
     *     &lt;/bar&gt;
     * &lt;/foo&gt;
     * </pre>
     * If you call getProperties("foo.bar.prop") will return a string array containing
     * {"some value", "other value", "last value"}.
     *
     * @param name the name of the property to retrieve
     * @return all child property values for the given node name.
     */
    public Iterator getChildProperties(String name) {
        String[] propName = parsePropertyName(name);
        // Search for this property by traversing down the XML heirarchy,
        // stopping one short.
        Element element = document.getRootElement();
        for (int i = 0; i < propName.length - 1; i++) {
            element = element.element(propName[i]);
            if (element == null) {
                // This node doesn't match this part of the property name which
                // indicates this property doesn't exist so return empty array.
                return Collections.EMPTY_LIST.iterator();
            }
        }
        // We found matching property, return values of the children.
        Iterator iter = element.elementIterator(propName[propName.length - 1]);
        ArrayList<String> props = new ArrayList<String>();
        while (iter.hasNext()) {
            props.add(((Element)iter.next()).getText());
        }
        return props.iterator();
    }

    /**
     * Returns the value of the attribute of the given property name or <tt>null</tt>
     * if it doesn't exist. Note, this
     *
     * @param name the property name to lookup - ie, "foo.bar"
     * @param attribute the name of the attribute, ie "id"
     * @return the value of the attribute of the given property or <tt>null</tt> if
     *      it doesn't exist.
     */
    public String getAttribute(String name, String attribute) {
        if (name == null || attribute == null) {
            return null;
        }
        String[] propName = parsePropertyName(name);
        // Search for this property by traversing down the XML heirarchy.
        Element element = document.getRootElement();
        for (int i = 0; i < propName.length; i++) {
            String child = propName[i];
            element = element.element(child);
            if (element == null) {
                // This node doesn't match this part of the property name which
                // indicates this property doesn't exist so return empty array.
                break;
            }
        }
        if (element != null) {
            // Get its attribute values
            return element.attributeValue(attribute);
        }
        return null;
    }

    

    /**
     * Return all children property names of a parent property as a String array,
     * or an empty array if the if there are no children. For example, given
     * the properties <tt>X.Y.A</tt>, <tt>X.Y.B</tt>, and <tt>X.Y.C</tt>, then
     * the child properties of <tt>X.Y</tt> are <tt>A</tt>, <tt>B</tt>, and
     * <tt>C</tt>.
     *
     * @param parent the name of the parent property.
     * @return all child property values for the given parent.
     */
    public String[] getChildrenProperties(String parent) {
        String[] propName = parsePropertyName(parent);
        // Search for this property by traversing down the XML heirarchy.
        Element element = document.getRootElement();
        for (int i = 0; i < propName.length; i++) {
            element = element.element(propName[i]);
            if (element == null) {
                // This node doesn't match this part of the property name which
                // indicates this property doesn't exist so return empty array.
                return new String[]{};
            }
        }
        // We found matching property, return names of children.
        List children = element.elements();
        int childCount = children.size();
        String[] childrenNames = new String[childCount];
        for (int i = 0; i < childCount; i++) {
            childrenNames[i] = ((Element)children.get(i)).getName();
        }
        return childrenNames;
    }

   

    /**
     * Builds the document XML model up based the given reader of XML data.
     */
    private void buildDoc(Reader in) throws IOException {
        try {
            SAXReader xmlReader = new SAXReader();
            document = xmlReader.read(in);
        }
        catch (Exception e) {
            //Log.error("Error reading XML properties", e);
            throw new IOException(e.getMessage());
        }
        finally {
            if (in != null) {
                in.close();
            }
        }
    }

    

    /**
     * Returns an array representation of the given Jive property. Jive
     * properties are always in the format "prop.name.is.this" which would be
     * represented as an array of four Strings.
     *
     * @param name the name of the Jive property.
     * @return an array representation of the given Jive property.
     */
    private String[] parsePropertyName(String name) {
        List<String> propName = new ArrayList<String>(5);
        // Use a StringTokenizer to tokenize the property name.
        StringTokenizer tokenizer = new StringTokenizer(name, ".");
        while (tokenizer.hasMoreTokens()) {
            propName.add(tokenizer.nextToken());
        }
        return propName.toArray(new String[propName.size()]);
    }

    /*public void setProperties(Map<String, String> propertyMap) {
        for (String propertyName : propertyMap.keySet()) {
            String propertyValue = propertyMap.get(propertyName);
            setProperty(propertyName, propertyValue);
        }
    }*/

    

    
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
在线影视一区二区三区| 中文字幕电影一区| 中文欧美字幕免费| 三级亚洲高清视频| www.综合网.com| 欧美电影免费观看高清完整版在线观看| 国产精品美女久久久久aⅴ| 视频一区二区不卡| 色天天综合久久久久综合片| 26uuu亚洲| 五月天丁香久久| 色欧美片视频在线观看| 欧美国产精品一区| 国产在线精品国自产拍免费| 欧美日韩国产欧美日美国产精品| 国产精品成人午夜| 国产高清不卡一区二区| 欧美成人aa大片| 日韩精品福利网| 欧美日韩亚洲综合在线 | 久久精品欧美日韩精品 | 国产69精品久久777的优势| 欧美一区二区免费视频| 亚洲国产日韩a在线播放性色| 成人动漫一区二区三区| 国产视频一区不卡| 国产91丝袜在线播放0| www欧美成人18+| 久久黄色级2电影| 欧美精品粉嫩高潮一区二区| 亚洲成a人v欧美综合天堂下载 | 欧美一区2区视频在线观看| 亚洲另类色综合网站| eeuss鲁片一区二区三区| 国产日韩欧美不卡在线| 成人永久aaa| 国产精品久久久久久久久果冻传媒 | 欧美日韩国产综合草草| 亚洲一区二区三区在线播放| 欧美性大战久久| 亚洲成人av一区| 欧美一级日韩免费不卡| 久久 天天综合| 久久精品一区蜜桃臀影院| 粉嫩一区二区三区在线看| 欧美激情综合五月色丁香小说| 成人午夜免费视频| 一区二区三区免费| 欧美一级高清片在线观看| 国产一本一道久久香蕉| 国产精品久久久久久一区二区三区 | 成人丝袜18视频在线观看| 中文字幕亚洲在| 欧美午夜电影网| 麻豆视频观看网址久久| 国产亚洲美州欧州综合国| 99久久免费精品| 日韩vs国产vs欧美| 国产调教视频一区| 欧美三区在线观看| 狠狠色2019综合网| 亚洲另类在线一区| 欧美岛国在线观看| 色噜噜狠狠色综合中国| 男女男精品视频| 国产精品福利一区| 日韩精品资源二区在线| 99久免费精品视频在线观看| 视频在线在亚洲| 国产精品久久免费看| 欧美一级黄色大片| 色噜噜狠狠一区二区三区果冻| 久久疯狂做爰流白浆xx| 亚洲免费在线看| 精品美女被调教视频大全网站| 99久久精品国产网站| 日韩va亚洲va欧美va久久| 中文字幕亚洲一区二区av在线| 91.麻豆视频| 99精品黄色片免费大全| 国产呦精品一区二区三区网站| 亚洲国产精品一区二区www| 国产视频一区二区在线| 欧美精品三级日韩久久| 91麻豆国产在线观看| 国产酒店精品激情| 免费高清在线一区| 亚洲成人免费视频| 亚洲日本成人在线观看| 26uuu精品一区二区在线观看| 欧美性猛交xxxx黑人交| 99久精品国产| 国产成人午夜片在线观看高清观看| 五月天久久比比资源色| 一区二区三区在线不卡| 国产精品视频一二三区| 国产无遮挡一区二区三区毛片日本| 日韩一区二区免费电影| 欧美日韩成人综合在线一区二区| av一二三不卡影片| 成人开心网精品视频| 国产剧情一区二区| 国产麻豆视频一区二区| 国内精品在线播放| 久久精品999| 久久丁香综合五月国产三级网站 | 欧美高清www午色夜在线视频| 色吧成人激情小说| 日本精品裸体写真集在线观看| 成人性视频免费网站| 国产精品18久久久久久久网站| 激情国产一区二区| 国内精品国产三级国产a久久| 捆绑紧缚一区二区三区视频| 日韩精彩视频在线观看| 日韩va欧美va亚洲va久久| 日韩精品一卡二卡三卡四卡无卡| 亚洲高清视频中文字幕| 亚洲午夜激情网页| 美女一区二区久久| 国产又黄又大久久| 成人午夜视频福利| 在线一区二区三区做爰视频网站| 91香蕉国产在线观看软件| 色噜噜偷拍精品综合在线| 欧美综合亚洲图片综合区| 欧美日韩亚洲不卡| 日韩一级大片在线| 久久久久久日产精品| 国产精品视频你懂的| 一区二区三区中文字幕| 亚洲自拍另类综合| 精品在线免费视频| 成人黄色电影在线| 色偷偷成人一区二区三区91 | 性做久久久久久久久| 天天色图综合网| 国产乱对白刺激视频不卡| 91丨国产丨九色丨pron| 欧美精品一卡二卡| 国产视频一区在线观看| 亚洲一区二区三区中文字幕 | 偷拍亚洲欧洲综合| 国产一区二区视频在线| 成人黄色在线网站| 欧美老年两性高潮| 日本一区二区三区高清不卡| 亚洲欧美日韩系列| 久久国产精品第一页| 色噜噜狠狠一区二区三区果冻| 7777精品伊人久久久大香线蕉 | 久久亚区不卡日本| 亚洲色图欧美激情| 捆绑调教一区二区三区| 色悠久久久久综合欧美99| 欧美丰满嫩嫩电影| 中文字幕亚洲精品在线观看| 日日嗨av一区二区三区四区| 国产一区 二区| 欧美精品色一区二区三区| 亚洲欧洲日产国码二区| 美女视频一区二区| 色婷婷综合久久久久中文 | 国产剧情一区在线| 欧美日韩国产在线观看| 中文字幕日韩一区二区| 六月丁香婷婷久久| 欧美视频在线观看一区二区| 久久女同性恋中文字幕| 午夜亚洲国产au精品一区二区| 国产99久久久国产精品免费看| 制服丝袜一区二区三区| √…a在线天堂一区| 国产伦理精品不卡| 欧美一级二级三级乱码| 亚洲一二三区不卡| 波多野结衣视频一区| 国产亚洲综合色| 视频一区在线视频| 欧美日韩高清一区二区| 亚洲免费在线视频一区 二区| 大白屁股一区二区视频| 精品国产免费视频| 麻豆成人免费电影| 欧美精品123区| 亚洲aaa精品| 欧美无砖砖区免费| 亚洲图片欧美综合| 欧美日韩和欧美的一区二区| 亚洲激情六月丁香| 色8久久人人97超碰香蕉987| 国产精品久久久久国产精品日日| 久久国产乱子精品免费女| 欧美顶级少妇做爰| 天天做天天摸天天爽国产一区| 欧美日韩中文一区| 亚洲第一激情av| 制服丝袜中文字幕一区| 日本一不卡视频| 欧美一区二区免费视频|