-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRTMLDocument.java
More file actions
1678 lines (1590 loc) · 47.1 KB
/
RTMLDocument.java
File metadata and controls
1678 lines (1590 loc) · 47.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
Copyright 2006, Astrophysics Research Institute, Liverpool John Moores University.
This file is part of org.estar.rtml.
org.estar.rtml is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
org.estar.rtml is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with org.estar.rtml; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
// RTMLDocument.java
// $Header: /space/home/eng/cjm/cvs/org_estar_rtml/RTMLDocument.java,v 1.21 2016-06-08 13:57:33 cjm Exp $
package org.estar.rtml;
import java.io.*;
import java.text.*;
import java.util.*;
/**
* This class is a data container for information contained in the base nodes/tags of an RTML document.
* @author Chris Mottram
* @version $Revision$
* @see org.estar.rtml.RTMLDeviceHolder
* @see org.estar.rtml.RTMLTargetHolder
*/
public class RTMLDocument implements Serializable, RTMLDeviceHolder, RTMLTargetHolder
{
/**
* Revision control system version id.
*/
public final static String RCSID = "$Id$";
/**
* Serial version ID. Fixed as these documents can be used as parameters in RMI calls across JVMs.
*/
static final long serialVersionUID = -8805723117207611978L;
/**
* Constant representing the value of the RTML version attribute specifying RTML version 2.2.
* @see #version
*/
public final static String RTML_VERSION_22 = "2.2";
/**
* Constant representing the value of the RTML version attribute specifying RTML version 3.1a.
* @see #version
*/
public final static String RTML_VERSION_31 = "3.1a";
/**
* The RTML version of the document.
* @see #RTML_VERSION_22
* @see #RTML_VERSION_31
*/
public String version = null;
/**
* The type of the document, as specified in the RTML node's "type" attribute, of type %rtmlDocumentModes;.
* Only used in RTML 2.2 documents, the equivalent is "mode" in RTML 3.1.
* See the DTD for possible values, such as: score, request, confirmation, information, update, observation,
* reject, fail, abort, incomplete.
*/
public String type = null;
/**
* The mode of the document, as specified in the RTML node's "mode" attribute.
* Only used in RTML 3.1 documents, the equivalent is "type" in RTML 2.2.
* See the schema for possible values, such as: abort, acknowledged, complete, confirm, fail, incomplete,
* inquiry, offer, reject, report, request, resource, update .
*/
public String mode = null;
/**
* The unique ID of the document, as specified in the RTML node's "uid" attribute.
* Only used in RTML 3.1 documents, the equivalent is some element of IntelligentAgent in RTML 2.2.
*/
public String uid = null;
/**
* The details contained in the IntelligentAgent tag/node.
*/
public RTMLIntelligentAgent intelligentAgent = null;
/**
* History info for this document.
*/
protected RTMLHistory history = null;
/**
* Contact info for this document.
*/
protected RTMLContact contact = null;
/**
* Project info for this document.
*/
protected RTMLProject project = null;
/**
* Telescope info for this document.
*/
protected RTMLTelescope telescope = null;
/**
* The instrument device this document wants to use.
* This can be null, with each Observation in the document having it's own Device.
*/
public RTMLDevice device = null;
/**
* The target of this document.
* This can be null, with each Observation in the document having it's own Target.
*/
private RTMLTarget target = null;
/**
* List containing observations.
*/
public List observationList = null;
/**
* The score of the document. Note this should be a per observation score, according to the DTD.
*/
public Double score = null;
/**
* A list of Score tags in a Scores tag, with probability/cumulative probability and delays.
*/
public List scoresList = null;
/**
* The completion time. Note this should be a per observation score, according to the DTD.
*/
public Date completionTime = null;
/**
* Error String contained in TEXT node of RTML document, if document has type reject.
*/
public String errorString = null;
/**
* Default constructor. Initialise scoresList and observationList.
* @see #observationList
* @see #scoresList
*/
public RTMLDocument()
{
super();
observationList = new Vector();
scoresList = new Vector();
}
/**
* Set the RTML version of the document.
* @param s The version.
* @see #version
* @see #RTML_VERSION_22
* @see #RTML_VERSION_31
*/
public void setVersion(String s)
{
version = s;
}
/**
* Get the RTML version of the document.
* @return The version.
* @see #version
* @see #RTML_VERSION_22
* @see #RTML_VERSION_31
*/
public String getVersion()
{
return version;
}
/**
* Set the type of the document (RTML 2.2).
* @param s The type.
* @see #type
*/
public void setType(String s)
{
type = s;
}
/**
* Get the type of the document.
* @return The type.
* @see #type
*/
public String getType()
{
return type;
}
/**
* Set the mode of the document (RTML 3.1).
* @param s The mode.
* @see #mode
*/
public void setMode(String s)
{
mode = s;
}
/**
* Get the mode of the document.
* @return The mode.
* @see #mode
*/
public String getMode()
{
return mode;
}
/**
* Set the Unique ID of the document (RTML 3.1).
* @param s The uid.
* @see #uid
*/
public void setUId(String s)
{
uid = s;
}
/**
* Get the Unique ID of the document. This is retrieved from the intelligent agent ID if that has been set
* (usually from RTML 2.2 documents),
* or from the document uid (RTML 3.1a documents). The uid takes preference if it is non-null.
* @return The uid.
* @see #uid
* @see #intelligentAgent
*/
public String getUId()
{
String s = null;
// if the intelligent agent data exists
if(intelligentAgent != null)
{
// we can use the id (extracted from the PCDATA) as the uid in RTML2.2 documents
if(intelligentAgent.getId() != null)
s = intelligentAgent.getId();
}
// RTML 3.1a documents should have the uid attribute of the document itself set
// This should override the intelligent agent data if it exists
if(uid != null)
s = uid;
return s;
}
/**
* Is this document a score request document?
* @return true if the document is a score request, false otherwise.
* @see #version
* @see #type
* @see #mode
* @see #RTML_VERSION_22
* @see #RTML_VERSION_31
*/
public boolean isScoreRequest()
{
// if we don't know what version of RTML this doc is, return false.
if(version == null)
return false;
if(version.equals(RTML_VERSION_22) && (type.equals("score")))
return true;
if(version.equals(RTML_VERSION_31) && (mode.equals("inquiry")))
return true;
return false;
}
/**
* Is this document a reject document?
* @return true if the document is a reject, false otherwise.
* @see #version
* @see #type
* @see #mode
* @see #RTML_VERSION_22
* @see #RTML_VERSION_31
*/
public boolean isReject()
{
// if we don't know what version of RTML this doc is, return false.
if(version == null)
return false;
if(version.equals(RTML_VERSION_22) && (type.equals("reject")))
return true;
if(version.equals(RTML_VERSION_31) && (mode.equals("reject")))
return true;
return false;
}
/**
* Is this document a score reply document?
* @return true if the document is a score reply, false otherwise.
* @see #version
* @see #type
* @see #mode
* @see #RTML_VERSION_22
* @see #RTML_VERSION_31
*/
public boolean isScoreReply()
{
// if we don't know what version of RTML this doc is, return false.
if(version == null)
return false;
if(version.equals(RTML_VERSION_22) && (type.equals("score")))
return true;
if(version.equals(RTML_VERSION_31) && (mode.equals("offer")))
return true;
return false;
}
/**
* Is this document an observation request document?
* @return true if the document is an observation request, false otherwise.
* @see #version
* @see #type
* @see #mode
* @see #RTML_VERSION_22
* @see #RTML_VERSION_31
*/
public boolean isRequest()
{
// if we don't know what version of RTML this doc is, return false.
if(version == null)
return false;
if(version.equals(RTML_VERSION_22) && (type.equals("request")))
return true;
if(version.equals(RTML_VERSION_31) && (mode.equals("request")))
return true;
return false;
}
/**
* Is this document an observation request reply (confirmation) document?
* @return true if the document is an observation request reply (confirmation), false otherwise.
* @see #version
* @see #type
* @see #mode
* @see #RTML_VERSION_22
* @see #RTML_VERSION_31
*/
public boolean isRequestConfirm()
{
// if we don't know what version of RTML this doc is, return false.
if(version == null)
return false;
if(version.equals(RTML_VERSION_22) && (type.equals("confirmation")))
return true;
if(version.equals(RTML_VERSION_31) && (mode.equals("confirm")))
return true;
return false;
}
/**
* Is this document an observation update document?
* @return true if the document is an observation update, false otherwise.
* @see #version
* @see #type
* @see #mode
* @see #RTML_VERSION_22
* @see #RTML_VERSION_31
*/
public boolean isUpdate()
{
// if we don't know what version of RTML this doc is, return false.
if(version == null)
return false;
if(version.equals(RTML_VERSION_22) && (type.equals("update")))
return true;
if(version.equals(RTML_VERSION_31) && (mode.equals("update")))
return true;
return false;
}
/**
* Is this document a fail document?
* @return true if the document is a fail, false otherwise.
* @see #version
* @see #type
* @see #mode
* @see #RTML_VERSION_22
* @see #RTML_VERSION_31
*/
public boolean isFail()
{
// if we don't know what version of RTML this doc is, return false.
if(version == null)
return false;
if(version.equals(RTML_VERSION_22) && (type.equals("fail")))
return true;
if(version.equals(RTML_VERSION_31) && (mode.equals("fail")))
return true;
return false;
}
/**
* Is this document an abort document?
* @return true if the document is a abort, false otherwise.
* @see #version
* @see #type
* @see #mode
* @see #RTML_VERSION_22
* @see #RTML_VERSION_31
*/
public boolean isAbort()
{
// if we don't know what version of RTML this doc is, return false.
if(version == null)
return false;
if(version.equals(RTML_VERSION_22) && (type.equals("abort")))
return true;
if(version.equals(RTML_VERSION_31) && (mode.equals("abort")))
return true;
return false;
}
/**
* Is this document an incomplete document?
* @return true if the document is an incomplete, false otherwise.
* @see #version
* @see #type
* @see #mode
* @see #RTML_VERSION_22
* @see #RTML_VERSION_31
*/
public boolean isIncomplete()
{
// if we don't know what version of RTML this doc is, return false.
if(version == null)
return false;
if(version.equals(RTML_VERSION_22) && (type.equals("incomplete")))
return true;
if(version.equals(RTML_VERSION_31) && (mode.equals("incomplete")))
return true;
return false;
}
/**
* Is this document a complete/observation document?
* @return true if the document is a complete/observation, false otherwise.
* @see #version
* @see #type
* @see #mode
* @see #RTML_VERSION_22
* @see #RTML_VERSION_31
*/
public boolean isComplete()
{
// if we don't know what version of RTML this doc is, return false.
if(version == null)
return false;
if(version.equals(RTML_VERSION_22) && (type.equals("observation")))
return true;
if(version.equals(RTML_VERSION_31) && (mode.equals("complete")))
return true;
return false;
}
/**
* Set this document to be a score request document. The underlying type or mode is set based on
* the document's version (which must have been set before this method is invoked using setVersion).
* @exception NullPointerException Thrown if the version has not been set.
* @exception IllegalArgumentException Thrown if the version is not supported.
* @see #version
* @see #type
* @see #mode
* @see #setType
* @see #setMode
* @see #RTML_VERSION_22
* @see #RTML_VERSION_31
*/
public void setScoreRequest() throws NullPointerException, IllegalArgumentException
{
if(version == null)
throw new NullPointerException(this.getClass().getName()+":setScoreRequest:version was null.");
if(version.equals(RTML_VERSION_22))
setType("score");
else if(version.equals(RTML_VERSION_31))
setMode("inquiry");
else
{
throw new IllegalArgumentException(this.getClass().getName()+
":setScoreRequest:Unsupported version:"+version);
}
}
/**
* Set this document to be a score reject document. The underlying type or mode is set based on
* the document's version (which must have been set before this method is invoked using setVersion).
* @exception NullPointerException Thrown if the version has not been set.
* @exception IllegalArgumentException Thrown if the version is not supported.
* @see #version
* @see #type
* @see #mode
* @see #setType
* @see #setMode
* @see #RTML_VERSION_22
* @see #RTML_VERSION_31
*/
public void setScoreReject() throws NullPointerException, IllegalArgumentException
{
if(version == null)
throw new NullPointerException(this.getClass().getName()+":setScoreReject:version was null.");
if(version.equals(RTML_VERSION_22))
setType("reject");
else if(version.equals(RTML_VERSION_31))
setMode("reject");
else
{
throw new IllegalArgumentException(this.getClass().getName()+
":setScoreReject:Unsupported version:"+version);
}
}
/**
* Set this document to be a score reply document. The underlying type or mode is set based on
* the document's version (which must have been set before this method is invoked using setVersion).
* @exception NullPointerException Thrown if the version has not been set.
* @exception IllegalArgumentException Thrown if the version is not supported.
* @see #version
* @see #type
* @see #mode
* @see #setType
* @see #setMode
* @see #RTML_VERSION_22
* @see #RTML_VERSION_31
*/
public void setScoreReply() throws NullPointerException, IllegalArgumentException
{
if(version == null)
throw new NullPointerException(this.getClass().getName()+":setScoreReply:version was null.");
if(version.equals(RTML_VERSION_22))
setType("score");
else if(version.equals(RTML_VERSION_31))
setMode("offer");
else
{
throw new IllegalArgumentException(this.getClass().getName()+
":setScoreReply:Unsupported version:"+version);
}
}
/**
* Set this document to be a request document. The underlying type or mode is set based on
* the document's version (which must have been set before this method is invoked using setVersion).
* @exception NullPointerException Thrown if the version has not been set.
* @exception IllegalArgumentException Thrown if the version is not supported.
* @see #version
* @see #type
* @see #mode
* @see #setType
* @see #setMode
* @see #RTML_VERSION_22
* @see #RTML_VERSION_31
*/
public void setRequest() throws NullPointerException, IllegalArgumentException
{
if(version == null)
throw new NullPointerException(this.getClass().getName()+":setRequest:version was null.");
if(version.equals(RTML_VERSION_22))
setType("request");
else if(version.equals(RTML_VERSION_31))
setMode("request");
else
{
throw new IllegalArgumentException(this.getClass().getName()+
":setRequest:Unsupported version:"+version);
}
}
/**
* Set this document to be a request reply (confirmation) document. The underlying type or mode is set based on
* the document's version (which must have been set before this method is invoked using setVersion).
* @exception NullPointerException Thrown if the version has not been set.
* @exception IllegalArgumentException Thrown if the version is not supported.
* @see #version
* @see #type
* @see #mode
* @see #setType
* @see #setMode
* @see #RTML_VERSION_22
* @see #RTML_VERSION_31
*/
public void setRequestReply() throws NullPointerException, IllegalArgumentException
{
if(version == null)
throw new NullPointerException(this.getClass().getName()+":setRequestReply:version was null.");
if(version.equals(RTML_VERSION_22))
setType("confirmation");
else if(version.equals(RTML_VERSION_31))
setMode("confirm");
else
{
throw new IllegalArgumentException(this.getClass().getName()+
":setRequestReply:Unsupported version:"+version);
}
}
/**
* Set this document to be an update document. The underlying type or mode is set based on
* the document's version (which must have been set before this method is invoked using setVersion).
* @exception NullPointerException Thrown if the version has not been set.
* @exception IllegalArgumentException Thrown if the version is not supported.
* @see #version
* @see #type
* @see #mode
* @see #setType
* @see #setMode
* @see #RTML_VERSION_22
* @see #RTML_VERSION_31
*/
public void setUpdate() throws NullPointerException, IllegalArgumentException
{
if(version == null)
throw new NullPointerException(this.getClass().getName()+":setUpdate:version was null.");
if(version.equals(RTML_VERSION_22))
setType("update");
else if(version.equals(RTML_VERSION_31))
setMode("update");
else
{
throw new IllegalArgumentException(this.getClass().getName()+
":setUpdate:Unsupported version:"+version);
}
}
/**
* Set this document to be a fail document. The underlying type or mode is set based on
* the document's version (which must have been set before this method is invoked using setVersion).
* @exception NullPointerException Thrown if the version has not been set.
* @exception IllegalArgumentException Thrown if the version is not supported.
* @see #version
* @see #type
* @see #mode
* @see #setType
* @see #setMode
* @see #RTML_VERSION_22
* @see #RTML_VERSION_31
*/
public void setFail() throws NullPointerException, IllegalArgumentException
{
if(version == null)
throw new NullPointerException(this.getClass().getName()+":setFail:version was null.");
if(version.equals(RTML_VERSION_22))
setType("fail");
else if(version.equals(RTML_VERSION_31))
setMode("fail");
else
{
throw new IllegalArgumentException(this.getClass().getName()+
":setFail:Unsupported version:"+version);
}
}
/**
* Set this document to be a fail document. The underlying type or mode is set based on
* the document's version (which must have been set before this method is invoked using setVersion).
* @exception NullPointerException Thrown if the version has not been set.
* @exception IllegalArgumentException Thrown if the version is not supported.
* @see #version
* @see #type
* @see #mode
* @see #setType
* @see #setMode
* @see #RTML_VERSION_22
* @see #RTML_VERSION_31
*/
public void setReject() throws NullPointerException, IllegalArgumentException
{
if(version == null)
throw new NullPointerException(this.getClass().getName()+":setReject:version was null.");
if(version.equals(RTML_VERSION_22))
setType("reject");
else if(version.equals(RTML_VERSION_31))
setMode("reject");
else
{
throw new IllegalArgumentException(this.getClass().getName()+
":setReject:Unsupported version:"+version);
}
}
/**
* Set this document to be an abort document. The underlying type or mode is set based on
* the document's version (which must have been set before this method is invoked using setVersion).
* Note RTML 3.1a suggests an "abort reply" has the mode "confirm".
* @exception NullPointerException Thrown if the version has not been set.
* @exception IllegalArgumentException Thrown if the version is not supported.
* @see #version
* @see #type
* @see #mode
* @see #setType
* @see #setMode
* @see #RTML_VERSION_22
* @see #RTML_VERSION_31
*/
public void setAbort() throws NullPointerException, IllegalArgumentException
{
if(version == null)
throw new NullPointerException(this.getClass().getName()+":setAbort:version was null.");
if(version.equals(RTML_VERSION_22))
setType("abort");
else if(version.equals(RTML_VERSION_31))
setMode("abort");
else
{
throw new IllegalArgumentException(this.getClass().getName()+
":setAbort:Unsupported version:"+version);
}
}
/**
* Set this document to be a succesful reply to an abort document. The underlying type or mode is set based on
* the document's version (which must have been set before this method is invoked using setVersion).
* RTML 3.1a says an "abort reply" has the mode "confirm". We have made RTML 2.2 do the same
* (i.e. "confirmation").
* @exception NullPointerException Thrown if the version has not been set.
* @exception IllegalArgumentException Thrown if the version is not supported.
* @see #version
* @see #type
* @see #mode
* @see #setType
* @see #setMode
* @see #RTML_VERSION_22
* @see #RTML_VERSION_31
*/
public void setAbortReply() throws NullPointerException, IllegalArgumentException
{
if(version == null)
throw new NullPointerException(this.getClass().getName()+":setAbortReply:version was null.");
if(version.equals(RTML_VERSION_22))
setType("confirmation");
else if(version.equals(RTML_VERSION_31))
setMode("confirm");
else
{
throw new IllegalArgumentException(this.getClass().getName()+
":setAbortReply:Unsupported version:"+version);
}
}
/**
* Set this document to be a incomplete document. The underlying type or mode is set based on
* the document's version (which must have been set before this method is invoked using setVersion).
* @exception NullPointerException Thrown if the version has not been set.
* @exception IllegalArgumentException Thrown if the version is not supported.
* @see #version
* @see #type
* @see #mode
* @see #setType
* @see #setMode
* @see #RTML_VERSION_22
* @see #RTML_VERSION_31
*/
public void setIncomplete() throws NullPointerException, IllegalArgumentException
{
if(version == null)
throw new NullPointerException(this.getClass().getName()+":setIncomplete:version was null.");
if(version.equals(RTML_VERSION_22))
setType("incomplete");
else if(version.equals(RTML_VERSION_31))
setMode("incomplete");
else
{
throw new IllegalArgumentException(this.getClass().getName()+
":setIncomplete:Unsupported version:"+version);
}
}
/**
* Set this document to be a complete document. The underlying type or mode is set based on
* the document's version (which must have been set before this method is invoked using setVersion).
* @exception NullPointerException Thrown if the version has not been set.
* @exception IllegalArgumentException Thrown if the version is not supported.
* @see #version
* @see #type
* @see #mode
* @see #setType
* @see #setMode
* @see #RTML_VERSION_22
* @see #RTML_VERSION_31
*/
public void setComplete() throws NullPointerException, IllegalArgumentException
{
if(version == null)
throw new NullPointerException(this.getClass().getName()+":setComplete:version was null.");
if(version.equals(RTML_VERSION_22))
setType("observation");
else if(version.equals(RTML_VERSION_31))
setMode("complete");
else
{
throw new IllegalArgumentException(this.getClass().getName()+
":setComplete:Unsupported version:"+version);
}
}
/**
* Method to return whether this documents represents a target of opportunity request (TOOP) which
* must be serviced immediately, or a regular phase II scheduled observation.
* @return true if the document is a TOOP, false otherwise.
* @exception NullPointerException Thrown if the version has not been set, or a document's observation #
* target/schedule are null.
* @exception IllegalArgumentException Thrown if the version is not supported, or the document
* contains multiple observations which don't agree as to whether they are a toop.
* @see #version
* @see #getObservationListCount
* @see #getObservation
* @see org.estar.rtml.RTMLObservation#getTarget
* @see org.estar.rtml.RTMLObservation#getSchedule
* @see org.estar.rtml.RTMTarget#isTypeTOOP
* @see org.estar.rtml.RTMLSchedule#getPriority
* @see org.estar.rtml.RTMLSchedule#SCHEDULE_PRIORITY_TOOP
* @see #RTML_VERSION_22
* @see #RTML_VERSION_31
*/
public boolean isTOOP() throws NullPointerException, IllegalArgumentException
{
RTMLObservation observation = null;
RTMLSchedule schedule = null;
RTMLTarget target = null;
boolean isToop = false;
if(version == null)
throw new NullPointerException(this.getClass().getName()+":isTOOP:version was null.");
for(int i = 0; i < getObservationListCount(); i++)
{
observation = getObservation(i);
target = observation.getTarget();
// if the observation target is null, use the document's overall target if it exists
if(target == null)
{
target = this.target;
}
schedule = observation.getSchedule();
if(target == null)
{
throw new NullPointerException(this.getClass().getName()+":isTOOP:observation "+i+
" has null target.");
}
if(schedule == null)
{
throw new NullPointerException(this.getClass().getName()+":isTOOP:observation "+i+
" has null schedule.");
}
if(version.equals(RTML_VERSION_22)) // check target type == toop
{
// if first observation, set isToop
if(i == 0)
{
if(target.isTypeTOOP())
isToop = true;
else
isToop = false;
}
else // check this observation matches others in the list else error
{
if(target.isTypeTOOP())
{
if(isToop == false)
{
throw new IllegalArgumentException(this.getClass().getName()+
":isTOOP:Observations don't match toop-wise(1): "+i);
}
}
else
{
if(isToop)
{
throw new IllegalArgumentException(this.getClass().getName()+
":isTOOP:Observations don't match toop-wise(2): "+i);
}
}
}
}
else if(version.equals(RTML_VERSION_31))// check schedule priority == 0
{
// if first observation, set isToop
if(i == 0)
{
if(schedule.getPriority() == RTMLSchedule.SCHEDULE_PRIORITY_TOOP)
isToop = true;
else
isToop = false;
}
else // check this observation matches others in the list else error
{
if(schedule.getPriority() == RTMLSchedule.SCHEDULE_PRIORITY_TOOP)
{
if(isToop == false)
{
throw new IllegalArgumentException(this.getClass().getName()+
":isTOOP:Observations don't match toop-wise(3): "+i);
}
}
else
{
if(isToop)
{
throw new IllegalArgumentException(this.getClass().getName()+
":isTOOP:Observations don't match toop-wise(4): "+i);
}
}
}
}
else
{
throw new IllegalArgumentException(this.getClass().getName()+
":isTOOP:Unsupported version:"+version);
}
}// end for on observations
return isToop;
}
/**
* Method to set that this documents represents a target of opportunity request (TOOP) which
* must be serviced immediately.
* @exception NullPointerException Thrown if the version has not been set, or a document's observation #
* target/schedule are null.
* @exception IllegalArgumentException Thrown if the version is not supported.
* @see #version
* @see #getObservationListCount
* @see #getObservation
* @see org.estar.rtml.RTMLObservation#getTarget
* @see org.estar.rtml.RTMLObservation#getSchedule
* @see org.estar.rtml.RTMTarget#setTypeTOOP
* @see org.estar.rtml.RTMLSchedule#setPriority
* @see org.estar.rtml.RTMLSchedule#SCHEDULE_PRIORITY_TOOP
* @see #RTML_VERSION_22
* @see #RTML_VERSION_31
*/
public void setTOOP() throws NullPointerException, IllegalArgumentException
{
RTMLObservation observation = null;
RTMLSchedule schedule = null;
RTMLTarget target = null;
boolean isToop = false;
if(version == null)
throw new NullPointerException(this.getClass().getName()+":setTOOP:version was null.");
for(int i = 0; i < getObservationListCount(); i++)
{
observation = getObservation(i);
target = observation.getTarget();
// if the observation target is null, use the document's overall target if it exists
if(target == null)
{
target = this.target;
}
schedule = observation.getSchedule();
if(target == null)
{
throw new NullPointerException(this.getClass().getName()+":setTOOP:observation "+i+
" has null target.");
}
if(schedule == null)
{
throw new NullPointerException(this.getClass().getName()+":setTOOP:observation "+i+
" has null schedule.");
}
if(version.equals(RTML_VERSION_22)) // target type == toop
{
target.setTypeTOOP();
}
else if(version.equals(RTML_VERSION_31))// schedule priority == 0
{
schedule.setPriority(RTMLSchedule.SCHEDULE_PRIORITY_TOOP);
}
else
{
throw new IllegalArgumentException(this.getClass().getName()+
":setTOOP:Unsupported version:"+version);
}
}// end for on observations
}
/**
* Set the document's history.
* @param h The history.
* @see #history
* @see org.estar.rtml.RTMLHistory
*/
public void setHistory(RTMLHistory h)
{
history = h;
}
/**
* Get the document's history.
* @return The history.
* @see #history
* @see org.estar.rtml.RTMLHistory
*/
public RTMLHistory getHistory()
{
return history;
}
/**
* Get the number of Entrys in the History list.
* @return The number of Entrys in the list.
* @see #history
* @see org.estar.rtml.RTMLHistory#getEntryListCount
*/
public int getHistoryEntryCount()
{