Skip to content

Commit

Permalink
bit more work on #674
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jan 28, 2021
1 parent 4ac7a64 commit bb35e7b
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 24 deletions.
29 changes: 22 additions & 7 deletions src/main/java/com/fasterxml/jackson/core/JsonGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,25 @@ public Object getOutputTarget() {
*
* @since 2.13 (added as replacement for older {@link #getCurrentValue()}
*/
public abstract Object currentValue();
public Object currentValue() {
// TODO: implement directly in 2.14 or later, make getCurrentValue() call this
return getCurrentValue();
}

/**
* Helper method, usually equivalent to:
*<code>
* getOutputContext().setCurrentValue(v);
*</code>
*
* @param v Current value to assign for the current context of this generator
*
* @since 2.13 (added as replacement for older {@link #setCurrentValue}
*/
public void assignCurrentValue(Object v) {
// TODO: implement directly in 2.14 or later, make setCurrentValue() call this
setCurrentValue(v);
}

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

// TODO: deprecate in 2.14 or later
/**
* Helper method, usually equivalent to:
*<code>
* getOutputContext().setCurrentValue(v);
*</code>
* Alias for {@link #assignCurrentValue}, to be deprecated in later
* Jackson 2.x versions (and removed from Jackson 3.0).
*
* @param v Current value to assign for the current context of this generator
*
* @since 2.5
*/
public void setCurrentValue(Object v) {
JsonStreamContext ctxt = getOutputContext();
Expand Down
25 changes: 19 additions & 6 deletions src/main/java/com/fasterxml/jackson/core/JsonParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -718,9 +718,25 @@ public JsonLocation currentTokenLocation() {
* @since 2.13 (added as replacement for older {@link #getCurrentValue()}
*/
public Object currentValue() {
// TODO: implement directly in 2.14 or later, make getCurrentValue() call this
return getCurrentValue();
}

/**
* Helper method, usually equivalent to:
*<code>
* getParsingContext().setCurrentValue(v);
*</code>
*
* @param v Current value to assign for the current input context of this parser
*
* @since 2.13 (added as replacement for older {@link #setCurrentValue}
*/
public void assignCurrentValue(Object v) {
// TODO: implement directly in 2.14 or later, make setCurrentValue() call this
setCurrentValue(v);
}

// TODO: deprecate in 2.14 or later
/**
* Alias for {@link #currentValue()}, to be deprecated in later
Expand All @@ -733,15 +749,12 @@ public Object getCurrentValue() {
return (ctxt == null) ? null : ctxt.getCurrentValue();
}

// TODO: deprecate in 2.14 or later
/**
* Helper method, usually equivalent to:
*<code>
* getParsingContext().setCurrentValue(v);
*</code>
* Alias for {@link #assignCurrentValue}, to be deprecated in later
* Jackson 2.x versions (and removed from Jackson 3.0).
*
* @param v Current value to assign for the current input context of this parser
*
* @since 2.5
*/
public void setCurrentValue(Object v) {
JsonStreamContext ctxt = getParsingContext();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ public JsonGeneratorDelegate(JsonGenerator d, boolean delegateCopyMethods) {
@Override public Object getOutputTarget() { return delegate.getOutputTarget(); }
@Override public int getOutputBuffered() { return delegate.getOutputBuffered(); }

@Override
public void setCurrentValue(Object v) {
delegate.setCurrentValue(v);
}
@Override public void assignCurrentValue(Object v) { delegate.assignCurrentValue(v); }
@Override public Object currentValue() { return delegate.currentValue(); }

// TODO: deprecate in 2.14 or later
@Override
public Object currentValue() { return delegate.currentValue(); }
public void setCurrentValue(Object v) { delegate.setCurrentValue(v); }

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,12 @@ public JsonParser overrideFormatFeatures(int values, int mask) {
@Override public JsonToken getLastClearedToken() { return delegate.getLastClearedToken(); }
@Override public void overrideCurrentName(String name) { delegate.overrideCurrentName(name); }

@Override // since 2.13
public void assignCurrentValue(Object v) { delegate.assignCurrentValue(v); }

// TODO: deprecate in 2.14 or later
@Override
public void setCurrentValue(Object v) {
delegate.setCurrentValue(v);
}
public void setCurrentValue(Object v) { delegate.setCurrentValue(v); }

/*
/**********************************************************************
Expand All @@ -120,10 +122,13 @@ public void setCurrentValue(Object v) {
@Override public JsonToken currentToken() { return delegate.currentToken(); }
@Override public int currentTokenId() { return delegate.currentTokenId(); }
@Override public String currentName() throws IOException { return delegate.currentName(); }
@Override public Object currentValue() { return delegate.currentValue(); }
@Override // since 2.13
public Object currentValue() { return delegate.currentValue(); }

@Override public JsonLocation currentLocation() { return delegate.getCurrentLocation(); }
@Override public JsonLocation currentTokenLocation() { return delegate.getTokenLocation(); }
@Override // since 2.13
public JsonLocation currentLocation() { return delegate.getCurrentLocation(); }
@Override // since 2.13
public JsonLocation currentTokenLocation() { return delegate.getTokenLocation(); }

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

0 comments on commit bb35e7b

Please sign in to comment.