Example usage for org.dom4j.io XPP3Reader XPP3Reader

List of usage examples for org.dom4j.io XPP3Reader XPP3Reader

Introduction

In this page you can find the example usage for org.dom4j.io XPP3Reader XPP3Reader.

Prototype

public XPP3Reader() 

Source Link

Usage

From source file:org.compass.core.xml.dom4j.converter.XPP3ReaderXmlContentConverter.java

License:Apache License

protected XPP3Reader doCreateXPP3Reader(CompassSettings settings) {
    return new XPP3Reader();
}

From source file:org.jivesoftware.site.Versions.java

License:Open Source License

/**
 * Returns the product information for all products defined in <tt>versions.xml</tt>. Note that this method call
 * uses cached data./*  w  ww . j a v  a2s.  c om*/
 *
 * @return A list of product names (never null).
 */
public static synchronized Map<String, Product> getProducts() {
    if (products.isEmpty() || cacheDate + 60000 < System.currentTimeMillis()) {
        try (InputStream in = Versions.class.getResourceAsStream("/versions.xml")) {
            final Iterator iter = new XPP3Reader().read(in).getRootElement().elementIterator("product");

            final Map<String, Product> update = new HashMap<>();
            while (iter.hasNext()) {
                final Element element = (Element) iter.next();

                final String name = element.attributeValue("name");
                final String version = element.attributeValue("version");
                final String date = element.attributeValue("date");

                final Product product = new Product(name, version, date);

                update.put(name, product);
            }

            products = update; // Replace old values with new ones.
            cacheDate = System.currentTimeMillis();
        } catch (XmlPullParserException | DocumentException | IOException e) {
            Log.warn("Unable to load version information from versions.xml.", e);
        }
    }
    return products;
}