KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > bsf > smartValueObject > VersionableFilters


1 package org.bsf.smartValueObject;
2
3 /**
4  * A helper class providing implementations for some common filters.
5  *
6  * @see org.bsf.smartValueObject.VersionableFilter
7  * @see org.bsf.smartValueObject.Versionable
8  */

9 public class VersionableFilters {
10     /**
11      * No filter, get all objects.
12      */

13     public static final VersionableFilter ALL =
14         new VersionableFilter() {
15             public boolean accept(Versionable v) {
16                 return true;
17             }
18         };
19
20     /**
21      * Get only deleted objects.
22      */

23     public static final VersionableFilter DELETED =
24         new VersionableFilter() {
25             public boolean accept(Versionable v) {
26                 return v.isDeleted();
27             }
28         };
29
30     /**
31      * Get newly created objects.
32      */

33     public static final VersionableFilter CREATED =
34         new VersionableFilter() {
35             public boolean accept(Versionable v) {
36                 return v.isCreated() && !v.isDeleted();
37             }
38         };
39
40     /**
41      * Get object that actually exist.
42      */

43     public static final VersionableFilter EXISTING =
44           new VersionableFilter() {
45             public boolean accept(Versionable v) {
46                 return !v.isDeleted();
47             }
48         };
49
50     /**
51      * Get modified (dirty) objects.
52      */

53     public static final VersionableFilter DIRTY =
54         new VersionableFilter() {
55             public boolean accept(Versionable v) {
56                 return v.isDirty();
57             }
58         };
59
60     /**
61      * Gets smart container objects.
62      */

63     public static final VersionableFilter SMARTCONTAINER =
64         new VersionableFilter() {
65             public boolean accept(Versionable v) {
66                 return SmartAccess.isSmartContainer(v);
67             }
68         };
69 }
70
Popular Tags