Skip to content

Commit

Permalink
增加writeObjectWithCodec
Browse files Browse the repository at this point in the history
  • Loading branch information
entropy-cloud committed Sep 28, 2024
1 parent 13d592d commit d150775
Show file tree
Hide file tree
Showing 40 changed files with 475 additions and 664 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
package io.nop.record.codec._gen;

import io.nop.record.codec.IFieldBinaryCodec;
import io.nop.record.codec.IFieldBinaryEncoder;
import io.nop.record.codec.IFieldCodecContext;
import io.nop.record.input.IRecordBinaryInput;
import io.nop.record.output.IRecordBinaryOutput;
Expand All @@ -15,7 +16,8 @@ public class FieldBinaryCodec_${wordType.name} implements IFieldBinaryCodec{
return input.read${wordType.name.$capitalize()}();
}

public void encode(IRecordBinaryOutput output, Object value, int length, Charset charset, IFieldCodecContext context){
public void encode(IRecordBinaryOutput output, Object value, int length, Charset charset,
IFieldCodecContext context, IFieldBinaryEncoder bodyEncoder){
if(value == null){
output.write${wordType.name.$capitalize()}(${wordType.obj.defaultValueInitializer});
}else{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,5 @@
*/
package io.nop.record.codec;

import io.nop.record.input.IRecordBinaryInput;
import io.nop.record.output.IRecordBinaryOutput;

import java.nio.charset.Charset;

public interface IFieldBinaryCodec {
Object decode(IRecordBinaryInput input, int length, Charset charset, IFieldCodecContext context);

void encode(IRecordBinaryOutput output, Object value, int length, Charset charset, IFieldCodecContext context);
public interface IFieldBinaryCodec extends IFieldBinaryEncoder, IFieldBinaryDecoder {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package io.nop.record.codec;

import io.nop.record.input.IRecordBinaryInput;

import java.nio.charset.Charset;

public interface IFieldBinaryDecoder {

Object decode(IRecordBinaryInput input, int length, Charset charset, IFieldCodecContext context);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package io.nop.record.codec;

import io.nop.record.output.IRecordBinaryOutput;

import java.nio.charset.Charset;

public interface IFieldBinaryEncoder {

void encode(IRecordBinaryOutput output, Object value, int length, Charset charset,
IFieldCodecContext context, IFieldBinaryEncoder bodyEncoder);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@
*/
package io.nop.record.codec;

import io.nop.record.input.IRecordTextInput;
import io.nop.record.output.IRecordTextOutput;
public interface IFieldTextCodec extends IFieldTextEncoder, IFieldTextDecoder {

public interface IFieldTextCodec {
Object decode(IRecordTextInput input, int length, IFieldCodecContext context);

void encode(IRecordTextOutput output, Object value, int length, IFieldCodecContext context);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package io.nop.record.codec;

import io.nop.record.input.IRecordTextInput;

public interface IFieldTextDecoder {
Object decode(IRecordTextInput input, int length, IFieldCodecContext context);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package io.nop.record.codec;

import io.nop.record.output.IRecordTextOutput;

public interface IFieldTextEncoder {
void encode(IRecordTextOutput output, Object value, int length, IFieldCodecContext context, IFieldTextEncoder bodyEncoder);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
package io.nop.record.codec._gen;

import io.nop.record.codec.IFieldBinaryCodec;
import io.nop.record.codec.IFieldBinaryEncoder;
import io.nop.record.codec.IFieldCodecContext;
import io.nop.record.input.IRecordBinaryInput;
import io.nop.record.output.IRecordBinaryOutput;
Expand All @@ -15,7 +16,8 @@ public Object decode(IRecordBinaryInput input, int length, Charset charset, IFie
return input.readF4be();
}

public void encode(IRecordBinaryOutput output, Object value, int length, Charset charset, IFieldCodecContext context){
public void encode(IRecordBinaryOutput output, Object value, int length, Charset charset,
IFieldCodecContext context, IFieldBinaryEncoder bodyEncoder){
if(value == null){
output.writeF4be(0.0f);
}else{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
package io.nop.record.codec._gen;

import io.nop.record.codec.IFieldBinaryCodec;
import io.nop.record.codec.IFieldBinaryEncoder;
import io.nop.record.codec.IFieldCodecContext;
import io.nop.record.input.IRecordBinaryInput;
import io.nop.record.output.IRecordBinaryOutput;
Expand All @@ -15,7 +16,8 @@ public Object decode(IRecordBinaryInput input, int length, Charset charset, IFie
return input.readF4le();
}

public void encode(IRecordBinaryOutput output, Object value, int length, Charset charset, IFieldCodecContext context){
public void encode(IRecordBinaryOutput output, Object value, int length, Charset charset,
IFieldCodecContext context, IFieldBinaryEncoder bodyEncoder){
if(value == null){
output.writeF4le(0.0f);
}else{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
package io.nop.record.codec._gen;

import io.nop.record.codec.IFieldBinaryCodec;
import io.nop.record.codec.IFieldBinaryEncoder;
import io.nop.record.codec.IFieldCodecContext;
import io.nop.record.input.IRecordBinaryInput;
import io.nop.record.output.IRecordBinaryOutput;
Expand All @@ -15,7 +16,8 @@ public Object decode(IRecordBinaryInput input, int length, Charset charset, IFie
return input.readF8be();
}

public void encode(IRecordBinaryOutput output, Object value, int length, Charset charset, IFieldCodecContext context){
public void encode(IRecordBinaryOutput output, Object value, int length, Charset charset,
IFieldCodecContext context, IFieldBinaryEncoder bodyEncoder){
if(value == null){
output.writeF8be(0.0);
}else{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
package io.nop.record.codec._gen;

import io.nop.record.codec.IFieldBinaryCodec;
import io.nop.record.codec.IFieldBinaryEncoder;
import io.nop.record.codec.IFieldCodecContext;
import io.nop.record.input.IRecordBinaryInput;
import io.nop.record.output.IRecordBinaryOutput;
Expand All @@ -15,7 +16,8 @@ public Object decode(IRecordBinaryInput input, int length, Charset charset, IFie
return input.readF8le();
}

public void encode(IRecordBinaryOutput output, Object value, int length, Charset charset, IFieldCodecContext context){
public void encode(IRecordBinaryOutput output, Object value, int length, Charset charset,
IFieldCodecContext context, IFieldBinaryEncoder bodyEncoder){
if(value == null){
output.writeF8le(0.0);
}else{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
package io.nop.record.codec._gen;

import io.nop.record.codec.IFieldBinaryCodec;
import io.nop.record.codec.IFieldBinaryEncoder;
import io.nop.record.codec.IFieldCodecContext;
import io.nop.record.input.IRecordBinaryInput;
import io.nop.record.output.IRecordBinaryOutput;
Expand All @@ -15,7 +16,8 @@ public Object decode(IRecordBinaryInput input, int length, Charset charset, IFie
return input.readS1();
}

public void encode(IRecordBinaryOutput output, Object value, int length, Charset charset, IFieldCodecContext context){
public void encode(IRecordBinaryOutput output, Object value, int length, Charset charset,
IFieldCodecContext context, IFieldBinaryEncoder bodyEncoder){
if(value == null){
output.writeS1((byte) 0);
}else{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
package io.nop.record.codec._gen;

import io.nop.record.codec.IFieldBinaryCodec;
import io.nop.record.codec.IFieldBinaryEncoder;
import io.nop.record.codec.IFieldCodecContext;
import io.nop.record.input.IRecordBinaryInput;
import io.nop.record.output.IRecordBinaryOutput;
Expand All @@ -15,7 +16,8 @@ public Object decode(IRecordBinaryInput input, int length, Charset charset, IFie
return input.readS2be();
}

public void encode(IRecordBinaryOutput output, Object value, int length, Charset charset, IFieldCodecContext context){
public void encode(IRecordBinaryOutput output, Object value, int length, Charset charset,
IFieldCodecContext context, IFieldBinaryEncoder bodyEncoder){
if(value == null){
output.writeS2be((short) 0);
}else{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
package io.nop.record.codec._gen;

import io.nop.record.codec.IFieldBinaryCodec;
import io.nop.record.codec.IFieldBinaryEncoder;
import io.nop.record.codec.IFieldCodecContext;
import io.nop.record.input.IRecordBinaryInput;
import io.nop.record.output.IRecordBinaryOutput;
Expand All @@ -15,7 +16,8 @@ public Object decode(IRecordBinaryInput input, int length, Charset charset, IFie
return input.readS2le();
}

public void encode(IRecordBinaryOutput output, Object value, int length, Charset charset, IFieldCodecContext context){
public void encode(IRecordBinaryOutput output, Object value, int length, Charset charset,
IFieldCodecContext context, IFieldBinaryEncoder bodyEncoder){
if(value == null){
output.writeS2le((short) 0);
}else{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
package io.nop.record.codec._gen;

import io.nop.record.codec.IFieldBinaryCodec;
import io.nop.record.codec.IFieldBinaryEncoder;
import io.nop.record.codec.IFieldCodecContext;
import io.nop.record.input.IRecordBinaryInput;
import io.nop.record.output.IRecordBinaryOutput;
Expand All @@ -15,7 +16,8 @@ public Object decode(IRecordBinaryInput input, int length, Charset charset, IFie
return input.readS4be();
}

public void encode(IRecordBinaryOutput output, Object value, int length, Charset charset, IFieldCodecContext context){
public void encode(IRecordBinaryOutput output, Object value, int length, Charset charset,
IFieldCodecContext context, IFieldBinaryEncoder bodyEncoder){
if(value == null){
output.writeS4be(0);
}else{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
package io.nop.record.codec._gen;

import io.nop.record.codec.IFieldBinaryCodec;
import io.nop.record.codec.IFieldBinaryEncoder;
import io.nop.record.codec.IFieldCodecContext;
import io.nop.record.input.IRecordBinaryInput;
import io.nop.record.output.IRecordBinaryOutput;
Expand All @@ -15,7 +16,8 @@ public Object decode(IRecordBinaryInput input, int length, Charset charset, IFie
return input.readS4le();
}

public void encode(IRecordBinaryOutput output, Object value, int length, Charset charset, IFieldCodecContext context){
public void encode(IRecordBinaryOutput output, Object value, int length, Charset charset,
IFieldCodecContext context, IFieldBinaryEncoder bodyEncoder){
if(value == null){
output.writeS4le(0);
}else{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
package io.nop.record.codec._gen;

import io.nop.record.codec.IFieldBinaryCodec;
import io.nop.record.codec.IFieldBinaryEncoder;
import io.nop.record.codec.IFieldCodecContext;
import io.nop.record.input.IRecordBinaryInput;
import io.nop.record.output.IRecordBinaryOutput;
Expand All @@ -15,7 +16,8 @@ public Object decode(IRecordBinaryInput input, int length, Charset charset, IFie
return input.readS8be();
}

public void encode(IRecordBinaryOutput output, Object value, int length, Charset charset, IFieldCodecContext context){
public void encode(IRecordBinaryOutput output, Object value, int length, Charset charset,
IFieldCodecContext context, IFieldBinaryEncoder bodyEncoder){
if(value == null){
output.writeS8be(0L);
}else{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
package io.nop.record.codec._gen;

import io.nop.record.codec.IFieldBinaryCodec;
import io.nop.record.codec.IFieldBinaryEncoder;
import io.nop.record.codec.IFieldCodecContext;
import io.nop.record.input.IRecordBinaryInput;
import io.nop.record.output.IRecordBinaryOutput;
Expand All @@ -15,7 +16,8 @@ public Object decode(IRecordBinaryInput input, int length, Charset charset, IFie
return input.readS8le();
}

public void encode(IRecordBinaryOutput output, Object value, int length, Charset charset, IFieldCodecContext context){
public void encode(IRecordBinaryOutput output, Object value, int length, Charset charset,
IFieldCodecContext context, IFieldBinaryEncoder bodyEncoder){
if(value == null){
output.writeS8le(0L);
}else{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
package io.nop.record.codec._gen;

import io.nop.record.codec.IFieldBinaryCodec;
import io.nop.record.codec.IFieldBinaryEncoder;
import io.nop.record.codec.IFieldCodecContext;
import io.nop.record.input.IRecordBinaryInput;
import io.nop.record.output.IRecordBinaryOutput;
Expand All @@ -15,7 +16,8 @@ public Object decode(IRecordBinaryInput input, int length, Charset charset, IFie
return input.readU1();
}

public void encode(IRecordBinaryOutput output, Object value, int length, Charset charset, IFieldCodecContext context){
public void encode(IRecordBinaryOutput output, Object value, int length, Charset charset,
IFieldCodecContext context, IFieldBinaryEncoder bodyEncoder){
if(value == null){
output.writeU1((short) 0);
}else{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
package io.nop.record.codec._gen;

import io.nop.record.codec.IFieldBinaryCodec;
import io.nop.record.codec.IFieldBinaryEncoder;
import io.nop.record.codec.IFieldCodecContext;
import io.nop.record.input.IRecordBinaryInput;
import io.nop.record.output.IRecordBinaryOutput;
Expand All @@ -15,7 +16,8 @@ public Object decode(IRecordBinaryInput input, int length, Charset charset, IFie
return input.readU2be();
}

public void encode(IRecordBinaryOutput output, Object value, int length, Charset charset, IFieldCodecContext context){
public void encode(IRecordBinaryOutput output, Object value, int length, Charset charset,
IFieldCodecContext context, IFieldBinaryEncoder bodyEncoder){
if(value == null){
output.writeU2be(0);
}else{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
package io.nop.record.codec._gen;

import io.nop.record.codec.IFieldBinaryCodec;
import io.nop.record.codec.IFieldBinaryEncoder;
import io.nop.record.codec.IFieldCodecContext;
import io.nop.record.input.IRecordBinaryInput;
import io.nop.record.output.IRecordBinaryOutput;
Expand All @@ -15,7 +16,8 @@ public Object decode(IRecordBinaryInput input, int length, Charset charset, IFie
return input.readU2le();
}

public void encode(IRecordBinaryOutput output, Object value, int length, Charset charset, IFieldCodecContext context){
public void encode(IRecordBinaryOutput output, Object value, int length, Charset charset,
IFieldCodecContext context, IFieldBinaryEncoder bodyEncoder){
if(value == null){
output.writeU2le(0);
}else{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
package io.nop.record.codec._gen;

import io.nop.record.codec.IFieldBinaryCodec;
import io.nop.record.codec.IFieldBinaryEncoder;
import io.nop.record.codec.IFieldCodecContext;
import io.nop.record.input.IRecordBinaryInput;
import io.nop.record.output.IRecordBinaryOutput;
Expand All @@ -15,7 +16,8 @@ public Object decode(IRecordBinaryInput input, int length, Charset charset, IFie
return input.readU4be();
}

public void encode(IRecordBinaryOutput output, Object value, int length, Charset charset, IFieldCodecContext context){
public void encode(IRecordBinaryOutput output, Object value, int length, Charset charset,
IFieldCodecContext context, IFieldBinaryEncoder bodyEncoder){
if(value == null){
output.writeU4be(0L);
}else{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
package io.nop.record.codec._gen;

import io.nop.record.codec.IFieldBinaryCodec;
import io.nop.record.codec.IFieldBinaryEncoder;
import io.nop.record.codec.IFieldCodecContext;
import io.nop.record.input.IRecordBinaryInput;
import io.nop.record.output.IRecordBinaryOutput;
Expand All @@ -15,7 +16,8 @@ public Object decode(IRecordBinaryInput input, int length, Charset charset, IFie
return input.readU4le();
}

public void encode(IRecordBinaryOutput output, Object value, int length, Charset charset, IFieldCodecContext context){
public void encode(IRecordBinaryOutput output, Object value, int length, Charset charset,
IFieldCodecContext context, IFieldBinaryEncoder bodyEncoder){
if(value == null){
output.writeU4le(0L);
}else{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
package io.nop.record.codec._gen;

import io.nop.record.codec.IFieldBinaryCodec;
import io.nop.record.codec.IFieldBinaryEncoder;
import io.nop.record.codec.IFieldCodecContext;
import io.nop.record.input.IRecordBinaryInput;
import io.nop.record.output.IRecordBinaryOutput;
Expand All @@ -15,7 +16,8 @@ public Object decode(IRecordBinaryInput input, int length, Charset charset, IFie
return input.readU8be();
}

public void encode(IRecordBinaryOutput output, Object value, int length, Charset charset, IFieldCodecContext context){
public void encode(IRecordBinaryOutput output, Object value, int length, Charset charset,
IFieldCodecContext context, IFieldBinaryEncoder bodyEncoder){
if(value == null){
output.writeU8be(0L);
}else{
Expand Down
Loading

0 comments on commit d150775

Please sign in to comment.