Example usage for org.apache.commons.jxpath JXPathException getMessage

List of usage examples for org.apache.commons.jxpath JXPathException getMessage

Introduction

In this page you can find the example usage for org.apache.commons.jxpath JXPathException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Return the message (if any) for this error .

Usage

From source file:org.mskcc.pathdb.lucene.ConfigurableIndexCollector.java

/**
 * get the list of tokens collected from the entry
 *
 * @return ArrayList of Strings//from  w ww .j a  va  2 s  .  co  m
 */
public ArrayList getIndexTokens() {
    ArrayList returnTokens = new ArrayList();

    try {
        if (currentConfigInfo != null) {
            Iterator fNameIterator = context.iterate(currentConfigInfo.getXpath());
            debug("Path: " + currentConfigInfo.getXpath());
            while (fNameIterator.hasNext()) {
                // force entry to be turned into a string, to convert
                // Integers and Strings alike
                String element = "" + fNameIterator.next();

                if (element != null && !element.trim().equals("")) {
                    debug("\t[" + element + "]");
                    returnTokens.add(element.trim());
                }
            }
        }
    } catch (JXPathException e) {
        warn(e.getMessage());
    }
    return returnTokens;
}

From source file:org.opennms.protocols.json.collector.AbstractJsonCollectionHandler.java

/**
 * Fill collection set.//from   w  w w. j a  va2s .co m
 *
 * @param agent the agent
 * @param collectionSet the collection set
 * @param source the source
 * @param json the JSON Object
 * @throws ParseException the parse exception
 */
@SuppressWarnings("unchecked")
protected void fillCollectionSet(CollectionAgent agent, XmlCollectionSet collectionSet, XmlSource source,
        JSONObject json) throws ParseException {
    XmlCollectionResource nodeResource = new XmlSingleInstanceCollectionResource(agent);
    JXPathContext context = JXPathContext.newContext(json);
    for (XmlGroup group : source.getXmlGroups()) {
        LOG.debug("fillCollectionSet: getting resources for XML group {} using XPATH {}", group.getName(),
                group.getResourceXpath());
        Date timestamp = getTimeStamp(context, group);
        Iterator<Pointer> itr = context.iteratePointers(group.getResourceXpath());
        while (itr.hasNext()) {
            JXPathContext relativeContext = context.getRelativeContext(itr.next());
            String resourceName = getResourceName(relativeContext, group);
            LOG.debug("fillCollectionSet: processing XML resource {} of type {}", resourceName,
                    group.getResourceType());
            XmlCollectionResource collectionResource;
            if (group.getResourceType().equalsIgnoreCase(CollectionResource.RESOURCE_TYPE_NODE)) {
                collectionResource = nodeResource;
            } else {
                collectionResource = getCollectionResource(agent, resourceName, group.getResourceType(),
                        timestamp);
            }
            LOG.debug("fillCollectionSet: processing resource {}", collectionResource);
            AttributeGroupType attribGroupType = new AttributeGroupType(group.getName(), group.getIfType());
            for (XmlObject object : group.getXmlObjects()) {
                try {
                    Object obj = relativeContext.getValue(object.getXpath());
                    if (obj != null) {
                        String value = obj.toString();
                        XmlCollectionAttributeType attribType = new XmlCollectionAttributeType(object,
                                attribGroupType);
                        collectionResource.setAttributeValue(attribType, value);
                    }
                } catch (JXPathException ex) {
                    LOG.warn("Unable to get value for {}: {}", object.getXpath(), ex.getMessage());
                }
            }
            processXmlResource(collectionResource, attribGroupType);
            collectionSet.getCollectionResources().add(collectionResource);
        }
    }
}

From source file:pt.webdetails.cdf.dd.util.XPathUtils.java

public static boolean getBooleanValue(JXPathContext node, String xPath) {

    boolean value = false;
    try {// ww w.j av a 2  s .  c  o m
        value = ((Boolean) node.getValue("boolean(" + xPath + " = \"true\")")).booleanValue();
    } catch (JXPathException e) {
        logger.error(e.getMessage());
    }

    return value;
}

From source file:pt.webdetails.cdf.dd.util.XPathUtils.java

public static String getArrayValue(JXPathContext node, String xPath) {

    String value = "";
    try {/*from  w ww  .  j a v a 2s  .co  m*/
        JSONArray values = new JSONArray(node.selectNodes(xPath));
        value = values.toString();
    } catch (JXPathException e) {
        logger.error(e.getMessage());
    }

    return value;
}