Statistics
| Revision:

gvsig-tools / org.gvsig.tools / library / trunk / org.gvsig.tools / org.gvsig.tools.lib / src / main / java / org / gvsig / tools / dynobject / impl / DefaultDynObjectManager.java @ 1031

History | View | Annotate | Download (23.8 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.tools.dynobject.impl;
25

    
26
import java.io.IOException;
27
import java.io.InputStream;
28
import java.util.ArrayList;
29
import java.util.Arrays;
30
import java.util.Collections;
31
import java.util.HashMap;
32
import java.util.HashSet;
33
import java.util.Iterator;
34
import java.util.List;
35
import java.util.Map;
36
import java.util.Set;
37

    
38
import org.gvsig.tools.ToolsLocator;
39
import org.gvsig.tools.dynobject.DynClass;
40
import org.gvsig.tools.dynobject.DynClassName;
41
import org.gvsig.tools.dynobject.DynField_LabelAttribute;
42
import org.gvsig.tools.dynobject.DynField_v2;
43
import org.gvsig.tools.dynobject.DynMethod;
44
import org.gvsig.tools.dynobject.DynObject;
45
import org.gvsig.tools.dynobject.DynObjectManager;
46
import org.gvsig.tools.dynobject.DynObjectPagingHelper;
47
import org.gvsig.tools.dynobject.DynObjectRuntimeException;
48
import org.gvsig.tools.dynobject.DynObjectSet;
49
import org.gvsig.tools.dynobject.DynStruct;
50
import org.gvsig.tools.dynobject.exception.DuplicateDynClassException;
51
import org.gvsig.tools.dynobject.exception.DynMethodException;
52
import org.gvsig.tools.dynobject.exception.DynMethodIllegalCodeException;
53
import org.gvsig.tools.dynobject.exception.DynMethodNotSupportedException;
54
import org.gvsig.tools.dynobject.exception.IllegalDynMethodException;
55
import org.gvsig.tools.dynobject.exception.IllegalDynMethodInvocationException;
56
import org.gvsig.tools.exception.BaseException;
57
import org.slf4j.Logger;
58
import org.slf4j.LoggerFactory;
59
import org.xmlpull.v1.XmlPullParser;
60
import org.xmlpull.v1.XmlPullParserException;
61

    
62
/**
63
 * Default {@link DynObjectManager} implementation.
64
 * 
65
 * @author gvSIG Team
66
 * @version $Id$
67
 */
68
public class DefaultDynObjectManager implements DynObjectManager {
69

    
70
    private final static Logger LOG = LoggerFactory
71
        .getLogger(DefaultDynObjectManager.class);
72

    
73
    private static DefaultDynObjectManager manager = null;
74

    
75
    private class MethodInfo {
76

    
77
        int code;
78
        DynClass dynClass;
79
        DynMethod dynMethod;
80
        Class theClass;
81

    
82
        MethodInfo(Class theClass, DynClass dynClass, DynMethod dynMethod,
83
            int code) {
84
            this.code = code;
85
            this.dynClass = dynClass;
86
            this.dynMethod = dynMethod;
87
            this.theClass = theClass;
88
        }
89

    
90
        String getKey() {
91
            return DefaultDynObjectManager
92
                .getKey(theClass, dynClass, dynMethod);
93
        }
94

    
95
        void check(Class theClass, int code) throws DynMethodException {
96
            if (code != this.code) {
97
                throw new DynMethodIllegalCodeException(dynMethod.getName(),
98
                    this.code, code);
99
            }
100
            if (theClass != null) {
101
                if (this.theClass == null) {
102
                    throw new IllegalDynMethodInvocationException(
103
                        dynMethod.getName(), theClass);
104
                }
105
                if (!this.theClass.isAssignableFrom(theClass)) {
106
                    throw new IllegalDynMethodInvocationException(
107
                        dynMethod.getName(), theClass);
108
                }
109
            }
110
        }
111

    
112
        void check(DynClass dynClass, int code) throws DynMethodException {
113
            if (code != this.code) {
114
                throw new DynMethodIllegalCodeException(dynMethod.getName(),
115
                    this.code, code);
116
            }
117
            if (dynClass != null) {
118
                if (this.dynClass == null) {
119
                    throw new IllegalDynMethodInvocationException(
120
                        dynMethod.getName(), dynClass);
121
                }
122
                if (dynClass != this.dynClass
123
                    || !dynClass.getName().equalsIgnoreCase(
124
                        this.dynClass.getName())) {
125
                    throw new IllegalDynMethodInvocationException(
126
                        dynMethod.getName(), dynClass);
127
                }
128
            }
129
        }
130
    }
131

    
132
    private class ClassesNamespaces {
133

    
134
        private Map defaultNamespace;
135
        private Map namespaces;
136

    
137
        ClassesNamespaces() {
138
            this.namespaces = new HashMap();
139
            this.defaultNamespace = new HashMap();
140
        }
141

    
142
        public Map addNamespace(String name) {
143
            Map namespace = new HashMap();
144
            this.namespaces.put(name.toLowerCase(), namespace);
145
            return namespace;
146
        }
147

    
148
        public Map getNamespace(String name) {
149
            return (Map) this.namespaces.get(name.toLowerCase());
150
        }
151

    
152
//        public void clear() {
153
//            this.defaultNamespace.clear();
154
//            this.namespaces.clear();
155
//        }
156

    
157
        public boolean containsClass(String name) {
158
            name = name.toLowerCase();
159
            if (this.defaultNamespace.containsKey(name)) {
160
                return true;
161
            }
162

    
163
            Iterator it = this.namespaces.values().iterator();
164
            while (it.hasNext()) {
165
                Map names = (Map) it.next();
166
                if (names.containsKey(name)) {
167
                    return true;
168
                }
169
            }
170
            return false;
171
        }
172

    
173
        public boolean containsClass(String namespace, String name) {
174
            name = name.toLowerCase();
175
            if (namespace == null) {
176
                return this.defaultNamespace.containsKey(name);
177
            }
178
            Map space = this.getNamespace(namespace);
179
            if (space == null) {
180
                return false;
181
            }
182
            return space.containsKey(name);
183
        }
184

    
185
//        public boolean containsClass(DynClass dynClass) {
186
//            if (this.defaultNamespace.containsValue(dynClass)) {
187
//                return true;
188
//            }
189
//
190
//            Iterator it = this.namespaces.values().iterator();
191
//            while (it.hasNext()) {
192
//                Map names = (Map) it.next();
193
//                if (names.containsValue(dynClass)) {
194
//                    return true;
195
//                }
196
//            }
197
//            return false;
198
//        }
199

    
200
        public DynClass get(String name, String namespace) {
201
            if (namespace == null) {
202
                return (DynClass) this.defaultNamespace.get(name.toLowerCase());
203
            }
204
            Map space = this.getNamespace(namespace);
205
            if (space == null) {
206
                return null;
207
            }
208
            DynClassName className = new DefaultDynClassName(name);
209
            if (className.getNamespace()==null){
210
                return (DynClass) space.get(name.toLowerCase());
211
            }
212
            if (!namespace.equalsIgnoreCase(className.getNamespace())){
213
                    return null;
214
            }
215
            return (DynClass) space.get(className.getName().toLowerCase());
216
        }
217

    
218
        public Set keySet() {
219
            Set keyset = new HashSet();
220
            Iterator it = this.iterator();
221
            while (it.hasNext()) {
222
                DynClass dynClass = (DynClass) it.next();
223
                keyset.add(dynClass.getFullName());
224
            }
225
            return keyset;
226
        }
227

    
228
        public Iterator iterator() {
229
            final class MyIterator implements Iterator {
230

    
231
                Iterator current;
232
                Iterator others;
233

    
234
                MyIterator(Iterator main, Iterator others) {
235
                    this.current = main;
236
                    this.others = others;
237
                }
238

    
239
                public boolean hasNext() {
240
                    if (this.current.hasNext()) {
241
                        return true;
242
                    }
243
                    while (this.others.hasNext()) { 
244
                        Object obj = others.next();
245
                        this.current = (Iterator) ((HashMap) obj).values().iterator();
246
                        if (this.current.hasNext()) {
247
                            return true;
248
                        }
249
                    }
250
                    return false;
251
                }
252

    
253
                public Object next() {
254
                    if (this.current.hasNext()) {
255
                        return this.current.next();
256
                    }
257
                    while (this.others.hasNext()) {
258
                        Object obj = others.next();
259
                        this.current = (Iterator) ((HashMap) obj).values().iterator();
260
                        if (this.current.hasNext()) {
261
                            return this.current.next();
262
                        }
263
                    }
264
                    return null;
265
                }
266

    
267
                public void remove() {
268
                    throw new UnsupportedOperationException();
269
                }
270
            }
271

    
272
            return new MyIterator(this.defaultNamespace.values().iterator(),
273
                this.namespaces.values().iterator());
274
        }
275

    
276
        public Object add(DynStruct dynClass) {
277
            String name = dynClass.getName().toLowerCase();
278
            Map namespace;
279
            if (dynClass.getNamespace() != null) {
280
                namespace = (Map) this.getNamespace(dynClass.getNamespace());
281
                if (namespace == null) {
282
                    namespace = this.addNamespace(dynClass.getNamespace());
283
                }
284
            } else {
285
                namespace = this.defaultNamespace;
286
            }
287
            if (namespace.containsKey(name)) {
288
                throw new DuplicateDynClassException(dynClass);
289
            }
290
            return namespace.put(name, dynClass);
291
        }
292

    
293
        public void remove(DynStruct dynClass) {
294
            String name = dynClass.getName().toLowerCase();
295
            Map namespace;
296
            if (dynClass.getNamespace() != null) {
297
                namespace = (Map) this.getNamespace(dynClass.getNamespace());
298
                if (namespace == null) {
299
                    namespace = this.addNamespace(dynClass.getNamespace());
300
                }
301
            } else {
302
                namespace = this.defaultNamespace;
303
            }
304
            if (namespace.containsKey(name)) {
305
                namespace.remove(name);
306
            }
307
        }
308

    
309
        public int size() {
310
            int count = this.defaultNamespace.size();
311

    
312
            Iterator it = this.namespaces.values().iterator();
313
            while (it.hasNext()) {
314
                Map names = (Map) it.next();
315
                count += names.size();
316
            }
317
            return count;
318
        }
319

    
320
    }
321

    
322
    private Map anonymousClasses;
323
    private ClassesNamespaces classes;
324
    private Map methodsMap;
325
    private MethodInfo[] methods;
326

    
327
    public static DefaultDynObjectManager getManager() {
328
        if (manager == null) {
329
            manager = new DefaultDynObjectManager();
330
        }
331
        return manager;
332
    }
333

    
334
    static String getKey(Class theClass, DynClass dynClass, DynMethod dynMethod) {
335
        return DefaultDynObjectManager.getKey(theClass, dynClass,
336
            dynMethod.getName());
337
    }
338

    
339
    static String getKey(Class theClass, DynClass dynClass, String methodName) {
340
        if (dynClass == null) {
341
            return theClass.getName() + ":" + methodName;
342
        } else {
343
            return dynClass.getName() + ":" + methodName;
344
        }
345
    }
346

    
347
    public DefaultDynObjectManager() {
348
        this.classes = new ClassesNamespaces();
349
        this.anonymousClasses = new HashMap();
350
        this.methodsMap = new HashMap();
351
        this.methods = null;
352
    }
353

    
354
    public DynClass createDynClass(String name, String description) {
355
        return new DefaultDynClass(this, name, description);
356
    }
357

    
358
    public DynClass createDynClass(String namespace, String name,
359
        String description) {
360
        return new DefaultDynClass(this, namespace, name, description);
361
    }
362

    
363
    public void add(DynClass dynClass) {
364
        try {
365
            ((DefaultDynClass) dynClass).check();
366
        } catch (Exception ex) {
367
            throw new DynObjectRuntimeException(ex);
368
        }
369
        this.classes.add(dynClass);
370
        LOG.trace("Add DynClass definition {}.",
371
            new Object[] { dynClass.getFullName() });
372

    
373
    }
374

    
375
    public DynClass add(String name, String description) {
376
        DynClass dynClass =
377
            (DynClass) this.classes.get(name.toLowerCase(), null);
378
        if (dynClass == null) {
379
            dynClass = this.createDynClass(name, description);
380
            this.add(dynClass);
381
        }
382
        return dynClass;
383
    }
384

    
385
    public DynClass add(String name) {
386
        return this.add(name, null);
387
    }
388

    
389
    public void remove(DynStruct dynClass) {
390
        this.classes.remove(dynClass);
391
    }
392

    
393
    // public static String getFullName(String namespace, String name) {
394
    // if( namespace == null ) {
395
    // return name;
396
    // }
397
    // return namespace + ":" + name;
398
    // }
399
    // public static String[] splitFullName(String fullname) {
400
    // String[] name = new String[] { null, fullname };
401
    // int x=fullname.indexOf(':');
402
    // if( x>-1 ) {
403
    // name[0] = fullname.substring(0, x);
404
    // name[1] = fullname.substring(x+1);
405
    // }
406
    // return name;
407
    //
408
    // }
409

    
410
    public DynClass get(String theName) {
411
        DynClassName name = createDynClassName(theName);
412
        return this.get(name.getNamespace(), name.getName());
413
    }
414

    
415
    public DynClass get(String namespace, String name) {
416
        return (DynClass) this.classes.get(name, namespace);
417
    }
418

    
419
    public DynClass get(DynClass[] superClasses) {
420
        StringBuffer name = new StringBuffer();
421
        for (int i = 0; i < superClasses.length; i++) {
422
            name.append(superClasses[i].getName()).append("+");
423
        }
424
        DefaultDynClass dynClass =
425
            (DefaultDynClass) this.anonymousClasses.get(name.toString());
426
        if (dynClass == null) {
427
            dynClass =
428
                new DefaultDynClass(this, name.toString(), null, superClasses);
429
            dynClass.setAnonymous(true);
430
        }
431
        return dynClass;
432
    }
433

    
434
    public int getCount() {
435
        return this.classes.size();
436
    }
437

    
438
    public List getNames() {
439
        String[] names = (String[]) this.classes.keySet().toArray();
440
        Arrays.sort(names);
441
        return Collections.unmodifiableList(Arrays.asList(names));
442
    }
443

    
444
    public boolean has(String name) {
445
        return this.classes.containsClass(name);
446
    }
447

    
448
    public boolean has(String namespace, String name) {
449
        return this.classes.containsClass(namespace, name);
450
    }
451

    
452
    public Iterator iterator() {
453
        return this.classes.iterator();
454
    }
455

    
456
    public DynObject createDynObject(String dynClassName) {
457
        DynClassName name = createDynClassName(dynClassName);
458
        return this.createDynObject(name.getName(), name.getNamespace());
459
    }
460

    
461
    public DynObject createDynObject(String dynClassName, String namespace) {
462

    
463
        DynClass dynClass =
464
            (DynClass) this.classes.get(dynClassName, namespace);
465
        if (dynClass == null) {
466
            throw new IllegalArgumentException("Can't locate class '"
467
                + createDynClassName(namespace, dynClassName).getFullName()
468
                + "'.");
469
        }
470
        return this.createDynObject(dynClass);
471
    }
472

    
473
    public DynObject createDynObject(DynStruct dynClass) {
474
        return new DefaultDynObject(dynClass);
475
    }
476

    
477
    public void consolide() {
478
        Iterator it = this.classes.iterator();
479
        while (it.hasNext()) {
480
            DefaultDynClass dc = (DefaultDynClass) it.next();
481
            dc.consolide();
482
        }
483
        it = this.anonymousClasses.values().iterator();
484
        while (it.hasNext()) {
485
            DefaultDynClass dc = (DefaultDynClass) it.next();
486
            dc.consolide();
487
        }
488
    }
489

    
490
    public int registerDynMethod(DynClass dynClass, DynMethod dynMethod) {
491
        ((DefaultDynClass) dynClass).addMethod(dynMethod);
492
        return registerDynMethod(null, dynClass, dynMethod);
493
    }
494

    
495
    public int registerDynMethod(Class theClass, DynMethod dynMethod) {
496
        return registerDynMethod(theClass, null, dynMethod);
497
    }
498

    
499
    int registerDynMethod(Class theClass, DynClass dynClass, DynMethod dynMethod) {
500
        MethodInfo info = new MethodInfo(theClass, dynClass, dynMethod, 0);
501
        MethodInfo oldInfo = (MethodInfo) methodsMap.get(info.getKey());
502
        if (oldInfo != null) {
503
            // Update the method info
504
            oldInfo.dynClass = dynClass;
505
            oldInfo.dynMethod = dynMethod;
506
            return oldInfo.code;
507
        }
508
        if (methods == null) {
509
            methods = new MethodInfo[1];
510
            info.code = 0;
511
        } else {
512
            MethodInfo[] temp1 = new MethodInfo[methods.length + 1];
513
            System.arraycopy(methods, 0, temp1, 0, methods.length);
514
            info.code = temp1.length - 1;
515
            methods = temp1;
516
        }
517
        methods[info.code] = info;
518
        methodsMap.put(info.getKey(), info);
519

    
520
        return info.code;
521
    }
522

    
523
    public Object invokeDynMethod(Object self, int code, DynObject context)
524
        throws DynMethodException {
525

    
526
        try {
527
            /*
528
             * Intentamos ejecutar la operacion, y si peta ya haremos las
529
             * comprobaciones oportunas para lanzar la excepcion que toque.
530
             * 
531
             * Asi evitamos codigo de comprobacion para los casos que valla bien
532
             * que deberian ser la mayoria.
533
             */
534
            return methods[code].dynMethod.invoke(self, context);
535
        } catch (RuntimeException e) {
536
            getDynMethod(self, code);
537
            throw e;
538
        } catch (DynMethodException e) {
539
            getDynMethod(self, code);
540
            throw e;
541
        }
542

    
543
    }
544

    
545
    public int getDynMethodCode(DynClass dynClass, String methodName)
546
        throws DynMethodException {
547
        String key = DefaultDynObjectManager.getKey(null, dynClass, methodName);
548
        MethodInfo info = (MethodInfo) methodsMap.get(key);
549
        if (info == null) {
550
            throw new IllegalDynMethodException(methodName, dynClass);
551
        }
552
        info.check(dynClass, info.code);
553
        return info.code;
554
    }
555

    
556
    public int getDynMethodCode(Class theClass, String methodName)
557
        throws DynMethodException {
558
        String key = DefaultDynObjectManager.getKey(theClass, null, methodName);
559
        MethodInfo info = (MethodInfo) methodsMap.get(key);
560
        if (info == null) {
561
            throw new IllegalDynMethodException(methodName, theClass);
562
        }
563
        info.check(theClass, info.code);
564
        return info.code;
565
    }
566

    
567
    public DynMethod getDynMethod(int code) throws DynMethodException {
568
        if (code >= methods.length) {
569
            throw new DynMethodNotSupportedException(code, "{null}");
570
        }
571
        MethodInfo info = methods[code];
572
        info.check((Class) null, code);
573
        return info.dynMethod;
574
    }
575

    
576
    public DynMethod getDynMethod(Object obj, int code)
577
        throws DynMethodException {
578
        return getDynMethod(obj.getClass(), code);
579
    }
580

    
581
    public DynMethod getDynMethod(Class theClass, int code)
582
        throws DynMethodException {
583
        if (code >= methods.length) {
584
            throw new DynMethodNotSupportedException(code, theClass.getName());
585
        }
586
        MethodInfo info = methods[code];
587
        info.check(theClass, code);
588
        return info.dynMethod;
589
    }
590

    
591
    public DynMethod getDynMethod(DynClass dynClass, int code)
592
        throws DynMethodException {
593
        if (code >= methods.length) {
594
            throw new DynMethodNotSupportedException(code, dynClass.getName());
595
        }
596
        MethodInfo info = methods[code];
597
        info.check(dynClass, code);
598
        return info.dynMethod;
599
    }
600

    
601
    public DynMethod getDynMethod(DynObject dynObject, int code)
602
        throws DynMethodException {
603
        return getDynMethod(dynObject.getDynClass(), code);
604
    }
605

    
606
    public void validate(DynObject object) {
607
        // TODO
608
        return;
609
    }
610

    
611
    public Class getDefaultClassOfType(int type) {
612
        return ToolsLocator.getDataTypesManager().getDefaultClass(type);
613
    }
614

    
615
    public Map importDynClassDefinitions(InputStream resource,
616
        ClassLoader loader) throws XmlPullParserException, IOException {
617
        return new DynClassImportHelper().importDefinitions(resource, loader,
618
            null);
619
    }
620

    
621
    public Map importDynClassDefinitions(XmlPullParser parser,
622
        ClassLoader loader, String defaultNamespace)
623
        throws XmlPullParserException, IOException {
624
        return new DynClassImportHelper().importDefinitions(parser, loader,
625
            defaultNamespace);
626
    }
627

    
628
    public Map importDynClassDefinitions(InputStream resource,
629
        ClassLoader loader, String defaultNamespace)
630
        throws XmlPullParserException, IOException {
631
        return new DynClassImportHelper().importDefinitions(resource, loader,
632
            defaultNamespace);
633
    }
634

    
635
    public DynObjectPagingHelper createDynObjectPagingHelper(DynObjectSet set)
636
        throws BaseException {
637
        return new DefaultDynObjectPagingHelper(set); 
638
    }
639

    
640
    public DynObjectPagingHelper createDynObjectPagingHelper(DynObjectSet set,
641
        int pageSize) throws BaseException {
642
        return new DefaultDynObjectPagingHelper(set, pageSize);
643
    }
644

    
645
    public DynClassName createDynClassName(String namespace, String name) {
646
        return new DefaultDynClassName(namespace, name);
647
    }
648

    
649
    public DynClassName createDynClassName(String name) {
650
        return new DefaultDynClassName(name);
651
    }
652

    
653
    public Iterator iterator(String nameSpace) {
654
        return iterator(nameSpace, false);
655
    }
656

    
657
    private Iterator iterator(String nameSpace, boolean exactMatchingRequired) {
658

    
659
        List list = new ArrayList();
660
        Iterator it = this.classes.iterator();
661

    
662
        if (nameSpace == null) {
663
            nameSpace = "";
664
        }
665

    
666
        while( it.hasNext() ) {
667
            
668
            Object obj = it.next();
669
            DynStruct dynStruct = (DynStruct) obj;
670
            String dynNameSpace = dynStruct.getNamespace();
671
            if ((dynNameSpace == null) || (dynNameSpace.equals(""))) {
672
                dynNameSpace = null;
673
            } else {
674
                dynNameSpace = dynNameSpace.toLowerCase();
675
            }
676
            nameSpace = nameSpace.toLowerCase();
677
            if (exactMatchingRequired) {
678
                if (nameSpace.equalsIgnoreCase(dynNameSpace)) {
679
                    list.add(dynStruct);
680
                }
681
            } else {
682
                if ((dynNameSpace != null)
683
                    && (nameSpace.indexOf(dynNameSpace) > -1)) {
684
                    list.add(dynStruct);
685
                }
686
            }
687
        }
688
        return list.iterator();
689
    }
690

    
691
    public Object getAttributeValue(Object obj, String name) {
692
        if( "label".equalsIgnoreCase(name) ) {
693
            if( obj instanceof DynField_LabelAttribute ) {
694
                return ((DynField_LabelAttribute)obj).getLabel();
695
            }
696
            } else if( "StructWhenTypeIsDynObject".equalsIgnoreCase(name) ) {
697
            if( obj instanceof DynField_v2 ) {
698
                return ((DynField_v2)obj).getStructWhenTypeIsDynObject();
699
            }
700
            }
701
            return null;
702
    }
703

    
704
    public void setAttributeValue(Object obj, String name, Object value) {
705
        if( "label".equalsIgnoreCase(name) ) {
706
            if( obj instanceof DynField_LabelAttribute ) {
707
                ((DynField_LabelAttribute)obj).setLabel((String) value);
708
            }
709
            } else if( "StructWhenTypeIsDynObject".equalsIgnoreCase(name) ) {
710
            if( obj instanceof DynField_v2 ) {
711
                ((DynField_v2)obj).setStructWhenTypeIsDynObject((DynStruct) value);
712
            }
713
            }
714
    }
715
}