Skip to content

Commit

Permalink
Changes wrt [core#1378]
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jan 3, 2025
1 parent ad973d5 commit d68a8e8
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 44 deletions.
24 changes: 12 additions & 12 deletions src/main/java/tools/jackson/dataformat/xml/deser/FromXmlParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ public String nextName() throws JacksonException {
* String collections.
*/
@Override
public String nextTextValue() throws JacksonException
public String nextStringValue() throws JacksonException
{
_binaryValue = null;
if (_nextToken != null) {
Expand Down Expand Up @@ -840,7 +840,7 @@ private void _updateState(JsonToken t)
*/

@Override
public String getText() throws JacksonException
public String getString() throws JacksonException
{
if (_currToken == null) {
return null;
Expand All @@ -856,19 +856,19 @@ public String getText() throws JacksonException
}

@Override
public char[] getTextCharacters() throws JacksonException {
String text = getText();
public char[] getStringCharacters() throws JacksonException {
String text = getString();
return (text == null) ? null : text.toCharArray();
}

@Override
public int getTextLength() throws JacksonException {
String text = getText();
public int getStringLength() throws JacksonException {
String text = getString();
return (text == null) ? 0 : text.length();
}

@Override
public int getTextOffset() throws JacksonException {
public int getStringOffset() throws JacksonException {
return 0;
}

Expand All @@ -877,14 +877,14 @@ public int getTextOffset() throws JacksonException {
* we must coalesce things it cannot really be exposed.
*/
@Override
public boolean hasTextCharacters() {
public boolean hasStringCharacters() {
return false;
}

@Override
public int getText(Writer writer) throws JacksonException
public int getString(Writer writer) throws JacksonException
{
String str = getText();
String str = getString();
if (str == null) {
return 0;
}
Expand Down Expand Up @@ -931,7 +931,7 @@ public byte[] getBinaryValue(Base64Variant b64variant) throws JacksonException
protected byte[] _decodeBase64(Base64Variant b64variant) throws JacksonException
{
ByteArrayBuilder builder = _getByteArrayBuilder();
final String str = getText();
final String str = getString();
_decodeBase64(str, builder, b64variant);
return builder.toByteArray();
}
Expand Down Expand Up @@ -1088,7 +1088,7 @@ protected void _convertNumberToInt() throws JacksonException
// Let's verify it's lossless conversion by simple roundtrip
int result = (int) _numberLong;
if (((long) result) != _numberLong) {
_reportError("Numeric value ("+getText()+") out of range of int");
_reportError("Numeric value ("+getString()+") out of range of int");
}
_numberInt = result;
} else if ((_numTypesValid & NR_BIGINT) != 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public String extractScalarFromObject(JsonParser p, ValueDeserializer<?> deser,
JsonToken t = p.nextToken();
if (t == JsonToken.VALUE_STRING) {
if (propName.equals("")) {
text = p.getText();
text = p.getString();
}
} else {
p.skipChildren();
Expand Down
10 changes: 5 additions & 5 deletions src/test/java/tools/jackson/dataformat/xml/XmlTestBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,10 @@ protected void assertToken(JsonToken expToken, JsonParser jp)
protected String getAndVerifyText(JsonParser jp)
{
// Ok, let's verify other accessors
int actLen = jp.getTextLength();
char[] ch = jp.getTextCharacters();
String str2 = new String(ch, jp.getTextOffset(), actLen);
String str = jp.getText();
int actLen = jp.getStringLength();
char[] ch = jp.getStringCharacters();
String str2 = new String(ch, jp.getStringOffset(), actLen);
String str = jp.getString();

if (str.length() != actLen) {
fail("Internal problem (jp.token == "+jp.currentToken()+"): jp.getText().length() ['"+str+"'] == "+str.length()+"; jp.getTextLength() == "+actLen);
Expand All @@ -288,7 +288,7 @@ protected String getAndVerifyText(JsonParser jp)

protected void verifyFieldName(JsonParser p, String expName)
{
assertEquals(expName, p.getText());
assertEquals(expName, p.getString());
assertEquals(expName, p.currentName());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ public void testMixedContentBeforeElement442() throws Exception
assertEquals("", xp.currentName());

assertToken(JsonToken.VALUE_STRING, xp.nextToken());
assertEquals("text", xp.getText().trim());
assertEquals("text", xp.getString().trim());

assertToken(JsonToken.PROPERTY_NAME, xp.nextToken());
assertEquals("leaf", xp.currentName());
assertToken(JsonToken.VALUE_STRING, xp.nextToken());
assertEquals("stuff", xp.getText().trim());
assertEquals("stuff", xp.getString().trim());

assertToken(JsonToken.END_OBJECT, xp.nextToken());
assertToken(JsonToken.END_OBJECT, xp.nextToken());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ public void testXmlAttributesWithNextTextValue() throws Exception
assertToken(JsonToken.PROPERTY_NAME, xp.nextToken()); // <max>
assertEquals("max", xp.currentName());

assertEquals("7", xp.nextTextValue());
assertEquals("7", xp.nextStringValue());

assertToken(JsonToken.PROPERTY_NAME, xp.nextToken()); // <offset>
assertEquals("offset", xp.currentName());

assertEquals("offset", xp.getText());
assertEquals("offset", xp.getString());

assertEquals("9", xp.nextTextValue());
assertEquals("9", xp.nextStringValue());

assertEquals("9", xp.getText());
assertEquals("9", xp.getString());

assertToken(JsonToken.END_OBJECT, xp.nextToken()); // </data>
xp.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void testSimplest() throws Exception
assertEquals("leaf", p.currentName());
assertEquals(1, p.streamReadContext().getNestingDepth());
assertToken(JsonToken.VALUE_STRING, p.nextToken());
assertEquals("abc", p.getText());
assertEquals("abc", p.getString());
assertEquals(1, p.streamReadContext().getNestingDepth());
assertToken(JsonToken.END_OBJECT, p.nextToken());
assertEquals(0, p.streamReadContext().getNestingDepth());
Expand Down Expand Up @@ -71,7 +71,7 @@ public void testSimpleWithEmpty() throws Exception
assertToken(JsonToken.PROPERTY_NAME, p.nextToken());
assertEquals("leaf", p.currentName());
assertToken(JsonToken.VALUE_STRING, p.nextToken());
assertEquals("", p.getText());
assertEquals("", p.getString());
assertToken(JsonToken.END_OBJECT, p.nextToken());
assertNull(p.nextToken());
}
Expand All @@ -90,7 +90,7 @@ public void testRootScalar() throws Exception
assertToken(JsonToken.PROPERTY_NAME, p.nextToken());
assertEquals("", p.currentName());
assertToken(JsonToken.VALUE_STRING, p.nextToken());
assertEquals("value", p.getText());
assertEquals("value", p.getString());
assertToken(JsonToken.END_OBJECT, p.nextToken());
assertNull(p.nextToken());
// should be ok to call again tho
Expand All @@ -108,12 +108,12 @@ public void testRootMixed() throws Exception
assertToken(JsonToken.PROPERTY_NAME, p.nextToken());
assertEquals("", p.currentName());
assertToken(JsonToken.VALUE_STRING, p.nextToken());
assertEquals("value", p.getText());
assertEquals("value", p.getString());

assertToken(JsonToken.PROPERTY_NAME, p.nextToken());
assertEquals("child", p.currentName());
assertToken(JsonToken.VALUE_STRING, p.nextToken());
assertEquals("abc", p.getText());
assertEquals("abc", p.getString());

assertToken(JsonToken.END_OBJECT, p.nextToken());
assertNull(p.nextToken());
Expand Down Expand Up @@ -160,11 +160,11 @@ public void testRoundTripWithSample() throws Exception
assertToken(JsonToken.PROPERTY_NAME, p.nextToken()); // 'Width'
verifyFieldName(p, "Width");
assertToken(JsonToken.VALUE_STRING, p.nextToken());
assertEquals(String.valueOf(SAMPLE_SPEC_VALUE_WIDTH), p.getText());
assertEquals(String.valueOf(SAMPLE_SPEC_VALUE_WIDTH), p.getString());
assertToken(JsonToken.PROPERTY_NAME, p.nextToken()); // 'Height'
verifyFieldName(p, "Height");
assertToken(JsonToken.VALUE_STRING, p.nextToken());
assertEquals(String.valueOf(SAMPLE_SPEC_VALUE_HEIGHT), p.getText());
assertEquals(String.valueOf(SAMPLE_SPEC_VALUE_HEIGHT), p.getString());
assertToken(JsonToken.PROPERTY_NAME, p.nextToken()); // 'Title'
verifyFieldName(p, "Title");
assertToken(JsonToken.VALUE_STRING, p.nextToken());
Expand All @@ -179,7 +179,7 @@ public void testRoundTripWithSample() throws Exception
assertToken(JsonToken.PROPERTY_NAME, p.nextToken()); // 'Height'
verifyFieldName(p, "Height");
assertToken(JsonToken.VALUE_STRING, p.nextToken());
assertEquals(String.valueOf(SAMPLE_SPEC_VALUE_TN_HEIGHT), p.getText());
assertEquals(String.valueOf(SAMPLE_SPEC_VALUE_TN_HEIGHT), p.getString());
assertToken(JsonToken.PROPERTY_NAME, p.nextToken()); // 'Width'
verifyFieldName(p, "Width");
// Width value is actually a String in the example
Expand Down Expand Up @@ -235,21 +235,21 @@ public void testForceElementAsArray() throws Exception
assertToken(JsonToken.PROPERTY_NAME, xp.nextToken()); // <elem>
assertEquals("elem", xp.currentName());
assertToken(JsonToken.VALUE_STRING, xp.nextToken());
assertEquals("value", xp.getText());
assertEquals("value", xp.getString());

assertToken(JsonToken.PROPERTY_NAME, xp.nextToken()); // <elem>
assertEquals("elem", xp.currentName());
assertToken(JsonToken.START_OBJECT, xp.nextToken()); // <property>
assertToken(JsonToken.PROPERTY_NAME, xp.nextToken());
assertEquals("property", xp.currentName());
assertToken(JsonToken.VALUE_STRING, xp.nextToken());
assertEquals("123", xp.getText());
assertEquals("123", xp.getString());
assertToken(JsonToken.END_OBJECT, xp.nextToken()); // <object>

assertToken(JsonToken.PROPERTY_NAME, xp.nextToken()); // <elem>
assertEquals("elem", xp.currentName());
assertToken(JsonToken.VALUE_STRING, xp.nextToken());
assertEquals("1", xp.getText());
assertEquals("1", xp.getString());

assertToken(JsonToken.END_OBJECT, xp.nextToken()); // </array>
xp.close();
Expand All @@ -268,17 +268,17 @@ public void testForceElementAsArray() throws Exception

assertToken(JsonToken.VALUE_STRING, xp.nextToken());
assertTrue(xp.streamReadContext().inArray());
assertEquals("value", xp.getText());
assertEquals("value", xp.getString());

assertToken(JsonToken.START_OBJECT, xp.nextToken()); // <property>
assertTrue(xp.streamReadContext().inObject());
assertToken(JsonToken.PROPERTY_NAME, xp.nextToken());
assertEquals("property", xp.currentName());
assertToken(JsonToken.VALUE_STRING, xp.nextToken());
assertEquals("123", xp.getText());
assertEquals("123", xp.getString());

StringWriter w = new StringWriter();
assertEquals(3, xp.getText(w));
assertEquals(3, xp.getString(w));
assertEquals("123", w.toString());

assertTrue(xp.streamReadContext().inObject());
Expand All @@ -287,7 +287,7 @@ public void testForceElementAsArray() throws Exception

assertToken(JsonToken.VALUE_STRING, xp.nextToken());
assertTrue(xp.streamReadContext().inArray());
assertEquals("1", xp.getText());
assertEquals("1", xp.getString());

assertToken(JsonToken.END_ARRAY, xp.nextToken()); // </array>
assertTrue(xp.streamReadContext().inRoot());
Expand All @@ -304,20 +304,20 @@ public void testXmlAttributes() throws Exception
assertToken(JsonToken.PROPERTY_NAME, xp.nextToken()); // <max>
assertEquals("max", xp.currentName());
assertToken(JsonToken.VALUE_STRING, xp.nextToken());
assertEquals("7", xp.getText());
assertEquals("7", xp.getString());

assertToken(JsonToken.PROPERTY_NAME, xp.nextToken()); // <offset>
assertEquals("offset", xp.currentName());

StringWriter w = new StringWriter();
assertEquals(6, xp.getText(w));
assertEquals(6, xp.getString(w));
assertEquals("offset", w.toString());

assertToken(JsonToken.VALUE_STRING, xp.nextToken());
assertEquals("9", xp.getText());
assertEquals("9", xp.getString());

w = new StringWriter();
assertEquals(1, xp.getText(w));
assertEquals(1, xp.getString(w));
assertEquals("9", w.toString());

assertToken(JsonToken.END_OBJECT, xp.nextToken()); // </data>
Expand All @@ -344,7 +344,7 @@ public void testInferredNumbers() throws Exception
assertEquals("value1", xp.currentName());
assertToken(JsonToken.VALUE_STRING, xp.nextToken());
assertFalse(xp.isExpectedNumberIntToken());
assertEquals("abc", xp.getText());
assertEquals("abc", xp.getString());

assertToken(JsonToken.PROPERTY_NAME, xp.nextToken()); // @value2
assertEquals("value2", xp.currentName());
Expand Down

0 comments on commit d68a8e8

Please sign in to comment.