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 | package Torello.JSON;
import Torello.Java.Function.ToShortFunction;
import Torello.Java.Function.ToByteFunction;
import Torello.Java.Function.ToFloatFunction;
import java.util.function.ToIntFunction;
import java.util.function.ToLongFunction;
import java.util.function.ToDoubleFunction;
import java.util.function.Predicate;
import Torello.JavaDoc.Annotations.LinkJavaSource;
import Torello.JavaDoc.Annotations.StaticFunctional;
import Torello.JavaDoc.Annotations.JDHeaderBackgroundImg;
import Torello.JavaDoc.Annotations.IntoHTMLTable;
// import Torello.JavaDoc.Annotations.IntoHTMLTable.Background;
import static Torello.JavaDoc.Annotations.IntoHTMLTable.Background.*;
import static Torello.JSON.JFlag.NOT_ALLOWED_RET_NULL_MASKS;
import java.util.function.Predicate;
import javax.json.Json;
import javax.json.JsonArray;
/**
* Utilities for parsing Json Array's and sending the parsed values into a Java-Array
*
* <EMBED CLASS='external-html' DATA-FILE-ID=ALL_CLASSES_NOTE>
* <EMBED CLASS='external-html' DATA-FILE-ID=RJA_INTO_PRIM_ARR>
*
* <BR /><HR><BR />
* <EMBED CLASS='external-html' DATA-FILE-ID=RJ_ARR_PRIM_ARR>
* <EMBED CLASS='external-html' DATA-FILE-ID=RJA_PT_PRIM_ARR>
*
* @see Json
* @see JsonArray
*/
@StaticFunctional
@JDHeaderBackgroundImg(EmbedTagFileID="RJA_JDHBI_PRIM_ARR")
public class RJArrIntoPrimArray
{
private RJArrIntoPrimArray() {}
/**
* <EMBED CLASS=defs DATA-TYPE=short DATA-INTERIM=Short>
* <EMBED CLASS='external-html' DATA-FILE-ID=RJ_ARR_PRIM_ARR_M_DOC>
*/
@IntoHTMLTable(background=BlueDither, title="JsonArray of Short")
@LinkJavaSource(handle="GENERATE_1DARRAY", name="boxedStreamToPrimitiveArray")
public static short[] shortArr(
final JsonArray ja,
final short defaultValue,
final int FLAGS,
final ToShortFunction<String> optionalUserParser
)
{
final short[] retArr = new short[ja.size()];
return GENERATE_1DARRAY.boxedStreamToPrimitiveArray(
RJArrIntoBoxedStream.shortArr(
ja,
defaultValue,
FLAGS & NOT_ALLOWED_RET_NULL_MASKS,
(optionalUserParser == null) ? null : optionalUserParser::applyAsShort
),
ja,
short.class,
(Short s, int i) -> retArr[i] = s.shortValue(),
retArr
);
}
/**
* <EMBED CLASS=defs DATA-TYPE=byte DATA-INTERIM=Byte>
* <EMBED CLASS='external-html' DATA-FILE-ID=RJ_ARR_PRIM_ARR_M_DOC>
*/
@IntoHTMLTable(background=GreenDither, title="JsonArray of Bytes")
@LinkJavaSource(handle="GENERATE_1DARRAY", name="boxedStreamToPrimitiveArray")
public static byte[] byteArr(
final JsonArray ja,
final byte defaultValue,
final int FLAGS,
final ToByteFunction<String> optionalUserParser
)
{
final byte[] retArr = new byte[ja.size()];
return GENERATE_1DARRAY.boxedStreamToPrimitiveArray(
RJArrIntoBoxedStream.byteArr(
ja,
defaultValue,
FLAGS & NOT_ALLOWED_RET_NULL_MASKS,
(optionalUserParser == null) ? null : optionalUserParser::applyAsByte
),
ja,
byte.class,
(Byte s, int i) -> retArr[i] = s.byteValue(),
retArr
);
}
/**
* <EMBED CLASS=defs DATA-TYPE=float DATA-INTERIM=Float>
* <EMBED CLASS='external-html' DATA-FILE-ID=RJ_ARR_PRIM_ARR_M_DOC>
*/
@IntoHTMLTable(background=BlueDither, title="JsonArray of Floats")
@LinkJavaSource(handle="GENERATE_1DARRAY", name="boxedStreamToPrimitiveArray")
public static float[] floatArr(
final JsonArray ja,
final float defaultValue,
final int FLAGS,
final ToFloatFunction<String> optionalUserParser
)
{
final float[] retArr = new float[ja.size()];
return GENERATE_1DARRAY.boxedStreamToPrimitiveArray(
RJArrIntoBoxedStream.floatArr(
ja,
defaultValue,
FLAGS & NOT_ALLOWED_RET_NULL_MASKS,
(optionalUserParser == null) ? null : optionalUserParser::applyAsFloat
),
ja,
float.class,
(Float s, int i) -> retArr[i] = s.floatValue(),
retArr
);
}
/**
* <EMBED CLASS=defs DATA-TYPE=boolean DATA-INTERIM=Boolean>
* <EMBED CLASS='external-html' DATA-FILE-ID=RJ_ARR_PRIM_ARR_M_DOC>
*/
@IntoHTMLTable(background=GreenDither, title="JsonArray of Booleans")
@LinkJavaSource(handle="GENERATE_1DARRAY", name="boxedStreamToPrimitiveArray")
public static boolean[] booleanArr(
final JsonArray ja,
final boolean defaultValue,
final int FLAGS,
final Predicate<String> optionalUserParser
)
{
final boolean[] retArr = new boolean[ja.size()];
return GENERATE_1DARRAY.boxedStreamToPrimitiveArray(
RJArrIntoBoxedStream.booleanArr(
ja,
defaultValue,
FLAGS & NOT_ALLOWED_RET_NULL_MASKS,
(optionalUserParser == null) ? null : optionalUserParser::test
),
ja,
boolean.class,
(Boolean s, int i) -> retArr[i] = s.booleanValue(),
retArr
);
}
/**
* <BR>Invokes: {@link RJArrIntoPrimStream#intArr(JsonArray, int, int, ToIntFunction)}
* <BR>And-Then: {@code toArray()}, as explained in the comments at the top of this class
*/
@IntoHTMLTable(background=BlueDither, title="JsonArray of Integers")
public static int[] intArr(
final JsonArray ja,
final int defaultValue,
final int FLAGS,
final ToIntFunction<String> optionalUserParser
)
{
return RJArrIntoPrimStream
.intArr(ja, defaultValue, FLAGS, optionalUserParser)
.toArray();
}
/**
* <BR>Invokes: {@link RJArrIntoPrimStream#longArr(JsonArray, long, int, ToLongFunction)}
* <BR>And-Then: {@code toArray()}, as explained in the comments at the top of this class
*/
@IntoHTMLTable(background=GreenDither, title="JsonArray of Longs")
public static long[] longArr(
final JsonArray ja,
final long defaultValue,
final int FLAGS,
final ToLongFunction<String> optionalUserParser
)
{
return RJArrIntoPrimStream
.longArr(ja, defaultValue, FLAGS, optionalUserParser)
.toArray();
}
/**
* <BR>Invokes:
* {@link RJArrIntoPrimStream#doubleArr(JsonArray, double, int, ToDoubleFunction)}
* <BR>And-Then: {@code toArray()}, as explained in the comments at the top of this class
*/
@IntoHTMLTable(background=BlueDither, title="JsonArray of Doubles")
public static double[] doubleArr(
final JsonArray ja,
final double defaultValue,
final int FLAGS,
final ToDoubleFunction<String> optionalUserParser
)
{
return RJArrIntoPrimStream
.doubleArr(ja, defaultValue, FLAGS, optionalUserParser)
.toArray();
}
}
|