Skip to content

Commit bb35e7b

Browse files
committed
bit more work on #674
1 parent 4ac7a64 commit bb35e7b

File tree

4 files changed

+57
-24
lines changed

4 files changed

+57
-24
lines changed

src/main/java/com/fasterxml/jackson/core/JsonGenerator.java

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,25 @@ public Object getOutputTarget() {
375375
*
376376
* @since 2.13 (added as replacement for older {@link #getCurrentValue()}
377377
*/
378-
public abstract Object currentValue();
378+
public Object currentValue() {
379+
// TODO: implement directly in 2.14 or later, make getCurrentValue() call this
380+
return getCurrentValue();
381+
}
382+
383+
/**
384+
* Helper method, usually equivalent to:
385+
*<code>
386+
* getOutputContext().setCurrentValue(v);
387+
*</code>
388+
*
389+
* @param v Current value to assign for the current context of this generator
390+
*
391+
* @since 2.13 (added as replacement for older {@link #setCurrentValue}
392+
*/
393+
public void assignCurrentValue(Object v) {
394+
// TODO: implement directly in 2.14 or later, make setCurrentValue() call this
395+
setCurrentValue(v);
396+
}
379397

380398
// TODO: deprecate in 2.14 or later
381399
/**
@@ -389,15 +407,12 @@ public Object getCurrentValue() {
389407
return (ctxt == null) ? null : ctxt.getCurrentValue();
390408
}
391409

410+
// TODO: deprecate in 2.14 or later
392411
/**
393-
* Helper method, usually equivalent to:
394-
*<code>
395-
* getOutputContext().setCurrentValue(v);
396-
*</code>
412+
* Alias for {@link #assignCurrentValue}, to be deprecated in later
413+
* Jackson 2.x versions (and removed from Jackson 3.0).
397414
*
398415
* @param v Current value to assign for the current context of this generator
399-
*
400-
* @since 2.5
401416
*/
402417
public void setCurrentValue(Object v) {
403418
JsonStreamContext ctxt = getOutputContext();

src/main/java/com/fasterxml/jackson/core/JsonParser.java

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -718,9 +718,25 @@ public JsonLocation currentTokenLocation() {
718718
* @since 2.13 (added as replacement for older {@link #getCurrentValue()}
719719
*/
720720
public Object currentValue() {
721+
// TODO: implement directly in 2.14 or later, make getCurrentValue() call this
721722
return getCurrentValue();
722723
}
723724

725+
/**
726+
* Helper method, usually equivalent to:
727+
*<code>
728+
* getParsingContext().setCurrentValue(v);
729+
*</code>
730+
*
731+
* @param v Current value to assign for the current input context of this parser
732+
*
733+
* @since 2.13 (added as replacement for older {@link #setCurrentValue}
734+
*/
735+
public void assignCurrentValue(Object v) {
736+
// TODO: implement directly in 2.14 or later, make setCurrentValue() call this
737+
setCurrentValue(v);
738+
}
739+
724740
// TODO: deprecate in 2.14 or later
725741
/**
726742
* Alias for {@link #currentValue()}, to be deprecated in later
@@ -733,15 +749,12 @@ public Object getCurrentValue() {
733749
return (ctxt == null) ? null : ctxt.getCurrentValue();
734750
}
735751

752+
// TODO: deprecate in 2.14 or later
736753
/**
737-
* Helper method, usually equivalent to:
738-
*<code>
739-
* getParsingContext().setCurrentValue(v);
740-
*</code>
754+
* Alias for {@link #assignCurrentValue}, to be deprecated in later
755+
* Jackson 2.x versions (and removed from Jackson 3.0).
741756
*
742757
* @param v Current value to assign for the current input context of this parser
743-
*
744-
* @since 2.5
745758
*/
746759
public void setCurrentValue(Object v) {
747760
JsonStreamContext ctxt = getParsingContext();

src/main/java/com/fasterxml/jackson/core/util/JsonGeneratorDelegate.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ public JsonGeneratorDelegate(JsonGenerator d, boolean delegateCopyMethods) {
6363
@Override public Object getOutputTarget() { return delegate.getOutputTarget(); }
6464
@Override public int getOutputBuffered() { return delegate.getOutputBuffered(); }
6565

66-
@Override
67-
public void setCurrentValue(Object v) {
68-
delegate.setCurrentValue(v);
69-
}
66+
@Override public void assignCurrentValue(Object v) { delegate.assignCurrentValue(v); }
67+
@Override public Object currentValue() { return delegate.currentValue(); }
7068

69+
// TODO: deprecate in 2.14 or later
7170
@Override
72-
public Object currentValue() { return delegate.currentValue(); }
71+
public void setCurrentValue(Object v) { delegate.setCurrentValue(v); }
7372

73+
// TODO: deprecate in 2.14 or later
7474
@Override
7575
public Object getCurrentValue() { return delegate.getCurrentValue(); }
7676

src/main/java/com/fasterxml/jackson/core/util/JsonParserDelegate.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,12 @@ public JsonParser overrideFormatFeatures(int values, int mask) {
104104
@Override public JsonToken getLastClearedToken() { return delegate.getLastClearedToken(); }
105105
@Override public void overrideCurrentName(String name) { delegate.overrideCurrentName(name); }
106106

107+
@Override // since 2.13
108+
public void assignCurrentValue(Object v) { delegate.assignCurrentValue(v); }
109+
110+
// TODO: deprecate in 2.14 or later
107111
@Override
108-
public void setCurrentValue(Object v) {
109-
delegate.setCurrentValue(v);
110-
}
112+
public void setCurrentValue(Object v) { delegate.setCurrentValue(v); }
111113

112114
/*
113115
/**********************************************************************
@@ -120,10 +122,13 @@ public void setCurrentValue(Object v) {
120122
@Override public JsonToken currentToken() { return delegate.currentToken(); }
121123
@Override public int currentTokenId() { return delegate.currentTokenId(); }
122124
@Override public String currentName() throws IOException { return delegate.currentName(); }
123-
@Override public Object currentValue() { return delegate.currentValue(); }
125+
@Override // since 2.13
126+
public Object currentValue() { return delegate.currentValue(); }
124127

125-
@Override public JsonLocation currentLocation() { return delegate.getCurrentLocation(); }
126-
@Override public JsonLocation currentTokenLocation() { return delegate.getTokenLocation(); }
128+
@Override // since 2.13
129+
public JsonLocation currentLocation() { return delegate.getCurrentLocation(); }
130+
@Override // since 2.13
131+
public JsonLocation currentTokenLocation() { return delegate.getTokenLocation(); }
127132

128133
// TODO: deprecate in 2.14 or later
129134
@Override public JsonToken getCurrentToken() { return delegate.getCurrentToken(); }

0 commit comments

Comments
 (0)