cacheConfig.xml中读取配置文件信息三2010-07-07




    /** 解析默认Keyspace.
     */
    private String readDefaultKeyspace(XPath aXpath, Document aDoc)
        throws XPathExpressionException
    {
        XPathExpression pathExpression = aXpath.compile("//defaultKeyspace");
        Node node = (Node) pathExpression.evaluate(aDoc, XPathConstants.NODE);
        return node.getTextContent();
    }

    /** 解析默认ColumnFamily
     * @param aDoc 文档对象
     * @return String 默认ColumnFamily
     */
    private String readDefaultColumnFamily(XPath aXpath, Document aDoc)
        throws XPathExpressionException
    {
        XPathExpression pathExpression =
            aXpath.compile("//defaultColumnFamily");
        Node node = (Node) pathExpression.evaluate(aDoc, XPathConstants.NODE);
        return node.getTextContent();
    }

    /** 解析DataBindings.
     * @param aDoc 文档对象
     */
    private Map<String, String> readDataBindingMap(XPath aXpath, Document aDoc)
        throws XPathExpressionException
    {
        Map<String, String> dataBindingMap = new HashMap<String, String>();
        XPathExpression pathExpression =
            aXpath.compile("//dataBindings/property");
        NodeList nodeList = (NodeList) pathExpression.evaluate(aDoc,
                XPathConstants.NODESET);
        String name = null;
        String value = null;
        for (int i = 0; i < nodeList.getLength(); i++)
        {
            name = nodeList.item(i)
                    .getAttributes()
                    .getNamedItem("name")
                    .getNodeValue();
            value = nodeList.item(i)
                    .getAttributes()
                    .getNamedItem("value")
                    .getNodeValue();
            dataBindingMap.put(name, value);
        }
        return dataBindingMap;
    }
}

你可能感兴趣的:(xml)