Skip to content

Commit 4ac7a64

Browse files
committed
Fixed #674
1 parent 5f2b093 commit 4ac7a64

File tree

4 files changed

+88
-67
lines changed

4 files changed

+88
-67
lines changed

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ protected JsonGenerator() { }
327327

328328
/*
329329
/**********************************************************************
330-
/* Public API, output configuration, state access
330+
/* Public API, state, output configuration access
331331
/**********************************************************************
332332
*/
333333

@@ -373,7 +373,16 @@ public Object getOutputTarget() {
373373
*
374374
* @return "Current value" associated with the current context (state) of this generator
375375
*
376-
* @since 2.5
376+
* @since 2.13 (added as replacement for older {@link #getCurrentValue()}
377+
*/
378+
public abstract Object currentValue();
379+
380+
// TODO: deprecate in 2.14 or later
381+
/**
382+
* Alias for {@link #currentValue()}, to be deprecated in later
383+
* Jackson 2.x versions (and removed from Jackson 3.0).
384+
*
385+
* @return Location of the last processed input unit (byte or character)
377386
*/
378387
public Object getCurrentValue() {
379388
JsonStreamContext ctxt = getOutputContext();
@@ -387,7 +396,7 @@ public Object getCurrentValue() {
387396
*</code>
388397
*
389398
* @param v Current value to assign for the current context of this generator
390-
*
399+
*
391400
* @since 2.5
392401
*/
393402
public void setCurrentValue(Object v) {

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

Lines changed: 53 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -429,43 +429,6 @@ protected JsonParser() { }
429429
*/
430430
public Object getInputSource() { return null; }
431431

432-
/**
433-
* Helper method, usually equivalent to:
434-
*<code>
435-
* getParsingContext().getCurrentValue();
436-
*</code>
437-
*<p>
438-
* Note that "current value" is NOT populated (or used) by Streaming parser;
439-
* it is only used by higher-level data-binding functionality.
440-
* The reason it is included here is that it can be stored and accessed hierarchically,
441-
* and gets passed through data-binding.
442-
*
443-
* @return "Current value" associated with the current input context (state) of this parser
444-
*
445-
* @since 2.5
446-
*/
447-
public Object getCurrentValue() {
448-
JsonStreamContext ctxt = getParsingContext();
449-
return (ctxt == null) ? null : ctxt.getCurrentValue();
450-
}
451-
452-
/**
453-
* Helper method, usually equivalent to:
454-
*<code>
455-
* getParsingContext().setCurrentValue(v);
456-
*</code>
457-
*
458-
* @param v Current value to assign for the current input context of this parser
459-
*
460-
* @since 2.5
461-
*/
462-
public void setCurrentValue(Object v) {
463-
JsonStreamContext ctxt = getParsingContext();
464-
if (ctxt != null) {
465-
ctxt.setCurrentValue(v);
466-
}
467-
}
468-
469432
/**
470433
* Sets the payload to be passed if {@link JsonParseException} is thrown.
471434
*
@@ -739,6 +702,54 @@ public JsonLocation currentTokenLocation() {
739702
*/
740703
public abstract JsonLocation getTokenLocation();
741704

705+
/**
706+
* Helper method, usually equivalent to:
707+
*<code>
708+
* getParsingContext().getCurrentValue();
709+
*</code>
710+
*<p>
711+
* Note that "current value" is NOT populated (or used) by Streaming parser;
712+
* it is only used by higher-level data-binding functionality.
713+
* The reason it is included here is that it can be stored and accessed hierarchically,
714+
* and gets passed through data-binding.
715+
*
716+
* @return "Current value" associated with the current input context (state) of this parser
717+
*
718+
* @since 2.13 (added as replacement for older {@link #getCurrentValue()}
719+
*/
720+
public Object currentValue() {
721+
return getCurrentValue();
722+
}
723+
724+
// TODO: deprecate in 2.14 or later
725+
/**
726+
* Alias for {@link #currentValue()}, to be deprecated in later
727+
* Jackson 2.x versions (and removed from Jackson 3.0).
728+
*
729+
* @return Location of the last processed input unit (byte or character)
730+
*/
731+
public Object getCurrentValue() {
732+
JsonStreamContext ctxt = getParsingContext();
733+
return (ctxt == null) ? null : ctxt.getCurrentValue();
734+
}
735+
736+
/**
737+
* Helper method, usually equivalent to:
738+
*<code>
739+
* getParsingContext().setCurrentValue(v);
740+
*</code>
741+
*
742+
* @param v Current value to assign for the current input context of this parser
743+
*
744+
* @since 2.5
745+
*/
746+
public void setCurrentValue(Object v) {
747+
JsonStreamContext ctxt = getParsingContext();
748+
if (ctxt != null) {
749+
ctxt.setCurrentValue(v);
750+
}
751+
}
752+
742753
/*
743754
/**********************************************************
744755
/* Buffer handling
@@ -1196,17 +1207,18 @@ public int currentTokenId() {
11961207
return getCurrentTokenId();
11971208
}
11981209

1210+
// TODO: deprecate in 2.14 or later
11991211
/**
12001212
* Alias for {@link #currentToken()}, may be deprecated sometime after
1201-
* Jackson 2.12 (will be removed from 3.0).
1213+
* Jackson 2.13 (will be removed from 3.0).
12021214
*
12031215
* @return Type of the token this parser currently points to,
12041216
* if any: null before any tokens have been read, and
12051217
*/
12061218
public abstract JsonToken getCurrentToken();
12071219

12081220
/**
1209-
* Alias for {@link #currentTokenId()}.
1221+
* Deprecated alias for {@link #currentTokenId()}.
12101222
*
12111223
* @return {@code int} matching one of constants from {@link JsonTokenId}.
12121224
*
@@ -1385,8 +1397,9 @@ public boolean isNaN() throws IOException {
13851397
/**********************************************************
13861398
*/
13871399

1400+
// TODO: deprecate in 2.14 or later
13881401
/**
1389-
* See {@link #currentName()}.
1402+
* Alias of {@link #currentName()}.
13901403
*
13911404
* @return Name of the current field in the parsing context
13921405
*

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

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,9 @@ public JsonGeneratorDelegate(JsonGenerator d, boolean delegateCopyMethods) {
4444
this.delegateCopyMethods = delegateCopyMethods;
4545
}
4646

47-
@Override
48-
public Object getCurrentValue() {
49-
return delegate.getCurrentValue();
50-
}
51-
52-
@Override
53-
public void setCurrentValue(Object v) {
54-
delegate.setCurrentValue(v);
55-
}
56-
5747
/*
5848
/**********************************************************************
59-
/* Public API, metadata
49+
/* Public API, metadata/state access
6050
/**********************************************************************
6151
*/
6252

@@ -73,6 +63,17 @@ public void setCurrentValue(Object v) {
7363
@Override public Object getOutputTarget() { return delegate.getOutputTarget(); }
7464
@Override public int getOutputBuffered() { return delegate.getOutputBuffered(); }
7565

66+
@Override
67+
public void setCurrentValue(Object v) {
68+
delegate.setCurrentValue(v);
69+
}
70+
71+
@Override
72+
public Object currentValue() { return delegate.currentValue(); }
73+
74+
@Override
75+
public Object getCurrentValue() { return delegate.getCurrentValue(); }
76+
7677
/*
7778
/**********************************************************************
7879
/* Public API, capability introspection

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

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,6 @@ public JsonParserDelegate(JsonParser d) {
2626
delegate = d;
2727
}
2828

29-
@Override
30-
public Object getCurrentValue() {
31-
return delegate.getCurrentValue();
32-
}
33-
34-
@Override
35-
public void setCurrentValue(Object v) {
36-
delegate.setCurrentValue(v);
37-
}
38-
3929
/*
4030
/**********************************************************************
4131
/* Public API, configuration
@@ -106,25 +96,31 @@ public JsonParser overrideFormatFeatures(int values, int mask) {
10696

10797
/*
10898
/**********************************************************************
109-
/* Public API, state override methods
99+
/* Public API, state change/override methods
110100
/**********************************************************************
111101
*/
112-
102+
113103
@Override public void clearCurrentToken() { delegate.clearCurrentToken(); }
114104
@Override public JsonToken getLastClearedToken() { return delegate.getLastClearedToken(); }
115105
@Override public void overrideCurrentName(String name) { delegate.overrideCurrentName(name); }
116106

107+
@Override
108+
public void setCurrentValue(Object v) {
109+
delegate.setCurrentValue(v);
110+
}
111+
117112
/*
118113
/**********************************************************************
119114
/* Public API, state/location accessors
120115
/**********************************************************************
121116
*/
122117

123118
@Override public JsonStreamContext getParsingContext() { return delegate.getParsingContext(); }
124-
119+
125120
@Override public JsonToken currentToken() { return delegate.currentToken(); }
126121
@Override public int currentTokenId() { return delegate.currentTokenId(); }
127122
@Override public String currentName() throws IOException { return delegate.currentName(); }
123+
@Override public Object currentValue() { return delegate.currentValue(); }
128124

129125
@Override public JsonLocation currentLocation() { return delegate.getCurrentLocation(); }
130126
@Override public JsonLocation currentTokenLocation() { return delegate.getTokenLocation(); }
@@ -135,6 +131,8 @@ public JsonParser overrideFormatFeatures(int values, int mask) {
135131
@Override public int getCurrentTokenId() { return delegate.getCurrentTokenId(); }
136132
// TODO: deprecate in 2.14 or later
137133
@Override public String getCurrentName() throws IOException { return delegate.getCurrentName(); }
134+
// TODO: deprecate in 2.14 or later
135+
@Override public Object getCurrentValue() { return delegate.getCurrentValue(); }
138136

139137
// TODO: deprecate in 2.14 or later
140138
@Override public JsonLocation getCurrentLocation() { return delegate.getCurrentLocation(); }

0 commit comments

Comments
 (0)