1 package org.lsst.ccs.bus;
2
3 import java.util.HashMap;
4 import java.util.List;
5 import java.util.Map;
6
7
8
9
10
11
12
13
14
15
16
17 public class TrendingStatus extends DataStatus_Deprecated {
18
19 private static final long serialVersionUID = 6585487433733821541L;
20
21
22
23 public TrendingStatus() {
24 }
25
26
27 @Deprecated
28 public TrendingStatus(Object value) {
29 super();
30 this.value = value;
31 }
32
33 public TrendingStatus(DataValueNotification value) {
34 super() ;
35 this.value = value ;
36 }
37
38 public TrendingStatus(List<? extends ValueNotification> list) {
39 super() ;
40 this.value = list ;
41
42 }
43
44 public String dummy() {
45 return "dummy" ;
46 }
47
48
49
50
51
52
53 @Deprecated
54 public Object getValue() {
55 try {
56 return getData();
57 } catch (ClassNotFoundException e) {
58 return value ;
59 }
60 }
61
62 @Override
63 public Object getData() throws ClassNotFoundException {
64
65 if(value instanceof ObjectNType) {
66 return ((ObjectNType) value).getData();
67 }
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93 return value ;
94 }
95
96
97
98
99
100
101
102
103 public Map<String, ObjectNType> getTrendingMap() {
104 if(value instanceof DataValueNotification) {
105 return ((DataValueNotification)value).getTrendingMap() ;
106 } else if (value instanceof List) {
107
108 HashMap<String,ObjectNType> mapres = new HashMap<String, ObjectNType>() ;
109 for(Object member : (List) value) {
110 if(! (member instanceof DataValueNotification)) {
111
112 return null ;
113 }
114 Map<String, ObjectNType> mapDVN = ((DataValueNotification)member).getTrendingMap() ;
115 if(mapDVN != null) {
116 mapres.putAll(mapDVN);
117 }
118 }
119 return mapres ;
120 }
121 return null ;
122 }
123
124 @Deprecated
125 public void setValue(Object value) {
126 this.value = value;
127 }
128
129 @Override
130 public boolean isOfWellKnownType() {
131 if(value instanceof ObjectNType) {
132 return ((ObjectNType) value).isOfWellKnownType();
133 }
134 if(value instanceof DataValueNotification) {
135 return ((DataValueNotification)value).isOfWellKnownType() ;
136 }
137
138 if(value instanceof List) {
139 return false ;
140 }
141 return true ;
142 }
143
144 @Override
145 public boolean isOfPrimitiveType() {
146 if(value instanceof ObjectNType) {
147 return ((ObjectNType) value).isOfPrimitiveType();
148 }
149 if(value instanceof DataValueNotification) {
150 return ((DataValueNotification)value).isOfPrimitiveType() ;
151 }
152 return false ;
153 }
154 @Override
155 public String getDataClassName() {
156 if(value instanceof DataValueNotification) {
157 return ((DataValueNotification)value).getObjectNType().getClassName() ;
158 }
159 return super.getDataClassName() ;
160 }
161
162 @Override
163 public String toString() {
164 Object val = null ;
165 try {
166 val = getData() ;
167 } catch (ClassNotFoundException e) {
168 val = "object_class_not_found" ;
169 }
170 return "TrendingStatus(" + origin + ") @" + timeStamp + " : [" + state + "] "
171 + summary+ "("+ val +")";
172 }
173
174 }