You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Willem Jiang (JIRA)" <ji...@apache.org> on 2012/05/18 04:36:15 UTC
[jira] [Assigned] (CAMEL-5276) Wish ObjectHelper wouldn't return
false for a node without children
[ https://issues.apache.org/jira/browse/CAMEL-5276?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Willem Jiang reassigned CAMEL-5276:
-----------------------------------
Assignee: Willem Jiang
> Wish ObjectHelper wouldn't return false for a node without children
> -------------------------------------------------------------------
>
> Key: CAMEL-5276
> URL: https://issues.apache.org/jira/browse/CAMEL-5276
> Project: Camel
> Issue Type: Wish
> Components: camel-core
> Affects Versions: 2.8.5
> Reporter: Bobby Hargett
> Assignee: Willem Jiang
> Labels: util
>
> org.apache.camel.util.ObjectHelper's method evaluateValuePredicate(Object) tests to see if an object of type NodeList has any children. If it doesn't have any children it return false?
> What if you have an Element that just has attributes and that is all you need? Would it be possible to check if the object passed in is a Node first and then check to see if it is a list...
> The offending(?) code
> {noformat}
> /**
> * Evaluate the value as a predicate which attempts to convert the value to
> * a boolean otherwise true is returned if the value is not null
> */
> public static boolean evaluateValuePredicate(Object value) {
> if (value instanceof Boolean) {
> return (Boolean)value;
> } else if (value instanceof String) {
> if ("true".equalsIgnoreCase((String)value)) {
> return true;
> } else if ("false".equalsIgnoreCase((String)value)) {
> return false;
> }
> } else if (value instanceof NodeList) { //Test for Node here?
> // is it an empty dom
> NodeList list = (NodeList) value;
> return list.getLength() > 0;
> } else if (value instanceof Collection) {
> // is it an empty collection
> Collection<?> col = (Collection<?>) value;
> return col.size() > 0;
> }
> return value != null;
> }
> {noformat}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira