@@ -200,7 +200,7 @@ public boolean isObject() {
200
200
* field. Null otherwise.
201
201
*/
202
202
@ Override
203
- public JsonNode get (String fieldName ) { return null ; }
203
+ public JsonNode get (String propertyName ) { return null ; }
204
204
205
205
/**
206
206
* Method for accessing value of the specified element of
@@ -259,7 +259,7 @@ public boolean isObject() {
259
259
*/
260
260
261
261
@ Override
262
- public abstract JsonNode path (String fieldName );
262
+ public abstract JsonNode path (String propertyName );
263
263
264
264
/**
265
265
* This method is similar to {@link #get(int)}, except
@@ -424,13 +424,21 @@ public final boolean isNumber() {
424
424
public boolean isBigInteger () { return false ; }
425
425
426
426
/**
427
- * Method that checks whether this node represents basic JSON String
427
+ * Method that checks whether this node represents JSON String
428
428
* value.
429
429
*/
430
- public final boolean isTextual () {
430
+ public final boolean isString () {
431
431
return getNodeType () == JsonNodeType .STRING ;
432
432
}
433
433
434
+ /**
435
+ * @deprecated Use {@link #isString} instead.
436
+ */
437
+ @ Deprecated // since 3.0
438
+ public boolean isTextual () {
439
+ return isString ();
440
+ }
441
+
434
442
/**
435
443
* Method that can be used to check if this node was created from
436
444
* JSON boolean value (literals "true" and "false").
@@ -451,7 +459,7 @@ public final boolean isNull() {
451
459
/**
452
460
* Method that can be used to check if this node represents
453
461
* binary data (Base64 encoded). Although this will be externally
454
- * written as JSON String value, {@link #isTextual } will
462
+ * written as JSON String value, {@link #isString } will
455
463
* return false if this method returns true.
456
464
*
457
465
* @return True if this node represents base64 encoded binary data
@@ -522,19 +530,21 @@ public boolean canConvertToExactIntegral() {
522
530
/**
523
531
* Method to use for accessing String values.
524
532
* Does <b>NOT</b> do any conversions for non-String value nodes;
525
- * for non-String values (ones for which {@link #isTextual } returns
533
+ * for non-String values (ones for which {@link #isString } returns
526
534
* false) null will be returned.
527
535
* For String values, null is never returned (but empty Strings may be)
536
+ *<p>
537
+ * NOTE: in Jackson 2.x, was {@code textValue()}.
528
538
*
529
- * @return Textual value this node contains, iff it is a textual
530
- * JSON node (comes from JSON String value entry)
539
+ * @return String value this node contains, iff node is created from
540
+ * a String value.
531
541
*/
532
- public String textValue () { return null ; }
542
+ public String stringValue () { return null ; }
533
543
534
544
/**
535
545
* Method to use for accessing binary content of binary nodes (nodes
536
- * for which {@link #isBinary} returns true); or for Text Nodes
537
- * (ones for which {@link #textValue } returns non-null value),
546
+ * for which {@link #isBinary} returns true); or for String Nodes
547
+ * (ones for which {@link #stringValue } returns non-null value),
538
548
* to read decoded base64 data.
539
549
* For other types of nodes, returns null.
540
550
*
@@ -652,11 +662,15 @@ public byte[] binaryValue() {
652
662
653
663
/**
654
664
* Method that will return a valid String representation of
655
- * the container value, if the node is a value node
665
+ * the contained value, if the node is a value node
656
666
* (method {@link #isValueNode} returns true),
657
667
* otherwise empty String.
668
+ *<p>
669
+ * NOTE: this is NOT same as {@link #toString()} in that result is
670
+ * <p>NOT VALID ENCODED JSON</p> for all nodes (but is for some, like
671
+ * {@code NumberNode}s and {@code BooleanNode}s).
658
672
*/
659
- public abstract String asText ();
673
+ public abstract String asString ();
660
674
661
675
/**
662
676
* Returns the text value of this node or the provided {@code defaultValue} if this node
@@ -666,11 +680,27 @@ public byte[] binaryValue() {
666
680
* @param defaultValue The default value to return if this node's text value is absent.
667
681
* @return The text value of this node, or {@code defaultValue} if the text value is absent.
668
682
*/
669
- public String asText (String defaultValue ) {
670
- String str = asText ();
683
+ public String asString (String defaultValue ) {
684
+ String str = asString ();
671
685
return (str == null ) ? defaultValue : str ;
672
686
}
673
687
688
+ /**
689
+ * @deprecated Use {@link #asString()} instead.
690
+ */
691
+ @ Deprecated // since 3.0
692
+ public final String asText () {
693
+ return asString ();
694
+ }
695
+
696
+ /**
697
+ * @deprecated Use {@link #asString(String)} instead.
698
+ */
699
+ @ Deprecated // since 3.0
700
+ public String asText (String defaultValue ) {
701
+ return asString (defaultValue );
702
+ }
703
+
674
704
/**
675
705
* Method that will try to convert value of this node to a Java <b>int</b>.
676
706
* Numbers are coerced using default Java rules; booleans convert to 0 (false)
@@ -832,10 +862,10 @@ public <T extends JsonNode> T requireNonNull() {
832
862
/**
833
863
* Method is functionally equivalent to
834
864
*{@code
835
- * path(fieldName ).required()
865
+ * path(propertyName ).required()
836
866
*}
837
867
* and can be used to check that this node is an {@code ObjectNode} (that is, represents
838
- * JSON Object value) and has value for specified property with key {@code fieldName }
868
+ * JSON Object value) and has value for specified property with key {@code propertyName }
839
869
* (but note that value may be explicit JSON null value).
840
870
* If this node is Object Node and has value for specified property, matching value
841
871
* is returned; otherwise {@link IllegalArgumentException} is thrown.
@@ -943,20 +973,20 @@ public final JsonNode requiredAt(final JsonPointer path) {
943
973
*<p>
944
974
* This method is equivalent to:
945
975
*<pre>
946
- * node.get(fieldName ) != null
976
+ * node.get(propertyName ) != null
947
977
*</pre>
948
978
* (since return value of get() is node, not value node contains)
949
979
*<p>
950
980
* NOTE: when explicit <code>null</code> values are added, this
951
981
* method will return <code>true</code> for such properties.
952
982
*
953
- * @param fieldName Name of element to check
983
+ * @param propertyName Name of element to check
954
984
*
955
985
* @return True if this node is a JSON Object node, and has a property
956
986
* entry with specified name (with any value, including null value)
957
987
*/
958
- public boolean has (String fieldName ) {
959
- return get (fieldName ) != null ;
988
+ public boolean has (String propertyName ) {
989
+ return get (propertyName ) != null ;
960
990
}
961
991
962
992
/**
@@ -991,13 +1021,11 @@ public boolean has(int index) {
991
1021
*<p>
992
1022
* This method is functionally equivalent to:
993
1023
*<pre>
994
- * node.get(fieldName ) != null && !node.get(fieldName ).isNull()
1024
+ * node.get(propertyName ) != null && !node.get(propertyName ).isNull()
995
1025
*</pre>
996
- *
997
- * @since 2.1
998
1026
*/
999
- public boolean hasNonNull (String fieldName ) {
1000
- JsonNode n = get (fieldName );
1027
+ public boolean hasNonNull (String propertyName ) {
1028
+ JsonNode n = get (propertyName );
1001
1029
return (n != null ) && !n .isNull ();
1002
1030
}
1003
1031
@@ -1009,8 +1037,6 @@ public boolean hasNonNull(String fieldName) {
1009
1037
*<pre>
1010
1038
* node.get(index) != null && !node.get(index).isNull()
1011
1039
*</pre>
1012
- *
1013
- * @since 2.1
1014
1040
*/
1015
1041
public boolean hasNonNull (int index ) {
1016
1042
JsonNode n = get (index );
@@ -1135,11 +1161,11 @@ public void forEachEntry(BiConsumer<? super String, ? super JsonNode> action) {
1135
1161
* Note that traversal is done in document order (that is, order in which
1136
1162
* nodes are iterated if using {@link JsonNode#values()})
1137
1163
*
1138
- * @param fieldName Name of field to look for
1164
+ * @param propertyName Name of field to look for
1139
1165
*
1140
1166
* @return Value of first matching node found, if any; null if none
1141
1167
*/
1142
- public abstract JsonNode findValue (String fieldName );
1168
+ public abstract JsonNode findValue (String propertyName );
1143
1169
1144
1170
/**
1145
1171
* Method for finding JSON Object fields with specified name -- both immediate
@@ -1150,11 +1176,11 @@ public void forEachEntry(BiConsumer<? super String, ? super JsonNode> action) {
1150
1176
* If no matching fields are found in this node or its descendants, returns
1151
1177
* an empty List.
1152
1178
*
1153
- * @param fieldName Name of field to look for
1179
+ * @param propertyName Name of field to look for
1154
1180
*/
1155
- public final List <JsonNode > findValues (String fieldName )
1181
+ public final List <JsonNode > findValues (String propertyName )
1156
1182
{
1157
- List <JsonNode > result = findValues (fieldName , null );
1183
+ List <JsonNode > result = findValues (propertyName , null );
1158
1184
if (result == null ) {
1159
1185
return Collections .emptyList ();
1160
1186
}
@@ -1165,9 +1191,9 @@ public final List<JsonNode> findValues(String fieldName)
1165
1191
* Similar to {@link #findValues}, but will additionally convert
1166
1192
* values into Strings, calling {@link #asText}.
1167
1193
*/
1168
- public final List <String > findValuesAsText (String fieldName )
1194
+ public final List <String > findValuesAsString (String propertyName )
1169
1195
{
1170
- List <String > result = findValuesAsText ( fieldName , null );
1196
+ List <String > result = findValuesAsString ( propertyName , null );
1171
1197
if (result == null ) {
1172
1198
return Collections .emptyList ();
1173
1199
}
@@ -1181,45 +1207,45 @@ public final List<String> findValuesAsText(String fieldName)
1181
1207
* returns true; and all value access methods return empty or
1182
1208
* missing value.
1183
1209
*
1184
- * @param fieldName Name of field to look for
1210
+ * @param propertyName Name of field to look for
1185
1211
*
1186
1212
* @return Value of first matching node found; or if not found, a
1187
1213
* "missing node" (non-null instance that has no value)
1188
1214
*/
1189
- public abstract JsonNode findPath (String fieldName );
1215
+ public abstract JsonNode findPath (String propertyName );
1190
1216
1191
1217
/**
1192
1218
* Method for finding a JSON Object that contains specified field,
1193
1219
* within this node or its descendants.
1194
1220
* If no matching field is found in this node or its descendants, returns null.
1195
1221
*
1196
- * @param fieldName Name of field to look for
1222
+ * @param propertyName Name of field to look for
1197
1223
*
1198
1224
* @return Value of first matching node found, if any; null if none
1199
1225
*/
1200
- public abstract JsonNode findParent (String fieldName );
1226
+ public abstract JsonNode findParent (String propertyName );
1201
1227
1202
1228
/**
1203
1229
* Method for finding a JSON Object that contains specified field,
1204
1230
* within this node or its descendants.
1205
1231
* If no matching field is found in this node or its descendants, returns null.
1206
1232
*
1207
- * @param fieldName Name of field to look for
1233
+ * @param propertyName Name of field to look for
1208
1234
*
1209
1235
* @return Value of first matching node found, if any; null if none
1210
1236
*/
1211
- public final List <JsonNode > findParents (String fieldName )
1237
+ public final List <JsonNode > findParents (String propertyName )
1212
1238
{
1213
- List <JsonNode > result = findParents (fieldName , null );
1239
+ List <JsonNode > result = findParents (propertyName , null );
1214
1240
if (result == null ) {
1215
1241
return Collections .emptyList ();
1216
1242
}
1217
1243
return result ;
1218
1244
}
1219
1245
1220
- public abstract List <JsonNode > findValues (String fieldName , List <JsonNode > foundSoFar );
1221
- public abstract List <String > findValuesAsText (String fieldName , List <String > foundSoFar );
1222
- public abstract List <JsonNode > findParents (String fieldName , List <JsonNode > foundSoFar );
1246
+ public abstract List <JsonNode > findValues (String propertyName , List <JsonNode > foundSoFar );
1247
+ public abstract List <String > findValuesAsString (String propertyName , List <String > foundSoFar );
1248
+ public abstract List <JsonNode > findParents (String propertyName , List <JsonNode > foundSoFar );
1223
1249
1224
1250
/*
1225
1251
/**********************************************************************
0 commit comments