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 b65859b commit fa7717e
Show file tree
Hide file tree
Showing 14 changed files with 112 additions and 112 deletions.
16 changes: 8 additions & 8 deletions csv/src/main/java/tools/jackson/dataformat/csv/CsvParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ public String nextName() throws JacksonException
}

@Override
public String nextTextValue() throws JacksonException
public String nextStringValue() throws JacksonException
{
_binaryValue = null;
JsonToken t;
Expand All @@ -556,7 +556,7 @@ public String nextTextValue() throws JacksonException
} else {
t = nextToken();
if (t == JsonToken.VALUE_STRING) {
return getText();
return getString();
}
}
return null;
Expand Down Expand Up @@ -975,15 +975,15 @@ protected final JsonToken _skipUntilEndOfLine() throws JacksonException

// For now we do not store char[] representation...
@Override
public boolean hasTextCharacters() {
public boolean hasStringCharacters() {
if (_currToken == JsonToken.PROPERTY_NAME) {
return false;
}
return _textBuffer.hasTextAsCharacters();
}

@Override
public String getText() throws JacksonException {
public String getString() throws JacksonException {
if (_currToken == JsonToken.PROPERTY_NAME) {
return _currentName;
}
Expand All @@ -993,28 +993,28 @@ public String getText() throws JacksonException {
}

@Override
public char[] getTextCharacters() throws JacksonException {
public char[] getStringCharacters() throws JacksonException {
if (_currToken == JsonToken.PROPERTY_NAME) {
return _currentName.toCharArray();
}
return _textBuffer.contentsAsArray();
}

@Override
public int getTextLength() throws JacksonException {
public int getStringLength() throws JacksonException {
if (_currToken == JsonToken.PROPERTY_NAME) {
return _currentName.length();
}
return _textBuffer.size();
}

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

@Override
public int getText(Writer w) throws JacksonException {
public int getString(Writer w) throws JacksonException {
String value = (_currToken == JsonToken.PROPERTY_NAME) ?
_currentName : _currentValue;
if (value == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,10 @@ protected void assertType(Object ob, Class<?> expType)
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 @@ -291,14 +291,14 @@ protected String getAndVerifyText(JsonParser jp)

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

protected void verifyIntValue(JsonParser jp, long expValue)
{
// First, via textual
assertEquals(String.valueOf(expValue), jp.getText());
assertEquals(String.valueOf(expValue), jp.getString());
}

protected void verifyException(Throwable e, String... matches)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ public void testLatin1AsUTF8() throws Exception
assertToken(JsonToken.VALUE_STRING, parser.nextToken());
assertToken(JsonToken.PROPERTY_NAME, parser.nextToken());
assertToken(JsonToken.VALUE_STRING, parser.nextToken());
assertEquals("2", parser.getText());
assertEquals("2", parser.getString());
assertToken(JsonToken.END_OBJECT, parser.nextToken());

// problem should only be triggered now
assertToken(JsonToken.START_OBJECT, parser.nextToken());
assertToken(JsonToken.PROPERTY_NAME, parser.nextToken());
assertEquals("a", parser.currentName());
assertToken(JsonToken.VALUE_STRING, parser.nextToken());
assertEquals("abc", parser.getText());
assertEquals("abc", parser.getString());
try {
parser.nextToken();
fail("Should trigger exception for invalid UTF-8 char");
Expand Down Expand Up @@ -77,7 +77,7 @@ public void testBrokenUTF8MiddleByte() throws Exception
assertToken(JsonToken.PROPERTY_NAME, parser.nextToken());
assertEquals("a", parser.currentName());
assertToken(JsonToken.VALUE_STRING, parser.nextToken());
assertEquals("1", parser.getText());
assertEquals("1", parser.getString());
try {
assertToken(JsonToken.PROPERTY_NAME, parser.nextToken());
assertEquals("b", parser.currentName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,23 +79,23 @@ private void _testInts(boolean useBytes, int a, int b, int c) throws Exception {
assertEquals("a", parser.currentName());

StringWriter w = new StringWriter();
assertEquals(1, parser.getText(w));
assertEquals(1, parser.getString(w));
assertEquals("a", w.toString());

String numStr = String.valueOf(a);
assertEquals(numStr, parser.nextTextValue());
char[] ch = parser.getTextCharacters();
String str2 = new String(ch, parser.getTextOffset(), parser.getTextLength());
assertEquals(numStr, parser.nextStringValue());
char[] ch = parser.getStringCharacters();
String str2 = new String(ch, parser.getStringOffset(), parser.getStringLength());
assertEquals(numStr, str2);
w = new StringWriter();
assertEquals(numStr.length(), parser.getText(w));
assertEquals(numStr.length(), parser.getString(w));
assertEquals(numStr, w.toString());

assertEquals(a, parser.getIntValue());
assertEquals((long) a, parser.getLongValue());

assertEquals("b", parser.nextName());
assertEquals(""+b, parser.nextTextValue());
assertEquals(""+b, parser.nextStringValue());
assertEquals((long) b, parser.getLongValue());
assertEquals(b, parser.getIntValue());

Expand Down Expand Up @@ -151,11 +151,11 @@ private void _testLongs(boolean useBytes, long a, long b) throws Exception

assertToken(JsonToken.PROPERTY_NAME, parser.nextToken());
assertEquals("a", parser.currentName());
assertEquals(""+a, parser.nextTextValue());
assertEquals(""+a, parser.nextStringValue());
assertEquals(a, parser.getLongValue());

assertEquals("b", parser.nextName());
assertEquals(""+b, parser.nextTextValue());
assertEquals(""+b, parser.nextStringValue());
assertEquals(b, parser.getLongValue());

assertToken(JsonToken.END_OBJECT, parser.nextToken());
Expand All @@ -173,12 +173,12 @@ private void _testDoubles(boolean useBytes, double a, double b, double c)

assertToken(JsonToken.PROPERTY_NAME, parser.nextToken());
assertEquals("a", parser.currentName());
assertEquals(""+a, parser.nextTextValue());
assertEquals(""+a, parser.nextStringValue());
assertEquals(a, parser.getDoubleValue());
assertEquals((float) a, parser.getFloatValue());

assertEquals("b", parser.nextName());
assertEquals(""+b, parser.nextTextValue());
assertEquals(""+b, parser.nextStringValue());
assertEquals((float) b, parser.getFloatValue());
assertEquals(b, parser.getDoubleValue());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public JsonToken nextToken() throws JacksonException {
}

@Override
public String getText() throws JacksonException {
public String getString() throws JacksonException {
JsonToken t = _currToken;
if (t == JsonToken.VALUE_STRING) {
return _streamReadContext.getCurrentText();
Expand All @@ -224,31 +224,31 @@ public String getText() throws JacksonException {
}

@Override
public boolean hasTextCharacters() {
public boolean hasStringCharacters() {
return false;
}

@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;
}

@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 All @@ -269,7 +269,7 @@ public byte[] getBinaryValue(Base64Variant variant) throws JacksonException
_reportError("Current token ("+_currToken+") not VALUE_STRING, can not access as binary");
}
ByteArrayBuilder builder = _getByteArrayBuilder();
_decodeBase64(getText(), builder, variant);
_decodeBase64(getString(), builder, variant);
_binaryValue = builder.toByteArray();
}
return _binaryValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void testParserConfig() throws Exception
_verifyVersion(p);
assertFalse(p.canReadObjectId());
assertFalse(p.canReadTypeId());
assertFalse(p.hasTextCharacters());
assertFalse(p.hasStringCharacters());

p.close();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,10 @@ protected void assertType(Object ob, Class<?> expType)
protected String getAndVerifyText(JsonParser jp) throws IOException
{
// 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 @@ -235,15 +235,15 @@ protected String getAndVerifyText(JsonParser jp) throws IOException
protected void verifyFieldName(JsonParser p, String expName)
throws IOException
{
assertEquals(expName, p.getText());
assertEquals(expName, p.getString());
assertEquals(expName, p.currentName());
}

protected void verifyIntValue(JsonParser jp, long expValue)
throws IOException
{
// First, via textual
assertEquals(String.valueOf(expValue), jp.getText());
assertEquals(String.valueOf(expValue), jp.getString());
}

protected void verifyException(Throwable e, String... matches)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ public void testParsing()
assertNotNull(p.currentLocation()); // N/A
assertNotNull(p.currentTokenLocation()); // N/A
assertToken(JsonToken.PROPERTY_NAME, p.nextToken());
assertEquals("foo", p.getText());
assertEquals("foo", p.getString());
assertToken(JsonToken.VALUE_STRING, p.nextToken());
StringWriter sw = new StringWriter();
assertEquals(3, p.getText(sw));
assertEquals(3, p.getString(sw));
assertEquals("bar", sw.toString());
p.close();
assertTrue(p.isClosed());
Expand All @@ -43,7 +43,7 @@ public void testParsing()
p = MAPPER.createParser("foo = bar");
assertToken(JsonToken.START_OBJECT, p.nextToken());
assertEquals("foo", p.nextName());
assertEquals("bar", p.nextTextValue());
assertEquals("bar", p.nextStringValue());
assertNull(p.nextName());
p.close();

Expand Down
18 changes: 9 additions & 9 deletions yaml/src/main/java/tools/jackson/dataformat/yaml/YAMLParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -785,12 +785,12 @@ private <T> T _reportInvalidNumber(String numStr, int base, Exception e) throws

// For now we do not store char[] representation...
@Override
public boolean hasTextCharacters() {
public boolean hasStringCharacters() {
return false;
}

@Override
public String getText() throws JacksonException
public String getString() throws JacksonException
{
if (_currToken == JsonToken.VALUE_STRING) {
return _textValue;
Expand Down Expand Up @@ -823,26 +823,26 @@ public String currentName() 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;
}

@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
Loading

0 comments on commit fa7717e

Please sign in to comment.