Repository navigation
Expand file tree
/
Copy pathSidex.java
More file actions
2445 lines (2249 loc) · 77.1 KB
/
Copy pathSidex.java
File metadata and controls
2445 lines (2249 loc) · 77.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
/*
* libTML: A BEEP based Messaging Suite
* Copyright (C) 2015 wobe-systems GmbH
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
*
* This program 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* You may find a copy of the license under this software is released
* at COPYING file. This is LGPL software: you are welcome to develop
* proprietary applications using this library without any royalty or
* fee but returning back any change, improvement or addition in the
* form of source code, project image, documentation patches, etc.
*
* Homepage:
* http://www.libtml.org
*
* For professional support contact us:
*
* wobe-systems GmbH
*/
/** @defgroup sdxGroup SIDEX API
* @ingroup basicAPI
* @brief SIDEX API functions.
*/
/** @ingroup sdxGroup
* @defgroup sdxgeneral General functions
* @brief General SIDEX API functions.
*/
/** @ingroup sdxGroup
* @defgroup sdxreturn Return values
* @brief Return values of SIDEX API function calls.
*/
/** @ingroup sdxGroup
* @defgroup sidexHandle SIDEX document
* @brief Handling of SIDEX documents
*/
/** @ingroup sidexHandle
* @defgroup navigationType Group/Key managment
* @brief Managing groups and keys in SIDEX documents
*/
/** @ingroup sidexHandle
* @defgroup sdxDocRWValues Read/Write values
* @brief Read/Write values from/to the SIDEX document.
*/
/** @ingroup sdxGroup
* @defgroup datatypes SIDEX datatypes
* @brief SIDEX API for supported datatypes
*/
/** @ingroup datatypes
* @defgroup varianttype General variant functions
* @brief General functions to handle data objects.
*/
/** @ingroup datatypes
* @defgroup simpletypes Simple data types
* @brief Simple data objects.
*/
/** @ingroup datatypes
* @defgroup complextypes container types
* @brief Datatypes containing multiple variant values.
*/
/** @ingroup datatypes
* @defgroup typeconst type id constants
* @brief Type id constants
*/
/** @ingroup simpletypes
* @defgroup inttype Integer
* @brief Handling of integer values
*/
/** @ingroup simpletypes
* @defgroup nonetype None
* @brief Handling of None values
*/
/** @ingroup simpletypes
* @defgroup booltype Boolean
* @brief Handling of Boolean values
*/
/** @ingroup simpletypes
* @defgroup floattype Float
* @brief Handling of Float values
*/
/** @ingroup simpletypes
* @defgroup stringtype String
* @brief Handling of String values
*/
/** @ingroup simpletypes
* @defgroup bintype Binary
* @brief Handling of Binary data
*/
/** @ingroup simpletypes
* @defgroup datetimetype DateTime
* @brief Handling of DateTime values
*/
/** @ingroup complextypes
* @defgroup listtype List
* @brief A list of values.
*/
/** @ingroup complextypes
* @defgroup dicttype Dictionary
* @brief Values organized in a dictionary with a string key.
*/
/** @ingroup complextypes
* @defgroup tabletype Table
* @brief A table with rows and columns.
*/
package com.tmlsidex.jni;
import java.nio.ByteBuffer;
/**
* Native SIDEX API functions.
**/
public class Sidex {
///////////////////////
// General:
private native void NativeSidexGetCopyright(StringBuffer sValue, int[] iLength);
private native void NativeSidexGetVersion(int[] apiVer, int[] libVer, StringBuffer vderStr);
private native int NativeSidexSetPassword(String pUserName, String pPassWord);
///////////////////////
// SIDEX document:
private native int NativeSidexCreate(String sDoc, long[] sHandle);
private native void NativeSidexFree(long sHandle);
// sidex_Free_Content is not necessary on JAVA
private native void NativeSidexClear(long sHandle);
private native int NativeSidexGetContent(long sHandle, StringBuffer sContent, int[] iLength);
private native int NativeSidexGetContentLength(long sHandle, int[] iLength);
private native int NativeSidexGetDocumentName(long sHandle, StringBuffer sName);
private native int NativeSidexMerge(long sBaseHandle, long sMergeHandle, boolean bOverwrite, String sGroup, String sKey);
private native int NativeSidexSaveContent(long sHandle, String sPath);
private native int NativeSidexLoadContent(long sHandle, String sPath);
private native int NativeSidexSetContent(long sHandle, String sContent);
private native int NativeSidexSetDocumentName(long sHandle, String sName);
////////////////////////////////////////////////
//SIDEX document / Group/Key management
private native int NativeSidexDeleteGroup(long sHandle, String sGroup);
private native int NativeSidexDeleteKey(long sHandle, String sGroup, String sKey);
private native int NativeSidexGetGroups(long sHandle, long[] variant);
private native int NativeSidexGetKeys(long sHandle, String sGroup, long[] variant);
private native boolean NativeSidexHasGroup(long sHandle, String sGroup);
private native boolean NativeSidexHasKey(long sHandle, String sGroup, String sKey);
////////////////////////////////////
// SIDEX document Read/Write values
private native int NativeSidexBinaryLength(long sHandle, String sGroup, String sKey, int[] iStrLength);
private native int NativeSidexBinaryRead(long sHandle, String sGroup, String sKey, ByteBuffer value, int[] iStrLength);
private native int NativeSidexBinaryWrite(long sHandle, String sGroup, String sKey, byte[] value, int iSize);
private native int NativeSidexBooleanRead(long sHandle, String sGroup, String sKey, boolean[] value);
private native int NativeSidexBooleanWrite(long sHandle, String sGroup, String sKey, boolean value);
private native int NativeSidexDateTimeRead(long sHandle, String sGroup, String sKey, long[] value);
private native int NativeSidexDateTimeWrite(long sHandle, String sGroup, String sKey,long value);
private native int NativeSidexDictRead(long sHandle, String sGroup, String sKey, long[] value);
private native int NativeSidexDictWrite(long sHandle, String sGroup, String sKey,long value);
private native int NativeSidexFloatRead(long sHandle, String sGroup, String sKey, double[] value);
private native int NativeSidexFloatWrite(long sHandle, String sGroup, String sKey,double value);
// sidex_Free_Binary_ReadString is not necessary on JAVA
// sidex_Free_ReadString is not necessary on JAVA
private native int NativeSidexIntegerRead(long sHandle, String sGroup, String sKey, long[] value);
private native int NativeSidexIntegerWrite(long sHandle, String sGroup, String sKey,long value);
private native int NativeSidexListRead(long sHandle, String sGroup, String sKey, long[] value);
private native int NativeSidexListWrite(long sHandle, String sGroup, String sKey,long value);
private native int NativeSidexNoneWrite(long sHandle, String sGroup, String sKey);
private native int NativeSidexStringLength(long sHandle, String sGroup, String sKey, int[] iLength);
private native int NativeSidexStringRead(long sHandle, String sGroup, String sKey, StringBuffer sValue, int[] iLength);
private native int NativeSidexStringWrite(long sHandle, String sGroup, String sKey, String sValue);
private native int NativeSidexTableRead(long sHandle, String sGroup, String sKey, long[] value);
private native int NativeSidexTableWrite(long sHandle, String sGroup, String sKey,long value);
private native int NativeSidexVariantRead(long sHandle, String sGroup, String sKey, long[] sVariant);
private native int NativeSidexVariantWrite(long sHandle, String sGroup, String sKey,long sVariant);
////////////////////////////////////////////////
//SIDEX datatypes / General variant functions
private native long NativeSidexVariantCopy(long variant);
private native int NativeSidexVariantDecRef(long variant);
private native int NativeSidexVariantGetType(long variant);
private native void NativeSidexVariantIncRef(long variant);
////////////////////////////////////////////////
//Simple data types / Integer
private native int NativeSidexVariantAsInteger(long variant, long[] value);
private native boolean NativeSidexVariantIntegerCheck(long variant);
private native long NativeSidexVariantNewInteger(long value);
////////////////////////////////////////////////
//Simple data types / None
private native boolean NativeSidexVariantNoneCheck(long variant);
private native long NativeSidexVariantNewNone();
////////////////////////////////////////////////
//Simple data types / Boolean
private native int NativeSidexVariantAsBoolean(long variant, boolean[] value);
private native boolean NativeSidexVariantBooleanCheck(long variant);
private native long NativeSidexVariantNewBoolean(boolean value);
////////////////////////////////////////////////
//Simple data types / Float
private native int NativeSidexVariantAsFloat(long variant, double[] value);
private native boolean NativeSidexVariantFloatCheck(long variant);
private native long NativeSidexVariantNewFloat(double value);
////////////////////////////////////////////////
//Simple data types / String
private native int NativeSidexVariantAsString(long variant, StringBuffer sValue, int[] iLength);
private native int NativeSidexVariantAsStringLength(long variant, int[] iLength);
private native int NativeSidexVariantNewString(String value, long[] variant);
private native boolean NativeSidexVariantStringCheck(long variant);
private native int NativeSidexVariantStringGetFormat(long variant, StringBuffer sValue);
private native int NativeSidexVariantStringSetFormat(long variant, String sValue);
////////////////////////////////////////////////
//Simple data types / Binary
private native int NativeSidexVariantAsBinary(long variant, ByteBuffer sValue, int[] iLength);
private native int NativeSidexVariantAsBinaryLength(long variant, int[] iLength);
private native boolean NativeSidexVariantBinaryCheck(long variant);
private native int NativeSidexVariantNewBinary(byte[] value, int length, long[] variant);
////////////////////////////////////////////////
//Simple data types / DateTime
private native int NativeSidexVariantAsDateTime(long variant, StringBuffer sValue);
private native boolean NativeSidexVariantDateTimeCheck(long variant);
private native int NativeSidexVariantNewDateTime(String value, long[]variant);
////////////////////////////////////////////////
//Comntainer data types / List
private native int NativeSidexVariantListAppend(long list, long value, int[]pos);
private native boolean NativeSidexVariantListCheck(long list);
private native int NativeSidexVariantListClear(long list);
private native int NativeSidexVariantListDeleteItem(long list, int pos);
private native int NativeSidexVariantListGet(long list, int index, long[] variant);
private native int NativeSidexVariantListInsert(long list, long value, int pos);
private native int NativeSidexVariantListSet(long list, long value, int pos);
private native int NativeSidexVariantListSize(long list, int[] size);
private native long NativeSidexVariantNewList();
////////////////////////////////////////////////
//Comntainer data types / Dict
private native boolean NativeSidexVariantDictCheck(long dict);
private native int NativeSidexVariantDictClear(long dict);
private native int NativeSidexVariantDictDelete(long dict, String sKey);
private native int NativeSidexVariantDictFirst(long dict);
private native int NativeSidexVariantDictGet(long dict, String sKey, long[] variant);
private native int NativeSidexVariantDictHasKey(long dict, String sKey, boolean[] bRet);
private native int NativeSidexVariantDictKeys(long dict, long[] keys);
private native int NativeSidexVariantDictNext(long dict, StringBuffer sKey, long[] variant);
private native int NativeSidexVariantDictSet(long dict, String sKey, long value);
private native int NativeSidexVariantDictSize(long dict, int[] size);
private native long NativeSidexVariantNewDict();
private native long NativeSidexVariantNewDictBySize(int size);
////////////////////////////////////////////////
//Comntainer data types / Table
private native long NativeSidexVariantNewTable();
private native int NativeSidexVariantTableAddColumn(long table, String sColumn);
private native int NativeSidexVariantTableAddRow(long table, int[] iRowIdx);
private native boolean NativeSidexVariantTableCheck(long table);
private native int NativeSidexVariantTableColumnNames(long table, long[] varNames);
private native int NativeSidexVariantTableColumns(long table, int[] iColumns);
private native int NativeSidexVariantTableDeleteColumn(long table, String sColumn);
private native int NativeSidexVariantTableDeleteRow(long table, int iRowIdx);
private native int NativeSidexVariantTableDeleteRows(long table);
private native int NativeSidexVariantTableGetColumnName(long table, int index, StringBuffer sColumn);
private native int NativeSidexVariantTableGetField(long table, int rowIndex, String sColumnName, long[] variant);
private native int NativeSidexVariantTableGetRow(long table, int rowIndex, long[] variant);
private native int NativeSidexVariantTableHasColumn(long table, String sColumnName, boolean[] bRet);
private native int NativeSidexVariantTableRows(long dict, int[] rows);
private native int NativeSidexVariantTableSetField(long table, int rowIndex, String sColumnName, long variant);
///////////////////////
// General:
/**
* \addtogroup sdxgeneral
* @{
*/
/**
* @ingroup sdxgeneral
* @brief get copyright information
*
* @param iLength array /element 0 returns the length of the copyright information
*
* @return copyright information
*/
public String sidex_Get_Copyright(int[] iLength){
StringBuffer buffer = new StringBuffer("");
NativeSidexGetCopyright(buffer, iLength);
String sRet = buffer.toString();
buffer = null;
return sRet;
}
/**
* @brief get interface api and library version
*
* @param iApiVer array of size 1 - returns api version
* @param iLibVer array of size 1 - returns library version
*
* @return copyright information
*/
public String sidex_Get_Version(int[] iApiVer, int[] iLibVer){
StringBuffer buffer = new StringBuffer("");
NativeSidexGetVersion(iApiVer, iLibVer, buffer);
String sRet = buffer.toString();
buffer = null;
return sRet;
}
/**
* @brief set the license key
*
* efore the sdk functions can be used a license key must be applied.
*
* @note This call is deprecated. It returns allways SIDEX_SUCCESS.<br>
* It has been left in the API to be backward compatible.
*
* @param pUserName user name (case sensitive)
* @param pPassWord password (case insensitive)
*/
public void sidex_Set_Password(String pUserName, String pPassWord) throws TmlSidexException{
int iRet = NativeSidexSetPassword(pUserName, pPassWord);
if (SidexErr.SIDEX_SUCCESS != iRet){
throw new TmlSidexException("sidex_Set_Password / Error "+Integer.toString(iRet), iRet);
}
}
/* @} */
///////////////////////
// SIDEX document:
/**
* \addtogroup sidexHandle
* @{
*/
/**
* @brief remove all values from the sidex document
*
* @param sHandle SIDEX document handle (SIDEX_HANDLE)
*/
public void sidex_Clear(long sHandle){
NativeSidexClear(sHandle);
return;
}
/**
* @brief create a SIDEX document handle
*
* SIDEX documents contain data based on SIDEX data objects organized in groups containing a number of keys.
* Groups and keys are names to find a specific value in the document.
* The document can be exported to/imported from an xml string or file.
*
* @param sDoc name of the document/xml root node
*
* @return SIDEX document handle (SIDEX_HANDLE). Use sidex_Free() to deallocate handle.
*
* @throws TmlSidexException
*/
public long sidex_Create(String sDoc) throws TmlSidexException{
long[] value = new long[1];
int iRet = NativeSidexCreate(sDoc, value);
if (SidexErr.SIDEX_SUCCESS != iRet){
value = null;
throw new TmlSidexException("sidex_Create / Error "+Integer.toString(iRet), iRet);
}
long lRet = value[0];
value = null;
return lRet;
}
/**
* @brief release a SIDEX document handle
*
* @param sHandle SIDEX document handle (SIDEX_HANDLE)
*/
public void sidex_Free(long sHandle){
NativeSidexFree(sHandle);
return;
}
/**
* @brief get the SIDEX document data as string
*
* @param sHandle SIDEX document handle (SIDEX_HANDLE)
*
* @return SIDEX document data as string
*
* @throws TmlSidexException
*/
public String sidex_Get_Content(long sHandle) throws TmlSidexException{
int[] iLength = new int[1];
StringBuffer buffer = new StringBuffer("");
int iRet = NativeSidexGetContent(sHandle, buffer, iLength);
if (SidexErr.SIDEX_SUCCESS != iRet){
buffer = null;
throw new TmlSidexException("sidex_Get_Content / Error "+Integer.toString(iRet), iRet);
}
String sRet = buffer.toString();
buffer = null;
iLength = null;
return sRet;
}
/**
* @brief get length of the document content
*
* @param sHandle SIDEX document handle (SIDEX_HANDLE)
*
* @return Reference to the length of the document content
*
* @throws TmlSidexException
* @see Sidex#sidex_Get_Content(long)
*/
public int sidex_Get_Content_Length(long sHandle) throws TmlSidexException{
int[] iLength = new int[1];
int iRet = NativeSidexGetContentLength(sHandle, iLength);
if (SidexErr.SIDEX_SUCCESS != iRet){
throw new TmlSidexException("sidex_Get_Content_Length / Error "+Integer.toString(iRet), iRet);
}
int iContLength = iLength[0];
iLength = null;
return iContLength;
}
/**
* @brief get the document name
*
* @param sHandle SIDEX document handle (SIDEX_HANDLE)
*
* @return name of the document
*
* @throws TmlSidexException
*/
public String sidex_Get_DocumentName(long sHandle) throws TmlSidexException{
StringBuffer buffer = new StringBuffer("");
int iRet = NativeSidexGetDocumentName(sHandle, buffer);
if (SidexErr.SIDEX_SUCCESS != iRet){
buffer = null;
throw new TmlSidexException("sidex_Get_DocumentName / Error "+Integer.toString(iRet), iRet);
}
String sRet = buffer.toString();
buffer = null;
return sRet;
}
/**
* @brief read a SIDEX document from a file
*
* @note If the document already contains data it will be deleted.
*
* @param sHandle SIDEX document handle (SIDEX_HANDLE)
* @param sPath path to SIDEX file
*
* @throws TmlSidexException
*/
public void sidex_Load_Content(long sHandle, String sPath) throws TmlSidexException{
int iRet = NativeSidexLoadContent(sHandle, sPath);
if (SidexErr.SIDEX_SUCCESS != iRet){
throw new TmlSidexException("sidex_Load_Content / Error "+Integer.toString(iRet), iRet);
}
}
/**
* @brief merge SIDEX document data
*
* @param sBaseHandle SIDEX document handle (SIDEX_HANDLE)
* @param sMergeHandle SIDEX document handle (SIDEX_HANDLE) to be merged
* @param bOverwrite if true the existing group,key pairs will be overwritten
* @param sGroup name of the group
* @param sKey name of the key or SIDEX_HANDLETYPE_NULL (complete group)
*
* @throws TmlSidexException
*/
public void sidex_Merge(long sBaseHandle, long sMergeHandle, boolean bOverwrite, String sGroup, String sKey) throws TmlSidexException{
int iRet = NativeSidexMerge(sBaseHandle, sMergeHandle, bOverwrite, sGroup, sKey);
if (SidexErr.SIDEX_SUCCESS != iRet){
throw new TmlSidexException("sidex_Merge / Error "+Integer.toString(iRet), iRet);
}
}
/**
* @brief Write a SIDEX document to a file
*
* @note If the file exits, it will be replaced.
*
* @param sHandle SIDEX document handle (SIDEX_HANDLE)
* @param sPath file path and name
*
* @throws TmlSidexException
*/
public void sidex_Save_Content(long sHandle, String sPath) throws TmlSidexException{
int iRet = NativeSidexSaveContent(sHandle, sPath);
if (SidexErr.SIDEX_SUCCESS != iRet){
throw new TmlSidexException("sidex_Save_Content / Error "+Integer.toString(iRet), iRet);
}
}
/**
* @brief read a SIDEX document from a string
*
* @note If the document already contains data it will be deleted.
*
* @param sHandle SIDEX document handle (SIDEX_HANDLE)
* @param sContent SIDEX document data
*
* @throws TmlSidexException
*/
public void sidex_Set_Content(long sHandle, String sContent) throws TmlSidexException{
int iRet = NativeSidexSetContent(sHandle, sContent);
if (SidexErr.SIDEX_SUCCESS != iRet){
throw new TmlSidexException("sidex_Set_Content / Error "+Integer.toString(iRet), iRet);
}
}
/**
* @brief change the document name
*
* @param sHandle SIDEX document handle (SIDEX_HANDLE)
* @param sName name of the document/xml root node
*
* @throws TmlSidexException
*/
public void sidex_Set_DocumentName(long sHandle, String sName) throws TmlSidexException{
int iRet = NativeSidexSetDocumentName(sHandle, sName);
if (SidexErr.SIDEX_SUCCESS != iRet){
throw new TmlSidexException("sidex_Set_DocumentName / Error "+Integer.toString(iRet), iRet);
}
}
/* @} */
////////////////////////////////////////////////
//SIDEX document / Group/Key management
/**
* \addtogroup navigationType
* @{
*/
/**
* @brief delete a group from the document
*
* @param sHandle SIDEX document handle (SIDEX_HANDLE)
* @param sGroup name of the group
*
* @throws TmlSidexException
*/
public void sidex_DeleteGroup(long sHandle, String sGroup)throws TmlSidexException{
int iRet = NativeSidexDeleteGroup(sHandle, sGroup);
if (SidexErr.SIDEX_SUCCESS != iRet){
throw new TmlSidexException("sidex_DeleteGroup / Error "+Integer.toString(iRet), iRet);
}
}
/**
* @brief delete a key, value pair from the document
*
* @param sHandle SIDEX document handle (SIDEX_HANDLE)
* @param sGroup name of the group
* @param sKey name of the key
*
* @throws TmlSidexException
*/
public void sidex_DeleteKey(long sHandle, String sGroup, String sKey) throws TmlSidexException{
int iRet = NativeSidexDeleteKey(sHandle, sGroup, sKey);
if (SidexErr.SIDEX_SUCCESS != iRet){
throw new TmlSidexException("sidex_DeleteKey / Error "+Integer.toString(iRet), iRet);
}
}
/**
* @brief get a list of group names
*
* @param sHandle SIDEX document handle (SIDEX_HANDLE)
*
* @return SIDEX variant List value. The list contains all group names of the SIDEX document
* and must be released by sidex_Variant_DecRef().
*
* @throws TmlSidexException
*/
public long sidex_GetGroups(long sHandle) throws TmlSidexException{
long[] value = new long[1];
int iRet = NativeSidexGetGroups(sHandle, value);
if (SidexErr.SIDEX_SUCCESS != iRet){
value = null;
throw new TmlSidexException("sidex_GetGroups / Error "+Integer.toString(iRet), iRet);
}
long lRet = value[0];
value = null;
return lRet;
}
/**
* @brief get a list of key names in a group
*
* @param sHandle SIDEX document handle (SIDEX_HANDLE)
* @param sGroup name of the group
*
* @return SIDEX variant List value. The list contains all key names of the sGroup of the SIDEX document
* and must be released by sidex_Variant_DecRef().
*
* @throws TmlSidexException
*/
public long sidex_GetKeys(long sHandle, String sGroup) throws TmlSidexException{
long[] value = new long[1];
int iRet = NativeSidexGetKeys(sHandle, sGroup, value);
if (SidexErr.SIDEX_SUCCESS != iRet){
value = null;
throw new TmlSidexException("sidex_GetKeys / Error "+Integer.toString(iRet), iRet);
}
long lRet = value[0];
value = null;
return lRet;
}
/**
* @brief check if a group exists
*
* @param sHandle SIDEX document handle (SIDEX_HANDLE)
* @param sGroup name of the group
*
* @return true if group exists
*/
public boolean sidex_HasGroup(long sHandle, String sGroup){
boolean bRet = NativeSidexHasGroup(sHandle, sGroup);
return bRet;
}
/**
* @brief check if a key exists in a group
*
* @param sHandle SIDEX document handle (SIDEX_HANDLE)
* @param sGroup name of the group
* @param sKey name of the key
*
* @return true if the key exists in the group
*/
public boolean sidex_HasKey(long sHandle, String sGroup, String sKey){
boolean bRet = NativeSidexHasKey(sHandle, sGroup, sKey);
return bRet;
}
/* @} */
////////////////////////////////////////////////
//SIDEX document / Read/Write values
/**
* \addtogroup sdxDocRWValues
* @{
*/
/**
* @brief get the number of bytes of a binary value in a SIDEX document
*
* @param sHandle SIDEX document handle (SIDEX_HANDLE)
* @param sGroup name of the group
* @param sKey name of the key
*
* @return the byte count
*
* @throws TmlSidexException
*/
public int sidex_Binary_Length(long sHandle, String sGroup, String sKey) throws TmlSidexException{
int[] iStrLength = new int[1];
int iRet = NativeSidexBinaryLength(sHandle, sGroup, sKey, iStrLength);
if (SidexErr.SIDEX_SUCCESS != iRet){
iStrLength = null;
throw new TmlSidexException("sidex_Binary_Length / Error "+Integer.toString(iRet), iRet);
}
int iLength = iStrLength[0];
iStrLength = null;
return iLength;
}
/**
* @brief get a binary value from a SIDEX document
*
* @param sHandle SIDEX document handle (SIDEX_HANDLE)
* @param sGroup name of the group
* @param sKey name of the key
* @param iLength array of size 1 - returns the byte count
*
* @return binary data
*
* @throws TmlSidexException
*/
public byte[] sidex_Binary_Read(long sHandle, String sGroup, String sKey,int[] iLength) throws TmlSidexException{
int iBinLength;
iBinLength = sidex_Binary_Length(sHandle, sGroup, sKey);
ByteBuffer bStr = ByteBuffer.allocateDirect (iBinLength);
int iRet = NativeSidexBinaryRead(sHandle, sGroup, sKey, bStr, iLength);
if (SidexErr.SIDEX_SUCCESS != iRet){
throw new TmlSidexException("sidex_Binary_Read / Error "+Integer.toString(iRet), iRet);
}
byte[] bArray = new byte[iLength[0]];
for (int i = 0; i < iLength[0]; ++i){
bArray[i] = bStr.get(i);
}
bStr = null;
return bArray;
}
/**
* @brief write a binary value to a SIDEX document
*
* @param sHandle SIDEX document handle (SIDEX_HANDLE)
* @param sGroup name of the group
* @param sKey name of the key
* @param value byte array of binary data to write
* @param iSize length of binary data
*
* @throws TmlSidexException
*/
public void sidex_Binary_Write(long sHandle, String sGroup, String sKey, byte[] value, int iSize) throws TmlSidexException{
int iRet = NativeSidexBinaryWrite(sHandle, sGroup, sKey, value, iSize);
if (SidexErr.SIDEX_SUCCESS != iRet){
throw new TmlSidexException("sidex_Binary_Write / Error "+Integer.toString(iRet), iRet);
}
}
/**
* @brief get a boolean value from a SIDEX document
*
* @param sHandle SIDEX document handle (SIDEX_HANDLE)
* @param sGroup name of the group
* @param sKey name of the key
*
* @return boolean value
*
* @throws TmlSidexException
*/
public boolean sidex_Boolean_Read(long sHandle, String sGroup, String sKey) throws TmlSidexException{
boolean[] value = new boolean[1];
int iRet = NativeSidexBooleanRead(sHandle, sGroup, sKey, value);
if (SidexErr.SIDEX_SUCCESS != iRet){
value = null;
throw new TmlSidexException("sidex_Boolean_Read / Error "+Integer.toString(iRet), iRet);
}
boolean bValue = value[0];
value = null;
return bValue;
}
/**
* @brief write a boolean value to a SIDEX document
*
* @param sHandle SIDEX document handle (SIDEX_HANDLE)
* @param sGroup name of the group
* @param sKey name of the key
* @param value boolean data to write
*
* @throws TmlSidexException
*/
public void sidex_Boolean_Write(long sHandle, String sGroup, String sKey, boolean value) throws TmlSidexException{
int iRet = NativeSidexBooleanWrite(sHandle, sGroup, sKey, value);
if (SidexErr.SIDEX_SUCCESS != iRet){
throw new TmlSidexException("sidex_Boolean_Write / Error "+Integer.toString(iRet), iRet);
}
}
/**
* @brief get a datetime value from a SIDEX document
*
* @param sHandle SIDEX document handle (SIDEX_HANDLE)
* @param sGroup name of the group
* @param sKey name of the key
*
* @return SIDEX_VARIANT handle
*
* @throws TmlSidexException
*/
public long sidex_DateTime_Read(long sHandle, String sGroup, String sKey) throws TmlSidexException{
long[] value = new long[1];
int iRet = NativeSidexDateTimeRead(sHandle, sGroup, sKey, value);
if (SidexErr.SIDEX_SUCCESS != iRet){
value = null;
throw new TmlSidexException("sidex_DateTime_Read / Error "+Integer.toString(iRet), iRet);
}
long lRet = value[0];
value = null;
return lRet;
}
/**
* @brief write a dateTime value to a SIDEX document
*
* @param sHandle SIDEX document handle (SIDEX_HANDLE)
* @param sGroup name of the group
* @param sKey name of the key
* @param value SIDEX_VARIANT handle of dateTime value
*
* @throws TmlSidexException
*/
public void sidex_DateTime_Write(long sHandle, String sGroup, String sKey,long value) throws TmlSidexException{
int iRet = NativeSidexDateTimeWrite(sHandle, sGroup, sKey,value);
if (SidexErr.SIDEX_SUCCESS != iRet){
throw new TmlSidexException("sidex_DateTime_Write / Error "+Integer.toString(iRet), iRet);
}
}
/**
* @brief get a dictionary value from a SIDEX document
*
* @param sHandle SIDEX document handle (SIDEX_HANDLE)
* @param sGroup name of the group
* @param sKey name of the key
*
* @return SIDEX_VARIANT handle
*
* @throws TmlSidexException
*/
public long sidex_Dict_Read(long sHandle, String sGroup, String sKey) throws TmlSidexException{
long[] value = new long[1];
int iRet = NativeSidexDictRead(sHandle, sGroup, sKey, value);
if (SidexErr.SIDEX_SUCCESS != iRet){
value = null;
throw new TmlSidexException("sidex_Dict_Read / Error "+Integer.toString(iRet), iRet);
}
long lRet = value[0];
value = null;
return lRet;
}
/**
* @brief write a dictionary value to a SIDEX document
*
* @param sHandle SIDEX document handle (SIDEX_HANDLE)
* @param sGroup name of the group
* @param sKey name of the key
* @param value SIDEX_VARIANT handle of dictionary value
*
* @throws TmlSidexException
*/
public void sidex_Dict_Write(long sHandle, String sGroup, String sKey,long value) throws TmlSidexException{
int iRet = NativeSidexDictWrite(sHandle, sGroup, sKey,value);
if (SidexErr.SIDEX_SUCCESS != iRet){
throw new TmlSidexException("sidex_Dict_Write / Error "+Integer.toString(iRet), iRet);
}
}
/**
* @brief get a float value from a SIDEX document
*
* @param sHandle SIDEX document handle (SIDEX_HANDLE)
* @param sGroup name of the group
* @param sKey name of the key
*
* @return float value
*
* @throws TmlSidexException
*/
public double sidex_Float_Read(long sHandle, String sGroup, String sKey) throws TmlSidexException{
double[] value = new double[1];
int iRet = NativeSidexFloatRead(sHandle, sGroup, sKey, value);
if (SidexErr.SIDEX_SUCCESS != iRet){
value = null;
throw new TmlSidexException("sidex_Float_Read / Error "+Integer.toString(iRet), iRet);
}
double dRet = value[0];
value = null;
return dRet;
}
/**
* @brief write a float value to a SIDEX document
*
* @param sHandle SIDEX document handle (SIDEX_HANDLE)
* @param sGroup name of the group
* @param sKey name of the key
* @param value float value
*
* @throws TmlSidexException
*/
public void sidex_Float_Write(long sHandle, String sGroup, String sKey, double value) throws TmlSidexException{
int iRet = NativeSidexFloatWrite(sHandle, sGroup, sKey,value);
if (SidexErr.SIDEX_SUCCESS != iRet){
throw new TmlSidexException("sidex_Float_Write / Error "+Integer.toString(iRet), iRet);
}
}
/**
* @brief get an integer value from a SIDEX document
*
* @param sHandle SIDEX document handle (SIDEX_HANDLE)
* @param sGroup name of the group
* @param sKey name of the key
*
* @return integer value
*
* @throws TmlSidexException
*/
public long sidex_Integer_Read(long sHandle, String sGroup, String sKey) throws TmlSidexException{
long[] value = new long[1];
int iRet = NativeSidexIntegerRead(sHandle, sGroup, sKey, value);
if (SidexErr.SIDEX_SUCCESS != iRet){
value = null;
throw new TmlSidexException("sidex_Integer_Read / Error "+Integer.toString(iRet), iRet);
}
long lRet = value[0];
value = null;
return lRet;
}
/**
* @brief write an integer value to a SIDEX document
*
* @param sHandle SIDEX document handle (SIDEX_HANDLE)
* @param sGroup name of the group
* @param sKey name of the key
* @param value integer value
*
* @throws TmlSidexException
*/
public void sidex_Integer_Write(long sHandle, String sGroup, String sKey,long value) throws TmlSidexException{
int iRet = NativeSidexIntegerWrite(sHandle, sGroup, sKey,value);
if (SidexErr.SIDEX_SUCCESS != iRet){
throw new TmlSidexException("sidex_Integer_Write / Error "+Integer.toString(iRet), iRet);
}
}
/**
* @brief get a list value from a SIDEX document
*
* @param sHandle SIDEX document handle (SIDEX_HANDLE)
* @param sGroup name of the group
* @param sKey name of the key
*
* @return SIDEX_VARIANT handle
*
* @throws TmlSidexException
*/
public long sidex_List_Read(long sHandle, String sGroup, String sKey) throws TmlSidexException{
long[] value = new long[1];
int iRet = NativeSidexListRead(sHandle, sGroup, sKey, value);
if (SidexErr.SIDEX_SUCCESS != iRet){
value = null;
throw new TmlSidexException("sidex_List_Read / Error "+Integer.toString(iRet), iRet);
}
long lRet = value[0];
value = null;
return lRet;
}
/**
* @brief write a list value to a SIDEX document
*
* @param sHandle SIDEX document handle (SIDEX_HANDLE)
* @param sGroup name of the group
* @param sKey name of the key
* @param value SIDEX_VARIANT handle of list value
*
* @throws TmlSidexException
*/
public void sidex_List_Write(long sHandle, String sGroup, String sKey,long value) throws TmlSidexException{
int iRet = NativeSidexListWrite(sHandle, sGroup, sKey,value);
if (SidexErr.SIDEX_SUCCESS != iRet){
throw new TmlSidexException("sidex_List_Write / Error "+Integer.toString(iRet), iRet);
}