commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From 青木 正平 <bs-sa...@bs.swh.nttdata.co.jp>
Subject [JXPath] iteratePointers() cannot get null value
Date Mon, 27 Feb 2006 10:14:55 GMT

Hi all,

I'm using JXPath 1.2, and I want to get null value from a JavaBean, 
but not successful.

If a property is java.lang.String type, I can get null value, 
but do not get null value in a final modifer type
(for example, Date type and Object type).

The following is a sample.
----------------------------------------------------------
/* ******* JavaBean ******* */
public class Employee {
    private Object firstName;
    private String secondName;
    public Object getFirstName() {
        return firstName;
    }
    public String getSecondName() {
        return secondName;
    }
    ......
}

/* ******* Access String Type ******* */
Employee emp = new Employee();
emp.setSecondName(null);
JXPathContext context = JXPathContext.newContext(emp);
Iterator itr = context.iteratePointers("/secondName");

// hasNext ---> true
while (itr.hasNext()) {
    // Invoked and get null value.
    Pointer p = (Pointer) itr.next();
    System.out.println("'secondName' value --- " + p.getValue());
}
// This cord outputs the following messages. 
// 'secondName' value --- null


/* ******* Access Object Type ******* */
Employee emp = new Employee();
emp.setFirstName(null);
JXPathContext context = JXPathContext.newContext(emp);
Iterator itr = context.iteratePointers("/firstName");

// hasNext() ---> false
// I think that there should be one null value...
while (itr.hasNext()) {
    // Not Invoked.
    Pointer p = (Pointer) itr.next();
    System.out.println("'firstName' value --- " + p.getValue());
}
// This cord outputs nothing.
----------------------------------------------------------
When I take an element of Map, a similar problem happens.

Would you teach me a good method to solve this problem?

Regards,
Shohei Aoki


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message