Skip to content

Commit 496cafc

Browse files
committed
Start work on writer-side of custom handlers
1 parent 3ea4211 commit 496cafc

File tree

5 files changed

+42
-15
lines changed

5 files changed

+42
-15
lines changed

jr-objects/src/main/java/com/fasterxml/jackson/jr/ob/api/ValueReader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
/**
1010
* API and base class for all "deserializer" implementations used to actually read
11-
* values of Java types from (json) input.
11+
* values of Java types from (JSON) input.
1212
*/
1313
public abstract class ValueReader
1414
{
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.fasterxml.jackson.jr.ob.api;
2+
3+
import java.io.IOException;
4+
5+
import com.fasterxml.jackson.core.JsonGenerator;
6+
import com.fasterxml.jackson.jr.ob.impl.JSONWriter;
7+
8+
/**
9+
*
10+
* @since 2.10
11+
*/
12+
public interface ValueWriter {
13+
public void writeValue(JSONWriter context, JsonGenerator g, Object value)
14+
throws IOException;
15+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.fasterxml.jackson.jr.ob.impl;
2+
3+
import java.io.IOException;
4+
5+
import com.fasterxml.jackson.core.JsonGenerator;
6+
import com.fasterxml.jackson.jr.ob.api.ValueWriter;
7+
8+
public class BeanWriter
9+
implements ValueWriter
10+
{
11+
protected final BeanPropertyWriter[] _properties;
12+
13+
public BeanWriter(BeanPropertyWriter[] props) {
14+
_properties = props;
15+
}
16+
17+
@Override
18+
public void writeValue(JSONWriter context, JsonGenerator g, Object value)
19+
throws IOException
20+
{
21+
context.writeBeanValue(_properties, value);
22+
}
23+
24+
}

jr-objects/src/main/java/com/fasterxml/jackson/jr/ob/impl/JSONWriter.java

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -163,18 +163,6 @@ public void writeValue(Object value) throws IOException
163163
_writeValue(value, _writerLocator.findSerializationType(value.getClass()));
164164
}
165165

166-
@Deprecated // since 2.8
167-
public void writeField(String fieldName, Object value) throws IOException
168-
{
169-
if (value == null) {
170-
if (_writeNullValues) {
171-
writeNullField(fieldName);
172-
}
173-
return;
174-
}
175-
writeField(fieldName, value, _writerLocator.findSerializationType(value.getClass()));
176-
}
177-
178166
public void writeField(String fieldName, Object value, int type) throws IOException
179167
{
180168
switch (type) {
@@ -693,7 +681,7 @@ protected void writeEnumField(String fieldName, Enum<?> v) throws IOException {
693681
}
694682
}
695683

696-
protected void writeBeanValue(BeanPropertyWriter[] props, Object bean) throws IOException
684+
public void writeBeanValue(BeanPropertyWriter[] props, Object bean) throws IOException
697685
{
698686
_generator.writeStartObject();
699687
for (int i = 0, end = props.length; i < end; ++i) {

jr-objects/src/main/java/com/fasterxml/jackson/jr/ob/impl/ValueWriterLocator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public ValueWriterLocator perOperationInstance(JSONWriter w, int features) {
120120
/* Public API: writer lookup
121121
/**********************************************************************
122122
*/
123-
123+
124124
public BeanPropertyWriter[] getPropertyWriters(int index) {
125125
// for simplicity, let's allow caller to pass negative id as is
126126
if (index < 0) {

0 commit comments

Comments
 (0)