gvsig-tools / org.gvsig.tools / library / trunk / org.gvsig.tools / org.gvsig.tools.lib / src / main / java / org / gvsig / tools / observer / BaseNotification.java @ 3086
History | View | Annotate | Download (1.85 KB)
1 |
package org.gvsig.tools.observer; |
---|---|
2 |
|
3 |
import org.apache.commons.lang3.builder.ToStringBuilder; |
4 |
|
5 |
public class BaseNotification implements Notification { |
6 |
|
7 |
private final String type; |
8 |
protected Object[] values; |
9 |
protected boolean canceled = false; |
10 |
private boolean aborted; |
11 |
|
12 |
public BaseNotification(String type, int values) { |
13 |
this.type = type;
|
14 |
this.values = new Object[values]; |
15 |
} |
16 |
|
17 |
public BaseNotification(String type, Object[] values) { |
18 |
this.type = type;
|
19 |
this.values = values;
|
20 |
} |
21 |
|
22 |
@Override
|
23 |
public String getType() { |
24 |
return this.type; |
25 |
} |
26 |
|
27 |
@Override
|
28 |
public boolean isOfType(String type) { |
29 |
return type.equalsIgnoreCase(this.type); |
30 |
} |
31 |
|
32 |
@Override
|
33 |
public Object getValue() { |
34 |
if( this.values==null ) { |
35 |
return null; |
36 |
} |
37 |
return this.values[0]; |
38 |
} |
39 |
|
40 |
@Override
|
41 |
public Object getValue(int n) { |
42 |
if( this.values==null ) { |
43 |
return null; |
44 |
} |
45 |
return this.values[n]; |
46 |
} |
47 |
|
48 |
@Override
|
49 |
public void setValue(Object value) { |
50 |
this.values[0] = value; |
51 |
} |
52 |
|
53 |
@Override
|
54 |
public void setValue(int n, Object value) { |
55 |
this.values[n] = value;
|
56 |
} |
57 |
|
58 |
@Override
|
59 |
public boolean isCanceled() { |
60 |
return this.canceled; |
61 |
} |
62 |
|
63 |
@Override
|
64 |
public void cancel() { |
65 |
this.canceled = true; |
66 |
} |
67 |
|
68 |
@Override
|
69 |
public boolean isAborted() { |
70 |
return this.aborted; |
71 |
} |
72 |
|
73 |
@Override
|
74 |
public void abort() { |
75 |
this.aborted = true; |
76 |
} |
77 |
|
78 |
@Override
|
79 |
public String toString() { |
80 |
try {
|
81 |
ToStringBuilder builder = new ToStringBuilder(this); |
82 |
builder.append("type", type);
|
83 |
builder.append("values", values);
|
84 |
return builder.build();
|
85 |
} catch(Throwable th) { |
86 |
return super.toString(); |
87 |
} |
88 |
} |
89 |
|
90 |
} |
91 |
|