|
@@ -3,95 +3,78 @@ |
3 |
3 |
|
|
4 |
4 |
|
import org.litesoft.commonfoundation.typeutils.Objects; |
5 |
5 |
|
|
6 |
|
- |
import java.io.Serializable; |
|
6 |
+ |
import java.io.*; |
7 |
7 |
|
import java.util.*; |
8 |
8 |
|
|
9 |
|
- |
public class ViewObjectSet implements Serializable |
10 |
|
- |
{ |
|
9 |
+ |
public class ViewObjectSet implements Serializable { |
11 |
10 |
|
private static final long serialVersionUID = 1L; |
12 |
11 |
|
|
13 |
12 |
|
private VOMap mMembers = new VOMap(); |
14 |
13 |
|
|
15 |
|
- |
public synchronized boolean isEmpty() |
16 |
|
- |
{ |
|
14 |
+ |
public synchronized boolean isEmpty() { |
17 |
15 |
|
return mMembers.isEmpty(); |
18 |
16 |
|
} |
19 |
17 |
|
|
20 |
|
- |
public synchronized int size() |
21 |
|
- |
{ |
|
18 |
+ |
public synchronized int size() { |
22 |
19 |
|
return mMembers.size(); |
23 |
20 |
|
} |
24 |
21 |
|
|
25 |
|
- |
public synchronized ViewObject get( ObjectURL pObjectURL ) |
26 |
|
- |
{ |
|
22 |
+ |
public synchronized ViewObject get( ObjectURL pObjectURL ) { |
27 |
23 |
|
return mMembers.get( pObjectURL ); |
28 |
24 |
|
} |
29 |
25 |
|
|
30 |
|
- |
public synchronized void clear() |
31 |
|
- |
{ |
|
26 |
+ |
public synchronized void clear() { |
32 |
27 |
|
mMembers.clear(); |
33 |
28 |
|
} |
34 |
29 |
|
|
35 |
|
- |
public synchronized ViewObject add( ViewObject pViewObject ) |
36 |
|
- |
{ |
37 |
|
- |
if ( pViewObject != null ) |
38 |
|
- |
{ |
|
30 |
+ |
public synchronized ViewObject add( ViewObject pViewObject ) { |
|
31 |
+ |
if ( pViewObject != null ) { |
39 |
32 |
|
mMembers.put( pViewObject.getObjectURL(), pViewObject ); |
40 |
33 |
|
} |
41 |
34 |
|
return pViewObject; |
42 |
35 |
|
} |
43 |
36 |
|
|
44 |
|
- |
public synchronized boolean remove( ViewObject pViewObject ) |
45 |
|
- |
{ |
|
37 |
+ |
public synchronized boolean remove( ViewObject pViewObject ) { |
46 |
38 |
|
return (pViewObject != null) && (null != mMembers.remove( pViewObject.getObjectURL() )); |
47 |
39 |
|
} |
48 |
40 |
|
|
49 |
41 |
|
/** |
50 |
42 |
|
* @return Your own personal Set - To do with it as you please! |
51 |
43 |
|
*/ |
52 |
|
- |
public synchronized Set<ViewObject> getAllMembers() |
53 |
|
- |
{ |
|
44 |
+ |
public synchronized Set<ViewObject> getAllMembers() { |
54 |
45 |
|
return new HashSet<ViewObject>( mMembers.values() ); |
55 |
46 |
|
} |
56 |
47 |
|
|
57 |
48 |
|
@Override |
58 |
|
- |
public synchronized String toString() |
59 |
|
- |
{ |
|
49 |
+ |
public synchronized String toString() { |
60 |
50 |
|
StringBuilder zSB = new StringBuilder(); |
61 |
51 |
|
LLtitle( zSB ); |
62 |
52 |
|
int zSize = size(); |
63 |
|
- |
if ( zSize == 0 ) |
64 |
|
- |
{ |
|
53 |
+ |
if ( zSize == 0 ) { |
65 |
54 |
|
zSB.append( " - No Members" ); |
66 |
|
- |
} |
67 |
|
- |
else |
68 |
|
- |
{ |
|
55 |
+ |
} else { |
69 |
56 |
|
zSB.append( " - " ).append( zSize ).append( " Members:" ).append( '\n' ); |
70 |
57 |
|
Iterator<ViewObject> zIterator = mMembers.values().iterator(); |
71 |
58 |
|
String[] zMembers = new String[zSize]; |
72 |
|
- |
for ( int i = 0; i < zMembers.length; i++ ) |
73 |
|
- |
{ |
|
59 |
+ |
for ( int i = 0; i < zMembers.length; i++ ) { |
74 |
60 |
|
zMembers[i] = zIterator.next().toString(); |
75 |
61 |
|
} |
76 |
62 |
|
Arrays.sort( zMembers ); |
77 |
|
- |
for ( String zMember : zMembers ) |
78 |
|
- |
{ |
|
63 |
+ |
for ( String zMember : zMembers ) { |
79 |
64 |
|
zSB.append( " " ).append( zMember ).append( '\n' ); |
80 |
65 |
|
} |
81 |
66 |
|
} |
82 |
67 |
|
return zSB.toString(); |
83 |
68 |
|
} |
84 |
69 |
|
|
85 |
|
- |
protected void LLtitle( StringBuilder pSB ) |
86 |
|
- |
{ |
|
70 |
+ |
protected void LLtitle( StringBuilder pSB ) { |
87 |
71 |
|
pSB.append( Objects.justClassNameOf( this ) ); |
88 |
72 |
|
} |
89 |
73 |
|
|
90 |
74 |
|
/** |
91 |
75 |
|
* @author matg don't know why, but GWT will not serialize this when private |
92 |
76 |
|
*/ |
93 |
|
- |
static class VOMap extends HashMap<ObjectURL, ViewObject> implements Serializable |
94 |
|
- |
{ |
|
77 |
+ |
static class VOMap extends HashMap<ObjectURL, ViewObject> implements Serializable { |
95 |
78 |
|
private static final long serialVersionUID = 1L; |
96 |
79 |
|
} |
97 |
80 |
|
} |