KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > simple > MyClass5d


1
2 package simple;
3
4 import org.jibx.runtime.IMarshallingContext;
5 import org.jibx.runtime.ITrackSource;
6 import org.jibx.runtime.IUnmarshallingContext;
7
8 class MyClass5d extends MyClass5a
9 {
10     /*package*/ boolean factory;
11     private boolean preset;
12     private boolean postset;
13     private String JavaDoc text1;
14     private String JavaDoc text2;
15     
16     private void preset(IUnmarshallingContext ctx) {
17         if (!(ctx.getStackObject(1) instanceof MyClass5)) {
18             throw new IllegalStateException JavaDoc("wrong object in stack");
19         }
20         preset = true;
21         value = 1;
22     }
23     
24     private void postset(IUnmarshallingContext ctx) {
25         if (!(ctx.getStackObject(1) instanceof MyClass5)) {
26             throw new IllegalStateException JavaDoc("wrong object in stack");
27         }
28         postset = true;
29         if (value == 2) {
30             value = 3;
31         }
32     }
33     
34     private void preget(IMarshallingContext ctx) {
35         if (!(ctx.getStackObject(1) instanceof MyClass5)) {
36             throw new IllegalStateException JavaDoc("wrong object in stack");
37         }
38         value = 2;
39     }
40     
41     protected void verify() {
42         if (!factory || !preset || !postset) {
43             throw new IllegalStateException JavaDoc
44                 ("factory, pre-set, or post-set method not called");
45         }
46         ITrackSource track = (ITrackSource)this;
47         System.out.println("Verified " + this.getClass().getName() +
48             " from \"" + track.jibx_getDocumentName() + "\" (" +
49             track.jibx_getLineNumber() + ":" + track.jibx_getColumnNumber() +
50             ")");
51     }
52 }
53
Popular Tags