@@ -27,7 +27,7 @@ public class OsonDocumentReader implements JsonDocumentReader {
27
27
final private OracleJsonParser parser ;
28
28
private String currentKeyName ;
29
29
private Object currentValue ;
30
- private boolean currentValueIsAString ; // avoid later introspection
30
+
31
31
/**
32
32
* Creates a new <code>OsonDocumentReader</code> on top of a <code>OracleJsonParser</code>
33
33
* @param parser the parser
@@ -48,7 +48,6 @@ public JsonDocumentItemType next() {
48
48
OracleJsonParser .Event evt = this .parser .next ();
49
49
currentKeyName = null ;
50
50
currentValue = null ;
51
- currentValueIsAString = false ;
52
51
switch (evt ) {
53
52
case OracleJsonParser .Event .START_OBJECT :
54
53
return JsonDocumentItemType .OBJECT_START ;
@@ -76,7 +75,6 @@ public JsonDocumentItemType next() {
76
75
return JsonDocumentItemType .VALUE ;
77
76
case OracleJsonParser .Event .VALUE_STRING :
78
77
currentValue = this .parser .getString ();
79
- currentValueIsAString = true ;
80
78
return JsonDocumentItemType .VALUE ;
81
79
case OracleJsonParser .Event .VALUE_TRUE :
82
80
currentValue = Boolean .TRUE ;
@@ -128,51 +126,52 @@ public BigInteger getBigIntegerValue() {
128
126
129
127
@ Override
130
128
public double getDoubleValue () {
131
- if (currentValueIsAString ) return Double .parseDouble ( (String )currentValue );
129
+ if (currentValue instanceof String )
130
+ return Double .parseDouble ( (String )currentValue );
132
131
return ((Double )currentValue ).doubleValue ();
133
132
}
134
133
135
134
@ Override
136
135
public float getFloatValue () {
137
- if (currentValueIsAString ) return Float .parseFloat ( (String )currentValue );
136
+ if (currentValue instanceof String ) return Float .parseFloat ( (String )currentValue );
138
137
return ((Float )currentValue ).floatValue ();
139
138
}
140
139
141
140
@ Override
142
141
public long getLongValue () {
143
- if (currentValueIsAString ) return Long .parseLong ( (String )currentValue );
142
+ if (currentValue instanceof String ) return Long .parseLong ( (String )currentValue );
144
143
return ((BigDecimal )currentValue ).longValue ();
145
144
}
146
145
147
146
@ Override
148
147
public int getIntegerValue () {
149
- if (currentValueIsAString ) return Integer .parseInt ( (String )currentValue );
148
+ if (currentValue instanceof String ) return Integer .parseInt ( (String )currentValue );
150
149
return ((BigDecimal )currentValue ).intValue ();
151
150
}
152
151
153
152
@ Override
154
153
public short getShortValue () {
155
- if (currentValueIsAString ) return Short .parseShort ( (String )currentValue );
154
+ if (currentValue instanceof String ) return Short .parseShort ( (String )currentValue );
156
155
return ((BigDecimal )currentValue ).shortValue ();
157
156
}
158
157
159
158
@ Override
160
159
public byte getByteValue () {
161
- if (currentValueIsAString ) return Byte .parseByte ( (String )currentValue );
160
+ if (currentValue instanceof String ) return Byte .parseByte ( (String )currentValue );
162
161
return ((Byte )currentValue ).byteValue ();
163
162
}
164
163
165
164
@ Override
166
165
public boolean getBooleanValue () {
167
- if (currentValueIsAString ) return BooleanJavaType .INSTANCE .fromEncodedString ((String )currentValue );
166
+ if (currentValue instanceof String ) return BooleanJavaType .INSTANCE .fromEncodedString ((String )currentValue );
168
167
return ((Boolean )currentValue ).booleanValue ();
169
168
}
170
169
171
170
172
171
173
172
@ Override
174
173
public <T > T getValue (JavaType <T > javaType , WrapperOptions options ) {
175
- if ( currentValueIsAString ) {
174
+ if ( currentValue instanceof String ) {
176
175
if (javaType .equals (PrimitiveByteArrayJavaType .INSTANCE )) {
177
176
// be sure that we have only allowed characters.
178
177
// that may happen for string representation of UUID (i.e 53886a8a-7082-4879-b430-25cb94415be8) for instance
@@ -183,7 +182,7 @@ public <T> T getValue(JavaType<T> javaType, WrapperOptions options) {
183
182
184
183
Object theOneToBeUsed = currentValue ;
185
184
// handle special cases for Date things
186
- if ( currentValue . getClass () == LocalDateTime . class ) {
185
+ if ( currentValue instanceof LocalDateTime ) {
187
186
if ( java .sql .Date .class .isAssignableFrom ( javaType .getJavaTypeClass () ) ) {
188
187
theOneToBeUsed = Date .valueOf ( ((LocalDateTime )currentValue ).toLocalDate () );
189
188
}
0 commit comments