Jxpath is a Java implementation of the XPath provided by Apache, part of the Jakarta, and the latest version is 1.1,jxpath's main feature is a set of Java class libraries that use XPath to access Java classes that conform to the JavaBeans specification, Java Collections (collections), other objects with dynamic properties (such as map, ServletContext, and so on) provide a set of extension mechanisms that allow us to increase support for other object models outside of these objects.
Download Address: http://commons.apache.org/jxpath/
A. Accessing the JavaBean properties
package Demo.bean;
Import Java.util.Comparator;
public class, company implements Comparator<object> .... {
Private String name = "";
private int id = 0;
Private String address = "";
public void SetName (String p_name) ... {
THIS.name = p_name;
}
public void setId (int p_id) ... {
This.id = p_id;
}
public void setaddress (String p_address) ... {
This.address = p_address;
}
Public String getName () ... {
return this.name;
}
Public int getId () ... {
return this.id;
}
Public String getaddress () ... {
return this.address;
}
Public int compare (object O1, Object O2) ... {
return 0;
}
Public boolean equals (Object obj) ... {
Boolean result = false;
if (obj instanceof Company) ... {
Company company = [Company] obj;
if (Company.getid () ==this.id && comPany.getname (). Equals (This.getname ())
&& company.getaddress (). Equals (This.getaddress ())
result = true;
}
return result;
}
}