Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libIverUtiles / src / com / iver / utiles / XMLEntity.java @ 751

History | View | Annotate | Download (18.1 KB)

1
package com.iver.utiles;
2

    
3
import com.iver.utiles.xmlEntity.generate.Property;
4
import com.iver.utiles.xmlEntity.generate.XmlTag;
5

    
6

    
7
/**
8
 * Adaptador de las llamadas a sus m?todos sobre los generados por castor para
9
 * generar despu?s los XML.
10
 *
11
 * @author Vicente Caballero Navarro
12
 */
13
public class XMLEntity {
14
        private XmlTag xmltag;
15

    
16
        /**
17
         * Crea un nuevo XMLEntity.
18
         *
19
         * @param tag DOCUMENT ME!
20
         */
21
        public XMLEntity(XmlTag tag) {
22
                xmltag = tag;
23
        }
24

    
25
        /**
26
         * Crea un nuevo XMLEntity.
27
         */
28
        public XMLEntity() {
29
                xmltag = new XmlTag();
30
        }
31

    
32
        /**
33
         * A?ade una propiedad con un String como clave y un String como valor.
34
         *
35
         * @param key clave.
36
         * @param value valor.
37
         */
38
        public void putProperty(String key, String value) {
39
                if ((key == null)) {
40
                        return;
41
                }
42

    
43
                Property p = new Property();
44
                p.setKey(key);
45
                p.setValue(value);
46
                putProperty(p);
47
        }
48

    
49
        /**
50
         * A?ade una propiedad con un String como clave y un Object como valor.
51
         *
52
         * @param key clave.
53
         * @param value valor.
54
         */
55
        public void putProperty(String key, Object value) {
56
                String ret = "";
57

    
58
                if (key == null) {
59
                        return;
60
                }
61

    
62
                Class valueClass = value.getClass();
63

    
64
                if (valueClass.isArray()) {
65
                        Class compType = valueClass.getComponentType();
66

    
67
                        if (compType == byte.class) {
68
                                byte[] array = (byte[]) value;
69

    
70
                                if (!(array.length == 0)) {
71
                                        ret += ("" + array[0]).replaceAll("[,]", "\\\\,");
72

    
73
                                        for (int i = 1; i < array.length; i++) {
74
                                                ret += (" ," +
75
                                                ("" + array[i]).replaceAll("[,]", "\\\\,"));
76
                                        }
77
                                }
78
                        } else if (compType == short.class) {
79
                                short[] array = (short[]) value;
80

    
81
                                if (!(array.length == 0)) {
82
                                        ret += ("" + array[0]).replaceAll("[,]", "\\\\,");
83

    
84
                                        for (int i = 1; i < array.length; i++) {
85
                                                ret += (" ," +
86
                                                ("" + array[i]).replaceAll("[,]", "\\\\,"));
87
                                        }
88
                                }
89
                        } else if (compType == int.class) {
90
                                int[] array = (int[]) value;
91

    
92
                                if (!(array.length == 0)) {
93
                                        ret += ("" + array[0]).replaceAll("[,]", "\\\\,");
94

    
95
                                        for (int i = 1; i < array.length; i++) {
96
                                                ret += (" ," +
97
                                                ("" + array[i]).replaceAll("[,]", "\\\\,"));
98
                                        }
99
                                }
100
                        } else if (compType == long.class) {
101
                                long[] array = (long[]) value;
102

    
103
                                if (!(array.length == 0)) {
104
                                        ret += ("" + array[0]).replaceAll("[,]", "\\\\,");
105

    
106
                                        for (int i = 1; i < array.length; i++) {
107
                                                ret += (" ," +
108
                                                ("" + array[i]).replaceAll("[,]", "\\\\,"));
109
                                        }
110
                                }
111
                        } else if (compType == float.class) {
112
                                float[] array = (float[]) value;
113

    
114
                                if (!(array.length == 0)) {
115
                                        ret += ("" + array[0]).replaceAll("[,]", "\\\\,");
116

    
117
                                        for (int i = 1; i < array.length; i++) {
118
                                                ret += (" ," +
119
                                                ("" + array[i]).replaceAll("[,]", "\\\\,"));
120
                                        }
121
                                }
122
                        } else if (compType == double.class) {
123
                                double[] array = (double[]) value;
124

    
125
                                if (!(array.length == 0)) {
126
                                        ret += ("" + array[0]).replaceAll("[,]", "\\\\,");
127

    
128
                                        for (int i = 1; i < array.length; i++) {
129
                                                ret += (" ," +
130
                                                ("" + array[i]).replaceAll("[,]", "\\\\,"));
131
                                        }
132
                                }
133
                        } else if (compType == boolean.class) {
134
                                boolean[] array = (boolean[]) value;
135

    
136
                                if (!(array.length == 0)) {
137
                                        ret += ("" + array[0]).replaceAll("[,]", "\\\\,");
138

    
139
                                        for (int i = 1; i < array.length; i++) {
140
                                                ret += (" ," +
141
                                                ("" + array[i]).replaceAll("[,]", "\\\\,"));
142
                                        }
143
                                }
144
                        } else if (compType == String.class) {
145
                                String[] array = (String[]) value;
146

    
147
                                if (!(array.length == 0)) {
148
                                        if (array[0] == null) {
149
                                                array[0] = "null";
150
                                        }
151

    
152
                                        ret += array[0].replaceAll("[,]", "\\\\,");
153

    
154
                                        for (int i = 1; i < array.length; i++) {
155
                                                if (array[i] == null) {
156
                                                        array[i] = "null";
157
                                                }
158

    
159
                                                array[i] = array[i].replaceAll("[,]", "\\\\,");
160
                                                ret += (" ," + array[i]);
161
                                        }
162
                                }
163
                        } else {
164
                                Object[] array = (Object[]) value;
165

    
166
                                if (!(array.length == 0)) {
167
                                        ret += ("" + array[0]).replaceAll("[,]", "\\\\,");
168

    
169
                                        for (int i = 1; i < array.length; i++) {
170
                                                array[i] = ("" + array[i]).replaceAll("[,]", "\\\\,");
171
                                                ret += (" ," + array[i]);
172
                                        }
173
                                }
174
                        }
175
                } else {
176
                        ret = value.toString();
177
                }
178

    
179
                Property p = new Property();
180
                p.setKey(key);
181
                p.setValue(ret);
182
                putProperty(p);
183
        }
184

    
185
        /**
186
         * A?ade una propiedad con un String como clave y un entero como valor.
187
         *
188
         * @param key clave.
189
         * @param value valor.
190
         */
191
        public void putProperty(String key, int value) {
192
                if (key == null) {
193
                        return;
194
                }
195

    
196
                Property p = new Property();
197
                p.setKey(key);
198
                p.setValue(new Integer(value).toString());
199
                putProperty(p);
200
        }
201

    
202
        /**
203
         * A?ade una propiedad con un String como clave y un long como valor.
204
         *
205
         * @param key clave.
206
         * @param value valor.
207
         */
208
        public void putProperty(String key, long value) {
209
                if (key == null) {
210
                        return;
211
                }
212

    
213
                Property p = new Property();
214
                p.setKey(key);
215
                p.setValue(new Long(value).toString());
216
                putProperty(p);
217
        }
218

    
219
        /**
220
         * A?ade una propiedad con un String como clave y un boolean como valor.
221
         *
222
         * @param key clave.
223
         * @param value valor.
224
         */
225
        public void putProperty(String key, boolean value) {
226
                if (key == null) {
227
                        return;
228
                }
229

    
230
                Property p = new Property();
231
                p.setKey(key);
232
                p.setValue(new Boolean(value).toString());
233
                putProperty(p);
234
        }
235

    
236
        /**
237
         * A?ade una propiedad con un String como clave y un float como valor.
238
         *
239
         * @param key clave.
240
         * @param value valor.
241
         */
242
        public void putProperty(String key, float value) {
243
                if (key == null) {
244
                        return;
245
                }
246

    
247
                Property p = new Property();
248
                p.setKey(key);
249
                p.setValue(new Float(value).toString());
250
                putProperty(p);
251
        }
252

    
253
        /**
254
         * A?ade una propiedad con un String como clave y un double como valor.
255
         *
256
         * @param key clave.
257
         * @param value valor.
258
         */
259
        public void putProperty(String key, double value) {
260
                if (key == null) {
261
                        return;
262
                }
263

    
264
                Property p = new Property();
265
                p.setKey(key);
266
                p.setValue(new Double(value).toString());
267
                putProperty(p);
268
        }
269

    
270
        /**
271
         * Devuelve el String que corresponda a la clave que se pasa como
272
         * par?metro.
273
         *
274
         * @param key clave
275
         *
276
         * @return valor.
277
         *
278
         * @throws NotExistInXMLEntity Lanza esta excepci?n si no se encuentra
279
         *                    ning?n elemento con esa clave.
280
         */
281
        public String getStringProperty(String key) {
282
                Property[] properties = xmltag.getProperty();
283
                String res = null;
284
                boolean exists = false;
285

    
286
                for (int i = 0; i < properties.length; i++) {
287
                        if (properties[i].getKey().compareTo(key) == 0) {
288
                                res = properties[i].getValue();
289
                                exists = true;
290
                        }
291
                }
292

    
293
                if (exists) {
294
                        return res;
295
                }
296

    
297
                throw new NotExistInXMLEntity();
298
        }
299

    
300
        /**
301
         * Devuelve el double que corresponda a la clave que se pasa como
302
         * par?metro.
303
         *
304
         * @param key clave
305
         *
306
         * @return valor.
307
         *
308
         * @throws NotExistInXMLEntity Lanza esta excepci?n si no se encuentra
309
         *                    ning?n elemento con esa clave.
310
         */
311
        public double getDoubleProperty(String key) {
312
                Property[] properties = xmltag.getProperty();
313
                double res = 0;
314
                boolean exists = false;
315

    
316
                for (int i = 0; i < properties.length; i++) {
317
                        if (properties[i].getKey().compareTo(key) == 0) {
318
                                res = Double.parseDouble(properties[i].getValue());
319
                                exists = true;
320
                        }
321
                }
322

    
323
                if (exists) {
324
                        return res;
325
                }
326

    
327
                throw new NotExistInXMLEntity();
328
        }
329

    
330
        /**
331
         * Devuelve el array de doubles que corresponda a la clave que se pasa como
332
         * par?metro.
333
         *
334
         * @param key clave
335
         *
336
         * @return valor.
337
         *
338
         * @throws NotExistInXMLEntity Lanza esta excepci?n si no se encuentra
339
         *                    ning?n elemento con esa clave.
340
         */
341
        public double[] getDoubleArrayProperty(String key) {
342
                Property[] properties = xmltag.getProperty();
343
                String value = null;
344
                boolean exists = false;
345

    
346
                for (int i = 0; i < properties.length; i++) {
347
                        if (properties[i].getKey().compareTo(key) == 0) {
348
                                value = properties[i].getValue();
349
                                exists = true;
350
                        }
351
                }
352

    
353
                if (!exists) {
354
                        throw new NotExistInXMLEntity();
355
                }
356

    
357
                if (value.compareTo("") == 0) {
358
                        return new double[0];
359
                }
360

    
361
                String[] aux = (String[]) value.split(" ,");
362
                double[] ret = new double[aux.length];
363

    
364
                for (int i = 0; i < aux.length; i++) {
365
                        ret[i] = Double.parseDouble(aux[i].replaceAll("\\\\,", ","));
366
                }
367

    
368
                return ret;
369
        }
370

    
371
        /**
372
         * Devuelve el Object que corresponda a la clave que se pasa como
373
         * par?metro.
374
         *
375
         * @param key clave
376
         *
377
         * @return valor.
378
         *
379
         * @throws NotExistInXMLEntity Lanza esta excepci?n si no se encuentra
380
         *                    ning?n elemento con esa clave.
381
         */
382
        public Object getObjectProperty(String key) {
383
                Property[] properties = xmltag.getProperty();
384
                Object res = null;
385
                boolean exists = false;
386

    
387
                for (int i = 0; i < properties.length; i++) {
388
                        if (properties[i].getKey().compareTo(key) == 0) {
389
                                res = properties[i].getValue();
390
                                exists = true;
391
                        }
392
                }
393

    
394
                if (exists) {
395
                        return res;
396
                }
397

    
398
                throw new NotExistInXMLEntity();
399
        }
400

    
401
        /**
402
         * Devuelve el array de float que corresponda a la clave que se pasa como
403
         * par?metro.
404
         *
405
         * @param key clave
406
         *
407
         * @return valor.
408
         *
409
         * @throws NotExistInXMLEntity Lanza esta excepci?n si no se encuentra
410
         *                    ning?n elemento con esa clave.
411
         */
412
        public float[] getFloatArrayProperty(String key) {
413
                Property[] properties = xmltag.getProperty();
414
                String value = null;
415
                boolean exists = false;
416

    
417
                for (int i = 0; i < properties.length; i++) {
418
                        if (properties[i].getKey().compareTo(key) == 0) {
419
                                value = properties[i].getValue();
420
                                exists = true;
421
                        }
422
                }
423

    
424
                if (!exists) {
425
                        throw new NotExistInXMLEntity();
426
                }
427

    
428
                if (value.compareTo("") == 0) {
429
                        return new float[0];
430
                }
431

    
432
                String[] aux = (String[]) value.split(" ,");
433
                float[] ret = new float[aux.length];
434

    
435
                for (int i = 0; i < aux.length; i++) {
436
                        ret[i] = Float.parseFloat(aux[i].replaceAll("\\\\,", ","));
437
                }
438

    
439
                return ret;
440
        }
441

    
442
        /**
443
         * Devuelve el array de long que corresponda a la clave que se pasa como
444
         * par?metro.
445
         *
446
         * @param key clave
447
         *
448
         * @return valor.
449
         *
450
         * @throws NotExistInXMLEntity Lanza esta excepci?n si no se encuentra
451
         *                    ning?n elemento con esa clave.
452
         */
453
        public long[] getLongArrayProperty(String key) {
454
                Property[] properties = xmltag.getProperty();
455
                String value = null;
456
                boolean exists = false;
457

    
458
                for (int i = 0; i < properties.length; i++) {
459
                        if (properties[i].getKey().compareTo(key) == 0) {
460
                                value = properties[i].getValue();
461
                                exists = true;
462
                        }
463
                }
464

    
465
                if (!exists) {
466
                        throw new NotExistInXMLEntity();
467
                }
468

    
469
                if (value.compareTo("") == 0) {
470
                        return new long[0];
471
                }
472

    
473
                String[] aux = (String[]) value.split(" ,");
474
                long[] ret = new long[aux.length];
475

    
476
                for (int i = 0; i < aux.length; i++) {
477
                        ret[i] = Long.parseLong(aux[i].replaceAll("\\\\,", ","));
478
                }
479

    
480
                return ret;
481
        }
482

    
483
        /**
484
         * Devuelve el array de enteros que corresponda a la clave que se pasa como
485
         * par?metro.
486
         *
487
         * @param key clave
488
         *
489
         * @return valor.
490
         *
491
         * @throws NotExistInXMLEntity Lanza esta excepci?n si no se encuentra
492
         *                    ning?n elemento con esa clave.
493
         */
494
        public int[] getIntArrayProperty(String key) {
495
                Property[] properties = xmltag.getProperty();
496
                String value = null;
497
                boolean exists = false;
498

    
499
                for (int i = 0; i < properties.length; i++) {
500
                        if (properties[i].getKey().compareTo(key) == 0) {
501
                                value = properties[i].getValue();
502
                                exists = true;
503
                        }
504
                }
505

    
506
                if (!exists) {
507
                        throw new NotExistInXMLEntity();
508
                }
509

    
510
                if (value.compareTo("") == 0) {
511
                        return new int[0];
512
                }
513

    
514
                String[] aux = (String[]) value.split(" ,");
515
                int[] ret = new int[aux.length];
516

    
517
                for (int i = 0; i < aux.length; i++) {
518
                        ret[i] = Integer.parseInt(aux[i].replaceAll("\\\\,", ","));
519
                }
520

    
521
                return ret;
522
        }
523

    
524
        /**
525
         * Devuelve el array de boolean que corresponda a la clave que se pasa como
526
         * par?metro.
527
         *
528
         * @param key clave
529
         *
530
         * @return valor.
531
         *
532
         * @throws NotExistInXMLEntity Lanza esta excepci?n si no se encuentra
533
         *                    ning?n elemento con esa clave.
534
         */
535
        public boolean[] getBooleanArrayProperty(String key) {
536
                Property[] properties = xmltag.getProperty();
537
                String value = null;
538
                boolean exists = false;
539

    
540
                for (int i = 0; i < properties.length; i++) {
541
                        if (properties[i].getKey().compareTo(key) == 0) {
542
                                value = properties[i].getValue();
543
                                exists = true;
544
                        }
545
                }
546

    
547
                if (!exists) {
548
                        throw new NotExistInXMLEntity();
549
                }
550

    
551
                if (value.compareTo("") == 0) {
552
                        return new boolean[0];
553
                }
554

    
555
                String[] aux = (String[]) value.split(" ,");
556
                boolean[] ret = new boolean[aux.length];
557

    
558
                for (int i = 0; i < aux.length; i++) {
559
                        ret[i] = Boolean.valueOf(aux[i].replaceAll("\\\\,", ","))
560
                                                        .booleanValue();
561
                }
562

    
563
                return ret;
564
        }
565

    
566
        /**
567
         * Devuelve el array de String que corresponda a la clave que se pasa como
568
         * par?metro.
569
         *
570
         * @param key clave
571
         *
572
         * @return valor.
573
         *
574
         * @throws NotExistInXMLEntity Lanza esta excepci?n si no se encuentra
575
         *                    ning?n elemento con esa clave.
576
         */
577
        public String[] getStringArrayProperty(String key) {
578
                ///String value = (String) properties.get(key);
579
                Property[] properties = xmltag.getProperty();
580
                String value = null;
581
                boolean exists = false;
582

    
583
                for (int i = 0; i < properties.length; i++) {
584
                        if (properties[i].getKey().compareTo(key) == 0) {
585
                                value = properties[i].getValue();
586
                                exists = true;
587
                        }
588
                }
589

    
590
                if (!exists) {
591
                        throw new NotExistInXMLEntity();
592
                }
593

    
594
                if (value.compareTo("") == 0) {
595
                        return new String[0];
596
                }
597

    
598
                String[] aux = (String[]) value.split(" ,");
599

    
600
                for (int i = 0; i < aux.length; i++) {
601
                        aux[i] = aux[i].replaceAll("\\\\,", ",");
602
                }
603

    
604
                return aux;
605
        }
606

    
607
        /**
608
         * Devuelve el boolean que corresponda a la clave que se pasa como
609
         * par?metro.
610
         *
611
         * @param key clave
612
         *
613
         * @return valor.
614
         *
615
         * @throws NotExistInXMLEntity Lanza esta excepci?n si no se encuentra
616
         *                    ning?n elemento con esa clave.
617
         */
618
        public boolean getBooleanProperty(String key) {
619
                Property[] properties = xmltag.getProperty();
620
                boolean res = false;
621
                boolean exists = false;
622

    
623
                for (int i = 0; i < properties.length; i++) {
624
                        if (properties[i].getKey().compareTo(key) == 0) {
625
                                res = (boolean) Boolean.valueOf(properties[i].getValue())
626
                                                                           .booleanValue();
627
                                exists = true;
628
                        }
629
                }
630

    
631
                if (exists) {
632
                        return res;
633
                }
634

    
635
                throw new NotExistInXMLEntity();
636
        }
637

    
638
        /**
639
         * Devuelve el entero que corresponda a la clave que se pasa como
640
         * par?metro.
641
         *
642
         * @param key clave
643
         *
644
         * @return valor.
645
         *
646
         * @throws NotExistInXMLEntity Lanza esta excepci?n si no se encuentra
647
         *                    ning?n elemento con esa clave.
648
         */
649
        public int getIntProperty(String key) {
650
                Property[] properties = xmltag.getProperty();
651
                int res = 0;
652
                boolean exists = false;
653

    
654
                for (int i = 0; i < properties.length; i++) {
655
                        if (properties[i].getKey().compareTo(key) == 0) {
656
                                res = Integer.parseInt(properties[i].getValue());
657
                                exists=true;
658
                        }
659
                }
660

    
661
                if (exists) {
662
                        return res;
663
                }
664

    
665
                throw new NotExistInXMLEntity();
666
        }
667

    
668
        /**
669
         * Devuelve el long que corresponda a la clave que se pasa como par?metro.
670
         *
671
         * @param key clave
672
         *
673
         * @return valor.
674
         *
675
         * @throws NotExistInXMLEntity Lanza esta excepci?n si no se encuentra
676
         *                    ning?n elemento con esa clave.
677
         */
678
        public long getLongProperty(String key) {
679
                Property[] properties = xmltag.getProperty();
680
                long res = 0;
681
                boolean exists = false;
682

    
683
                for (int i = 0; i < properties.length; i++) {
684
                        if (properties[i].getKey().compareTo(key) == 0) {
685
                                res = Long.valueOf(properties[i].getValue()).longValue();
686
                                exists = true;
687
                        }
688
                }
689

    
690
                if (exists) {
691
                        return res;
692
                }
693

    
694
                throw new NotExistInXMLEntity();
695
        }
696

    
697
        /**
698
         * Devuelve el float que corresponda a la clave que se pasa como par?metro.
699
         *
700
         * @param key clave
701
         *
702
         * @return valor.
703
         *
704
         * @throws NotExistInXMLEntity Lanza esta excepci?n si no se encuentra
705
         *                    ning?n elemento con esa clave.
706
         */
707
        public float getFloatProperty(String key) {
708
                Property[] properties = xmltag.getProperty();
709
                float res = 0;
710
                boolean exists = false;
711

    
712
                for (int i = 0; i < properties.length; i++) {
713
                        if (properties[i].getKey().compareTo(key) == 0) {
714
                                res = Float.valueOf(properties[i].getValue()).floatValue();
715
                                exists = true;
716
                        }
717
                }
718

    
719
                if (exists) {
720
                        return res;
721
                }
722

    
723
                throw new NotExistInXMLEntity();
724
        }
725

    
726
        /**
727
         * A?ade el nombre con clave name y valor el String que se pasa como
728
         * par?metro.
729
         *
730
         * @param name nombre.
731
         */
732
        public void setName(String name) {
733
                Property p = new Property();
734
                p.setKey("name");
735
                p.setValue(name);
736
                xmltag.addProperty(p);
737
        }
738

    
739
        /**
740
         * Devuelve el nombre.
741
         *
742
         * @return nombre.
743
         */
744
        public String getName() {
745
                Property p = getProperty("name");
746

    
747
                return (String) p.getValue();
748
        }
749

    
750
        /**
751
         * Devuelve la clase que implementa.
752
         *
753
         * @return clase.
754
         */
755
        public Class getImplementingClass() {
756
                Property p = getProperty("class");
757
                Object ob = p.getValue();
758

    
759
                return (Class) ob;
760
        }
761

    
762
        /**
763
         * A?ade la clase que implementa
764
         *
765
         * @param c
766
         */
767
        public void setImplementingClass(Class c) {
768
                Property p = new Property();
769
                p.setKey("class");
770
                p.setValue(c.toString());
771
                xmltag.addProperty(p);
772
        }
773

    
774
        /**
775
         * A?ade un hijo al XMLEntity.
776
         *
777
         * @param entity xml para a?adir.
778
         */
779
        public void addChild(XMLEntity entity) {
780
                xmltag.addXmlTag(entity.getXmlTag());
781
        }
782

    
783
        /**
784
         * Devuelve un hijo a partir de un indice.
785
         *
786
         * @param i indice.
787
         *
788
         * @return hijo.
789
         */
790
        public XMLEntity getChild(int i) {
791
                return new XMLEntity(xmltag.getXmlTag(i));
792
        }
793

    
794
        /**
795
         * Devuelve el n?mero de hijos que contiene el XMLEntity.
796
         *
797
         * @return n?mero de hijos.
798
         */
799
        public int getNumChild() {
800
                return xmltag.getXmlTagCount();
801
        }
802

    
803
        /**
804
         * Devuelve los xmlTag hijos del actual xmltag.
805
         *
806
         * @return hijo.
807
         */
808
        public XmlTag[] hijos() {
809
                return xmltag.getXmlTag();
810
        }
811

    
812
        /**
813
         * Devuelve el Property a partir de la clave.
814
         *
815
         * @param key clave.
816
         *
817
         * @return Property.
818
         */
819
        private Property getProperty(String key) {
820
                Property[] ps = xmltag.getProperty();
821

    
822
                for (int i = 0; i < ps.length; i++) {
823
                        if (ps[i].getKey().compareTo(key) == 0) {
824
                                return ps[i];
825
                        }
826
                }
827

    
828
                return null;
829
        }
830

    
831
        /**
832
         * Devuelve el xmltag.
833
         *
834
         * @return xmltag.
835
         */
836
        public XmlTag getXmlTag() {
837
                return xmltag;
838
        }
839

    
840
        /**
841
         * A?ade el property que se pasa como par?metro.
842
         *
843
         * @param p property.
844
         */
845
        private void putProperty(Property p) {
846
                for (int i = 0; i < xmltag.getPropertyCount(); i++) {
847
                        if (xmltag.getProperty(i).getKey().compareTo(p.getKey()) == 0) {
848
                                xmltag.getProperty(i).setValue(p.getValue());
849

    
850
                                return;
851
                        }
852
                }
853

    
854
                xmltag.addProperty(p);
855
        }
856
        public boolean contains(String key) {
857
                Property[] properties = xmltag.getProperty();
858
                boolean exists = false;
859

    
860
                for (int i = 0; i < properties.length; i++) {
861
                        if (properties[i].getKey().compareTo(key) == 0) {
862
                                exists = true;
863
                        }
864
                }
865
                return exists;
866
        }
867
}