Thứ Ba, 29 tháng 7, 2014

Apply filter

Demo :Create an application to get only name of employees of departmant 24, that has status contact ( using xml  file in sample )


B1:Tạo mới java application,gồm các components sau:



B2:Tạo class DataFilter để tạo ra filter



B3:Tạo file employees.xml có nội dung như sau

B4:Code cho class DataProcess,viết hàm để xử lý lỗi



B5:Code cho hàm main


Kết quả:



Nhận xét:Việc sử dụng filter giúp cho việc kiểm soát dữ liệu tốt hơn,ứng dụng chạy mượt hơn 
-quá trình xử lý lỗi tốt hơn,lỗi ít hơn.
-Filter giúp lọc dữ liệu giữa XML và Handler khi ta không muốn đọc toàn bộ file XML.










Không có nhận xét nào:

Đăng nhận xét