sofahessian

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 30, 2022 License: Apache-2.0 Imports: 19 Imported by: 1

Documentation

Overview

Package sofahessian implements the hessian 2.0 serialization protocol with golang in http://hessian.caucho.com/doc/hessian-serialization.html

hessian v2 grammar top ::= value

# 8-bit binary data split into 64k chunks

binary ::= x41 b1 b0 <binary-data> binary # non-final chunk

::= 'B' b1 b0 <binary-data>        # final chunk
::= [x20-x2f] <binary-data>        # binary data of
                                      #  length 0-15
::= [x34-x37] <binary-data>        # binary data of
                                      #  length 0-1023

# boolean true/false

boolean ::= 'T'

::= 'F'

# definition for an object (compact map)

class-def ::= 'C' string int string*

# time in UTC encoded as 64-bit long milliseconds since
#  epoch

date ::= x4a b7 b6 b5 b4 b3 b2 b1 b0

::= x4b b3 b2 b1 b0       # minutes since epoch

# 64-bit IEEE double

double ::= 'D' b7 b6 b5 b4 b3 b2 b1 b0

::= x5b                   # 0.0
::= x5c                   # 1.0
::= x5d b0                # byte cast to double
                          #  (-128.0 to 127.0)
::= x5e b1 b0             # short cast to double
::= x5f b3 b2 b1 b0       # 32-bit float cast to double

# 32-bit signed integer

int ::= 'I' b3 b2 b1 b0

::= [x80-xbf]             # -x10 to x3f
::= [xc0-xcf] b0          # -x800 to x7ff
::= [xd0-xd7] b1 b0       # -x40000 to x3ffff

# list/vector

list ::= x55 type value* 'Z' # variable-length list

	   ::= 'V' type int value*   # fixed-length list
           ::= x57 value* 'Z'        # variable-length untyped list
           ::= x58 int value*        # fixed-length untyped list
	   ::= [x70-77] type value*  # fixed-length typed list
	   ::= [x78-7f] value*       # fixed-length untyped list

           # 64-bit signed long integer

long ::= 'L' b7 b6 b5 b4 b3 b2 b1 b0

::= [xd8-xef]             # -x08 to x0f
::= [xf0-xff] b0          # -x800 to x7ff
::= [x38-x3f] b1 b0       # -x40000 to x3ffff
::= x59 b3 b2 b1 b0       # 32-bit integer cast to long

# map/object

map ::= 'M' type (value value)* 'Z' # key, value map pairs

	   ::= 'H' (value value)* 'Z'       # untyped key, value

           # null value

null ::= 'N'

# Object instance

object ::= 'O' int value*

	   ::= [x60-x6f] value*

           # value reference (e.g. circular trees and graphs)

ref ::= x51 int # reference to nth map/list/object

# UTF-8 encoded character string split into 64k chunks

string ::= x52 b1 b0 <utf8-data> string # non-final chunk

::= 'S' b1 b0 <utf8-data>         # string of length
                                  #  0-65535
::= [x00-x1f] <utf8-data>         # string of length
                                  #  0-31
::= [x30-x34] <utf8-data>         # string of length
                                  #  0-1023

# map/list types for OO languages

type ::= string # type name

::= int                           # type reference

# main production

value ::= null

::= binary
::= boolean
::= class-def value
::= date
::= double
::= int
::= list
::= long
::= map
::= object
::= ref
::= string

Index

Constants

View Source
const (
	INTDIRECTMIN = -0x10    // -16
	INTDIRECTMAX = 0x2f     // 47
	INTZERO      = 0x90     // 144
	INTBYTEMIN   = -0x800   // -2048
	INTBYTEMAX   = 0x7ff    // 2047
	INTBYTEZERO  = 0xc8     // 200
	INTSHORTMIN  = -0x40000 // -262144
	INTSHORTMAX  = 0x3ffff  // 262143
	INTSHORTZERO = 0xd4     // 212

	LONGDIRECTMIN = -0x08
	LONGDIRECTMAX = 0x0f
	LONGZERO      = 0xe0
	LONGBYTEMIN   = -0x800
	LONGBYTEMAX   = 0x7ff
	LONGBYTEZERO  = 0xf8
	LONGSHORTMIN  = -0x40000
	LONGSHORTMAX  = 0x3ffff
	LONGSHORTZERO = 0x3c

	LISTDIRECT          = 0x70
	LISTDIRECTUNTYPED   = 0x78
	LISTDIRECTMAX       = 0x7
	LISTVARIABLE        = 0x55
	LISTFIXED           = 'V'
	LISTVARIABLEUNTYPED = 0x57
	LISTFIXEDUNTYPED    = 0x58
)

Variables

View Source
var (
	ErrEncodeTypeReferencesIsNil         = errors.New("hessian: type references cannot be nil")
	ErrEncodeTooManyNestedJSON           = errors.New("hessian: too many nested JSON")
	ErrEncodeNotSliceType                = errors.New("hessian: type is not slice")
	ErrEncodeNotStructType               = errors.New("hessian: type is not struct")
	ErrEncodeNotMapType                  = errors.New("hessian: type is not map")
	ErrEncodeSliceElemCannotBeInterfaced = errors.New("hessian: slice[i] cannot be interfaced")
	ErrEncodeSliceCannotBeInterfaced     = errors.New("hessian: slice cannot be interfaced")
	ErrEncodeStructCannotBeInterfaced    = errors.New("hessian: struct cannot be interfaced")
	ErrEncodeMapCannotBeInterfaced       = errors.New("hessian: map cannot be interfaced")
	ErrEncodePtrCannotBeInterfaced       = errors.New("hessian: pointer cannot be interfaced")
	ErrEncodeCannotInvalidValue          = errors.New("hessian: cannot encode invalid value")
	ErrDecodeBufferNotEnough             = errors.New("hessian: buffer not enough")
	ErrDecodeCannotDecodeInt32           = errors.New("hessian: malformed int32")
	ErrDecodeCannotDecodeInt64           = errors.New("hessian: malformed int64")
	ErrDecodeMalformedBool               = errors.New("hessian: malformed bool")
	ErrDecodeMalformedNil                = errors.New("hessian: malformed nil")
	ErrDecodeMalformedDouble             = errors.New("hessian: malformed double")
	ErrDecodeMalformedMap                = errors.New("hessian: malformed map")
	ErrDecodeMalformedUntypedMap         = errors.New("hessian: malformed untyped map")
	ErrDecodeMalformedTypedMap           = errors.New("hessian: malformed typed map")
	ErrDecodeMalformedDate               = errors.New("hessian: malformed date")
	ErrDecodeMalformedString             = errors.New("hessian: malformed string")
	ErrDecodeMalformedBinary             = errors.New("hessian: malformed binary")
	ErrDecodeMalformedObject             = errors.New("hessian: malformed object")
	ErrDecodeUnmatchedObject             = errors.New("hessian: unmatched object")
	ErrDecodeMalformedList               = errors.New("hessian: malformed list")
	ErrDecodeMalformedListEnd            = errors.New("hessian: malformed list end")
	ErrDecodeMalformedReference          = errors.New("hessian: malformed reference")
	ErrDecodeMalformedJSON               = errors.New("hessian: malformed json")
	ErrDecodeClassRefsIsNil              = errors.New("hessian: classrefs is nil")
	ErrDecodeClassRefsOverflow           = errors.New("hessian: classrefs overflow")
	ErrDecodeObjectRefsIsNil             = errors.New("hessian: objectrefs is nil")
	ErrDecodeTypeRefsIsNil               = errors.New("hessian: typerefs is nil")
	ErrDecodeTypeRefsOverflow            = errors.New("hessian: typerefs overflow")
	ErrDecodeObjectRefsOverflow          = errors.New("hessian: objectrefs overflow")
	ErrDecodeTypedMapKeyNotString        = errors.New("hessian: typedmap key is not string")
	ErrDecodeTypedMapValueNotAssign      = errors.New("hessian: typedmap value cannot set")
	ErrDecodeMaxDepthExceeded            = errors.New("hessian: encode depth exceeded")
	ErrEncodeMaxDepthExceeded            = errors.New("hessian: decode depth exceeded")
	ErrDecodeMaxListLengthExceeded       = errors.New("hessian: decode max list length exceeded")
	ErrDecodeMaxObjectFieldsExceeded     = errors.New("hessian: decode max object fields exceeded")
	ErrDecodeUnknownEncoding             = errors.New("hessian: decode unknown encoding")
	ErrDecodeObjectFieldCannotBeNull     = errors.New("hessian: decode object field cannot be null")
	ErrDecodeMapUnhashable               = errors.New("hessian: cannot set the value to the unhashable key of map")
)
View Source
var (
	JavaClassNameGetterInterfaceType = reflect.TypeOf((*JavaClassNameGetter)(nil)).Elem()
	HessianEncoderInterfaceType      = reflect.TypeOf((*HessianEncoder)(nil)).Elem()
	HessianDecoderInterfaceType      = reflect.TypeOf((*HessianDecoder)(nil)).Elem()
)

Functions

func DecodeBinaryHessian3V2

func DecodeBinaryHessian3V2(o *DecodeContext, reader *bufio.Reader) ([]byte, error)

func DecodeBinaryHessian4V2

func DecodeBinaryHessian4V2(o *DecodeContext, reader *bufio.Reader) ([]byte, error)

func DecodeBinaryHessianV1

func DecodeBinaryHessianV1(o *DecodeContext, reader *bufio.Reader) ([]byte, error)

func DecodeBinaryToHessian3V2

func DecodeBinaryToHessian3V2(o *DecodeContext, reader *bufio.Reader, dst []byte) ([]byte, error)

func DecodeBinaryToHessian4V2

func DecodeBinaryToHessian4V2(o *DecodeContext, reader *bufio.Reader, dst []byte) ([]byte, error)

func DecodeBinaryToHessianV1

func DecodeBinaryToHessianV1(o *DecodeContext, reader *bufio.Reader, dst []byte) ([]byte, error)

func DecodeBoolHessian3V2

func DecodeBoolHessian3V2(o *DecodeContext, reader io.Reader) (bool, error)

func DecodeBoolHessian4V2

func DecodeBoolHessian4V2(o *DecodeContext, reader io.Reader) (bool, error)

func DecodeBoolHessianV1

func DecodeBoolHessianV1(o *DecodeContext, reader io.Reader) (bool, error)

func DecodeBoolToHessian3V2

func DecodeBoolToHessian3V2(o *DecodeContext, reader io.Reader, b *bool) error

func DecodeBoolToHessian4V2

func DecodeBoolToHessian4V2(o *DecodeContext, reader io.Reader, b *bool) error

func DecodeBoolToHessianV1

func DecodeBoolToHessianV1(o *DecodeContext, reader io.Reader, b *bool) error

func DecodeDateHessian3V2

func DecodeDateHessian3V2(o *DecodeContext, reader *bufio.Reader) (time.Time, error)

func DecodeDateHessian4V2

func DecodeDateHessian4V2(o *DecodeContext, reader *bufio.Reader) (time.Time, error)

func DecodeDateHessianV1

func DecodeDateHessianV1(o *DecodeContext, reader *bufio.Reader) (time.Time, error)

func DecodeDateToHessian3V2

func DecodeDateToHessian3V2(o *DecodeContext, reader *bufio.Reader, t *time.Time) error

func DecodeDateToHessian4V2

func DecodeDateToHessian4V2(o *DecodeContext, reader *bufio.Reader, t *time.Time) error

func DecodeDateToHessianV1

func DecodeDateToHessianV1(o *DecodeContext, reader *bufio.Reader, t *time.Time) error

func DecodeFloat64Hessian3V2

func DecodeFloat64Hessian3V2(o *DecodeContext, reader *bufio.Reader) (float64, error)

func DecodeFloat64Hessian4V2

func DecodeFloat64Hessian4V2(o *DecodeContext, reader *bufio.Reader) (float64, error)

func DecodeFloat64HessianV1

func DecodeFloat64HessianV1(o *DecodeContext, reader *bufio.Reader) (float64, error)

func DecodeFloat64ToHessian3V2

func DecodeFloat64ToHessian3V2(o *DecodeContext, reader *bufio.Reader, i *float64) error

func DecodeFloat64ToHessian4V2

func DecodeFloat64ToHessian4V2(o *DecodeContext, reader *bufio.Reader, i *float64) error

func DecodeFloat64ToHessianV1

func DecodeFloat64ToHessianV1(o *DecodeContext, reader *bufio.Reader, i *float64) error

func DecodeHessian3V2

func DecodeHessian3V2(o *DecodeContext, reader *bufio.Reader) (interface{}, error)

func DecodeHessian4V2

func DecodeHessian4V2(o *DecodeContext, reader *bufio.Reader) (interface{}, error)

func DecodeHessianV1

func DecodeHessianV1(o *DecodeContext, reader *bufio.Reader) (interface{}, error)

func DecodeInt32Hessian3V2

func DecodeInt32Hessian3V2(o *DecodeContext, reader *bufio.Reader) (int32, error)

func DecodeInt32Hessian4V2

func DecodeInt32Hessian4V2(o *DecodeContext, reader *bufio.Reader) (int32, error)

func DecodeInt32HessianV1

func DecodeInt32HessianV1(o *DecodeContext, reader *bufio.Reader) (int32, error)

func DecodeInt32ToHessian3V2

func DecodeInt32ToHessian3V2(o *DecodeContext, reader *bufio.Reader, i *int32) error

func DecodeInt32ToHessian4V2

func DecodeInt32ToHessian4V2(o *DecodeContext, reader *bufio.Reader, i *int32) error

func DecodeInt32ToHessianV1

func DecodeInt32ToHessianV1(o *DecodeContext, reader *bufio.Reader, i *int32) error

func DecodeInt64Hessian3V2

func DecodeInt64Hessian3V2(o *DecodeContext, reader *bufio.Reader) (int64, error)

func DecodeInt64Hessian4V2

func DecodeInt64Hessian4V2(o *DecodeContext, reader *bufio.Reader) (int64, error)

func DecodeInt64HessianV1

func DecodeInt64HessianV1(o *DecodeContext, reader *bufio.Reader) (int64, error)

func DecodeInt64ToHessian3V2

func DecodeInt64ToHessian3V2(o *DecodeContext, reader *bufio.Reader, i *int64) error

func DecodeInt64ToHessian4V2

func DecodeInt64ToHessian4V2(o *DecodeContext, reader *bufio.Reader, i *int64) error

func DecodeInt64ToHessianV1

func DecodeInt64ToHessianV1(o *DecodeContext, reader *bufio.Reader, i *int64) error

func DecodeListHessian3V2

func DecodeListHessian3V2(o *DecodeContext, reader *bufio.Reader) (interface{}, error)

func DecodeListHessian4V2

func DecodeListHessian4V2(o *DecodeContext, reader *bufio.Reader) (interface{}, error)

func DecodeListHessianV1

func DecodeListHessianV1(o *DecodeContext, reader *bufio.Reader) (interface{}, error)

func DecodeListToHessian3V2

func DecodeListToHessian3V2(o *DecodeContext, reader *bufio.Reader, obj *interface{}) error

func DecodeListToHessian4V2

func DecodeListToHessian4V2(o *DecodeContext, reader *bufio.Reader, obj *interface{}) error

func DecodeListToHessianV1

func DecodeListToHessianV1(o *DecodeContext, reader *bufio.Reader, obj *interface{}) error

func DecodeMapHessian3V2

func DecodeMapHessian3V2(o *DecodeContext, reader *bufio.Reader) (interface{}, error)

func DecodeMapHessian4V2

func DecodeMapHessian4V2(o *DecodeContext, reader *bufio.Reader) (interface{}, error)

func DecodeMapHessianV1

func DecodeMapHessianV1(o *DecodeContext, reader *bufio.Reader) (interface{}, error)

func DecodeNilHessian3V2

func DecodeNilHessian3V2(o *DecodeContext, reader *bufio.Reader) error

func DecodeNilHessian4V2

func DecodeNilHessian4V2(o *DecodeContext, reader *bufio.Reader) error

func DecodeNilHessianV1

func DecodeNilHessianV1(o *DecodeContext, reader *bufio.Reader) error

func DecodeNilToHessian3V2

func DecodeNilToHessian3V2(o *DecodeContext, reader *bufio.Reader) error

func DecodeNilToHessian4V2

func DecodeNilToHessian4V2(o *DecodeContext, reader *bufio.Reader) error

func DecodeNilToHessianV1

func DecodeNilToHessianV1(o *DecodeContext, reader *bufio.Reader) error

func DecodeObjectHessian3V2

func DecodeObjectHessian3V2(o *DecodeContext, reader *bufio.Reader) (interface{}, error)

func DecodeObjectHessian4V2

func DecodeObjectHessian4V2(o *DecodeContext, reader *bufio.Reader) (interface{}, error)

func DecodeObjectHessianV1

func DecodeObjectHessianV1(o *DecodeContext, reader *bufio.Reader) (interface{}, error)

func DecodeObjectHessianV1WithType

func DecodeObjectHessianV1WithType(o *DecodeContext, reader *bufio.Reader) (interface{}, error)

func DecodeObjectToHessian3V2

func DecodeObjectToHessian3V2(o *DecodeContext, reader *bufio.Reader, obj interface{}) error

func DecodeObjectToHessian4V2

func DecodeObjectToHessian4V2(o *DecodeContext, reader *bufio.Reader, obj interface{}) error

func DecodeObjectToHessianV1

func DecodeObjectToHessianV1(o *DecodeContext, reader *bufio.Reader, obj interface{}) error

func DecodeRefHessian3V2

func DecodeRefHessian3V2(o *DecodeContext, reader *bufio.Reader) (interface{}, error)

func DecodeRefHessian4V2

func DecodeRefHessian4V2(o *DecodeContext, reader *bufio.Reader) (interface{}, error)

func DecodeRefHessianV1

func DecodeRefHessianV1(o *DecodeContext, reader *bufio.Reader) (interface{}, error)

func DecodeRefToHessian3V2

func DecodeRefToHessian3V2(o *DecodeContext, reader *bufio.Reader, obj *interface{}) error

func DecodeRefToHessian4V2

func DecodeRefToHessian4V2(o *DecodeContext, reader *bufio.Reader, obj *interface{}) error

func DecodeRefToHessianV1

func DecodeRefToHessianV1(o *DecodeContext, reader *bufio.Reader, obj *interface{}) error

func DecodeStringHessian3V2

func DecodeStringHessian3V2(o *DecodeContext, reader *bufio.Reader) (string, error)

func DecodeStringHessian4V2

func DecodeStringHessian4V2(o *DecodeContext, reader *bufio.Reader) (string, error)

func DecodeStringHessianV1

func DecodeStringHessianV1(o *DecodeContext, reader *bufio.Reader) (string, error)

func DecodeStringToHessian3V2

func DecodeStringToHessian3V2(o *DecodeContext, reader *bufio.Reader, s []byte) ([]byte, error)

DecodeStringToHessian3V2 decodes dst to string.

func DecodeStringToHessian4V2

func DecodeStringToHessian4V2(o *DecodeContext, reader *bufio.Reader, s []byte) ([]byte, error)

DecodeStringToHessian4V2 decodes dst to string.

func DecodeStringToHessianV1

func DecodeStringToHessianV1(o *DecodeContext, reader *bufio.Reader, s []byte) ([]byte, error)

DecodeStringToHessianV1 decodes dst to string.

func DecodeTypeHessian3V2

func DecodeTypeHessian3V2(o *DecodeContext, reader *bufio.Reader) (string, error)

func DecodeTypeHessian4V2

func DecodeTypeHessian4V2(o *DecodeContext, reader *bufio.Reader) (string, error)

func DecodeTypeHessianV1

func DecodeTypeHessianV1(o *DecodeContext, reader *bufio.Reader) (string, error)

func DecodeTypeToHessian3V2

func DecodeTypeToHessian3V2(o *DecodeContext, reader *bufio.Reader, dst []byte) ([]byte, error)

func DecodeTypeToHessian4V2

func DecodeTypeToHessian4V2(o *DecodeContext, reader *bufio.Reader, dst []byte) ([]byte, error)

func DecodeTypeToHessianV1

func DecodeTypeToHessianV1(o *DecodeContext, reader *bufio.Reader, dst []byte) ([]byte, error)

func DecodeTypedMapHessian3V2

func DecodeTypedMapHessian3V2(o *DecodeContext, reader *bufio.Reader) (interface{}, error)

func DecodeTypedMapHessian4V2

func DecodeTypedMapHessian4V2(o *DecodeContext, reader *bufio.Reader) (interface{}, error)

func DecodeTypedMapHessianV1

func DecodeTypedMapHessianV1(o *DecodeContext, reader *bufio.Reader) (interface{}, error)

func DecodeTypedMapToHessian3V2

func DecodeTypedMapToHessian3V2(o *DecodeContext, reader *bufio.Reader, obj *interface{}) error

func DecodeTypedMapToHessian4V2

func DecodeTypedMapToHessian4V2(o *DecodeContext, reader *bufio.Reader, obj *interface{}) error

func DecodeTypedMapToHessianV1

func DecodeTypedMapToHessianV1(o *DecodeContext, reader *bufio.Reader, obj *interface{}) error

func DecodeUntypedMapHessian3V2

func DecodeUntypedMapHessian3V2(o *DecodeContext, reader *bufio.Reader) (interface{}, error)

func DecodeUntypedMapHessian4V2

func DecodeUntypedMapHessian4V2(o *DecodeContext, reader *bufio.Reader) (interface{}, error)

func DecodeUntypedMapHessianV1

func DecodeUntypedMapHessianV1(o *DecodeContext, reader *bufio.Reader) (interface{}, error)

func DecodeUntypedMapToHessian3V2

func DecodeUntypedMapToHessian3V2(o *DecodeContext, reader *bufio.Reader, obj *interface{}) error

func DecodeUntypedMapToHessian4V2

func DecodeUntypedMapToHessian4V2(o *DecodeContext, reader *bufio.Reader, obj *interface{}) error

func DecodeUntypedMapToHessianV1

func DecodeUntypedMapToHessianV1(o *DecodeContext, reader *bufio.Reader, obj *interface{}) error

func EncodeBinaryToHessian3V2

func EncodeBinaryToHessian3V2(o *EncodeContext, dst []byte, b []byte) ([]byte, error)

func EncodeBinaryToHessian4V2

func EncodeBinaryToHessian4V2(o *EncodeContext, dst []byte, b []byte) ([]byte, error)

EncodeBinaryToHessian4V2 encodes binary to dst.

binary0000 ::= x41 b1 b0 <binary-data> binary # non-final chunk 000000000000::= 'B' b1 b0 <binary-data>00000000# final chunk 000000000000::= [x20-x2f] <binary-data>00000000# binary data of 00000000000000000000000000000000000000000000 # length 0-15 000000000000::= [x34-x37] <binary-data>00000000# binary data of 00000000000000000000000000000000000000000000 # length 0-1023

Binary data is encoded in chunks. The octet x42 ('B') encodes the final chunk and x62 ('b') represents any non-final chunk. Each chunk has a 16-bit length value.

len = 256 * b1 + b0

func EncodeBinaryToHessianV1

func EncodeBinaryToHessianV1(o *EncodeContext, dst []byte, b []byte) ([]byte, error)

func EncodeBinaryToJSON

func EncodeBinaryToJSON(ctx *JSONEncodeContext, dst []byte, b []byte) ([]byte, error)

EncodeBinaryToJSON encodes []byte to dst.

func EncodeBoolToHessian3V2

func EncodeBoolToHessian3V2(o *EncodeContext, dst []byte, b bool) ([]byte, error)

func EncodeBoolToHessian4V2

func EncodeBoolToHessian4V2(o *EncodeContext, dst []byte, b bool) ([]byte, error)

EncodeBoolToHessian4V2 encodes bool to dst. The octet 'F' represents false and the octet T represents true. boolean ::= T

::= F

func EncodeBoolToHessianV1

func EncodeBoolToHessianV1(o *EncodeContext, dst []byte, b bool) ([]byte, error)

func EncodeBoolToJSON

func EncodeBoolToJSON(ctx *JSONEncodeContext, dst []byte, b bool) ([]byte, error)

EncodeBoolToJSON encodes bool to dst.

func EncodeClassDefinitionToHessian3V2

func EncodeClassDefinitionToHessian3V2(o *EncodeContext, dst []byte, classname string,
	fields []string) ([]byte, error)

func EncodeClassDefinitionToHessian4V2

func EncodeClassDefinitionToHessian4V2(o *EncodeContext, dst []byte, classname string,
	fields []string) ([]byte, error)

func EncodeClassDefinitionToHessianV1

func EncodeClassDefinitionToHessianV1(o *EncodeContext, dst []byte, classname string, fields []string) ([]byte, error)

func EncodeDateToHessian3V2

func EncodeDateToHessian3V2(o *EncodeContext, dst []byte, t time.Time) ([]byte, error)

func EncodeDateToHessian4V2

func EncodeDateToHessian4V2(o *EncodeContext, dst []byte, t time.Time) ([]byte, error)

EncodeDateToHessian4V2 encodes data to dst. date ::= x4a b7 b6 b5 b4 b3 b2 b1 b0

::= x4b b4 b3 b2 b1 b0

Date represented by a 64-bit long of milliseconds since Jan 1 1970 00:00H, UTC.

func EncodeDateToHessianV1

func EncodeDateToHessianV1(o *EncodeContext, dst []byte, t time.Time) ([]byte, error)

func EncodeFloat32ToJSON

func EncodeFloat32ToJSON(ctx *JSONEncodeContext, dst []byte, f float32) ([]byte, error)

EncodeFloat32ToJSON encodes float32 to dst.

func EncodeFloat64ToHessian3V2

func EncodeFloat64ToHessian3V2(o *EncodeContext, dst []byte, d float64) ([]byte, error)

EncodeFloat64ToHessian3V2 encodes float64 to dst with hessian3 v2 protocol.

func EncodeFloat64ToHessian4V2

func EncodeFloat64ToHessian4V2(o *EncodeContext, dst []byte, d float64) ([]byte, error)

EncodeFloat64ToHessian4V2 encodes float64 to dst. A 64-bit IEEE floating pointer number.

double ::= D b7 b6 b5 b4 b3 b2 b1 b0

::= x5b
::= x5c
::= x5d b0
::= x5e b1 b0
::= x5f b3 b2 b1 b0

func EncodeFloat64ToHessianV1

func EncodeFloat64ToHessianV1(o *EncodeContext, dst []byte, d float64) ([]byte, error)

EncodeFloat64ToHessianV1 encodes float64 to dst with hessian3 v2 protocol.

func EncodeFloat64ToJSON

func EncodeFloat64ToJSON(ctx *JSONEncodeContext, dst []byte, f float64) ([]byte, error)

EncodeFloat64ToJSON encodes float64 to dst.

func EncodeHessian3V2

func EncodeHessian3V2(o *EncodeContext, value interface{}) ([]byte, error)

EncodeHessian3V2 encodes the interface to dst.

func EncodeHessian4V2

func EncodeHessian4V2(o *EncodeContext, value interface{}) ([]byte, error)

EncodeHessian4V2 encodes the interface to dst.

func EncodeHessianV1

func EncodeHessianV1(o *EncodeContext, value interface{}) ([]byte, error)

EncodeHessianV1 encodes the interface to dst.

func EncodeInt32RefToHessianV1

func EncodeInt32RefToHessianV1(o *EncodeContext, dst []byte, n int32) ([]byte, error)

EncodeInt32RefToHessianV1 encodes int32 to dst with hessian3 v2 protocol.

func EncodeInt32ToHessian3V2

func EncodeInt32ToHessian3V2(o *EncodeContext, dst []byte, n int32) ([]byte, error)

EncodeInt32ToHessian3V2 encodes int32 to dst with hessian3 v2 protocol.

func EncodeInt32ToHessian4V2

func EncodeInt32ToHessian4V2(o *EncodeContext, dst []byte, n int32) ([]byte, error)

EncodeInt32ToHessian4V2 encodes int32 to dst.

int ::= 'I' b3 b2 b1 b0 0000 ::= [x80-xbf] 0000 ::= [xc0-xcf] b0 0000 ::= [xd0-xd7] b1 b0

A 32-bit signed integer. An integer is represented by the octet x49 ('I') followed by the 4 octets of the integer in big-endian order. value = (b3 << 24) + (b2 << 16) + (b1 << 8) + b0;

func EncodeInt32ToHessianV1

func EncodeInt32ToHessianV1(o *EncodeContext, dst []byte, n int32) ([]byte, error)

EncodeInt32ToHessianV1 encodes int32 to dst with hessian3 v2 protocol.

func EncodeInt32ToJSON

func EncodeInt32ToJSON(ctx *JSONEncodeContext, dst []byte, i int32) ([]byte, error)

EncodeInt32ToJSON encodes in32 to dst.

func EncodeInt64ToHessian3V2

func EncodeInt64ToHessian3V2(o *EncodeContext, dst []byte, n int64) ([]byte, error)

EncodeInt64ToHessian3V2 encodes int64 to dst with hessian3 v2 protocol.

func EncodeInt64ToHessian4V2

func EncodeInt64ToHessian4V2(o *EncodeContext, dst []byte, n int64) ([]byte, error)

EncodeInt64ToHessian4V2 encodes int64 to dst.

long ::= L b7 b6 b5 b4 b3 b2 b1 b0 0000 ::= [xd8-xef] 0000 ::= [xf0-xff] b0 0000 ::= [x38-x3f] b1 b0 0000 ::= x4c b3 b2 b1 b0 A 64-bit signed integer. An long is represented by the octet x4c ('L' ) followed by the 8-bytes of the integer in big-endian order.

func EncodeInt64ToHessianV1

func EncodeInt64ToHessianV1(o *EncodeContext, dst []byte, n int64) ([]byte, error)

EncodeInt64ToHessianV1 encodes int64 to dst with hessian3 v2 protocol.

func EncodeInt64ToJSON

func EncodeInt64ToJSON(ctx *JSONEncodeContext, dst []byte, i int64) ([]byte, error)

EncodeInt64ToJSON encodes in64 to dst.

func EncodeInterfaceInterfaceMapToJSON

func EncodeInterfaceInterfaceMapToJSON(ctx *JSONEncodeContext, dst []byte,
	m map[interface{}]interface{}) ([]byte, error)

EncodeInterfaceInterfaceMapToJSON encodes reflect.Value to dst.

func EncodeInterfaceSliceToJSON

func EncodeInterfaceSliceToJSON(ctx *JSONEncodeContext, dst []byte, m []interface{}) ([]byte, error)

EncodeInterfaceSliceToJSON encodes reflect.Value to dst.

func EncodeInterfaceSliceValueToJSON

func EncodeInterfaceSliceValueToJSON(ctx *JSONEncodeContext, dst []byte, value reflect.Value) ([]byte, error)

EncodeInterfaceSliceValueToJSON encodes reflect.Value to dst.

func EncodeJSONArrayToHessian

func EncodeJSONArrayToHessian(ctx *JSONEncodeContext, encoder *Encoder, v *fastjson.Value, typ string) error

EncodeJSONArrayToHessian encodes JSON Array to hessian encoder.

func EncodeJSONBoolToHessian

func EncodeJSONBoolToHessian(ctx *JSONEncodeContext, encoder *Encoder, b bool) error

EncodeJSONBoolToHessian encodes JSON boolean to hessian encoder.

func EncodeJSONBytes

func EncodeJSONBytes(ctx *JSONEncodeContext, encoder *Encoder, v *fastjson.Value, classname string) error

EncodeJSONBytes encodes JSON bytes(base64 encoding) to hessian encoder.

func EncodeJSONDate

func EncodeJSONDate(ctx *JSONEncodeContext, encoder *Encoder, v *fastjson.Value, classname string) error

EncodeJSONDate encodes JSON boolean to hessian encoder.

func EncodeJSONFloat64

func EncodeJSONFloat64(ctx *JSONEncodeContext, encoder *Encoder, v *fastjson.Value, classname string) error

EncodeJSONFloat64 encodes JSON float64 to hessian encoder.

func EncodeJSONInt32

func EncodeJSONInt32(ctx *JSONEncodeContext, encoder *Encoder, v *fastjson.Value, classname string) error

EncodeJSONInt32 encodes JSON int32 to hessian encoder.

func EncodeJSONInt64

func EncodeJSONInt64(ctx *JSONEncodeContext, encoder *Encoder, v *fastjson.Value, classname string) error

EncodeJSONInt64 encodes JSON int64 to hessian encoder.

func EncodeJSONNULLToHessian

func EncodeJSONNULLToHessian(ctx *JSONEncodeContext, encoder *Encoder, v *fastjson.Value) error

EncodeJSONNULLToHessian encodes JSON NULL to hessian encoder.

func EncodeJSONNumberToHessian

func EncodeJSONNumberToHessian(ctx *JSONEncodeContext, encoder *Encoder, v *fastjson.Value) error

EncodeJSONNumberToHessian encodes JSON number to hessian encoder.

func EncodeJSONObjectToHessian

func EncodeJSONObjectToHessian(ctx *JSONEncodeContext, encoder *Encoder, v *fastjson.Value) error

EncodeJSONObjectToHessian encodes JSON Object to hessian encoder.

func EncodeJSONStringToHessian

func EncodeJSONStringToHessian(ctx *JSONEncodeContext, encoder *Encoder, v *fastjson.Value) error

EncodeJSONStringToHessian encodes JSON string to hessian encoder.

func EncodeJSONToHessian

func EncodeJSONToHessian(ctx *JSONEncodeContext, encoder *Encoder, v *fastjson.Value) (err error)

EncodeJSONToHessian transforms fastjson to hessian encoder.

func EncodeListBeginToHessian3V2

func EncodeListBeginToHessian3V2(o *EncodeContext, dst []byte, length int, typ string) ([]byte, bool, error)

func EncodeListBeginToHessian4V2

func EncodeListBeginToHessian4V2(o *EncodeContext, dst []byte, length int, typ string) ([]byte, bool, error)

EncodeListBeginToHessian4V2 encodes slice to dst.

list ::= x55 type value* 'Z' # variable-length list

::= 'V' type int value*   # fixed-length list
::= x57 value* 'Z'        # variable-length untyped list
::= x58 int value*        # fixed-length untyped list
::= [x70-77] type value*  # fixed-length typed list
::= [x78-7f] value*       # fixed-length untyped list

func EncodeListBeginToHessianV1

func EncodeListBeginToHessianV1(o *EncodeContext, dst []byte, length int, typ string) ([]byte, bool, error)

func EncodeListEndToHessian3V2

func EncodeListEndToHessian3V2(o *EncodeContext, dst []byte, end bool) ([]byte, error)

func EncodeListEndToHessian4V2

func EncodeListEndToHessian4V2(o *EncodeContext, dst []byte, end bool) ([]byte, error)

func EncodeListEndToHessianV1

func EncodeListEndToHessianV1(o *EncodeContext, dst []byte, end bool) ([]byte, error)

func EncodeListToHessian3V2

func EncodeListToHessian3V2(o *EncodeContext, dst []byte, obj interface{}) ([]byte, error)

func EncodeListToHessian4V2

func EncodeListToHessian4V2(o *EncodeContext, dst []byte, obj interface{}) ([]byte, error)

EncodeListToHessian4V2 encodes list to dst. list ::= x55 type value* 'Z' # variable-length list

::= 'V' type int value*   # fixed-length list
::= x57 value* 'Z'        # variable-length untyped list
::= x58 int value*        # fixed-length untyped list
::= [x70-77] type value*  # fixed-length typed list
::= [x78-7f] value*       # fixed-length untyped list

func EncodeListToHessianV1

func EncodeListToHessianV1(o *EncodeContext, dst []byte, obj interface{}) ([]byte, error)

func EncodeListWithLengthToHessian4V2

func EncodeListWithLengthToHessian4V2(o *EncodeContext, dst []byte, length int,
	fn func(i int, o *EncodeContext, dst []byte) ([]byte, error)) ([]byte, error)

func EncodeMapBeginToHessian3V2

func EncodeMapBeginToHessian3V2(o *EncodeContext, dst []byte, typ string) ([]byte, error)

func EncodeMapBeginToHessian4V2

func EncodeMapBeginToHessian4V2(o *EncodeContext, dst []byte, typ string) ([]byte, error)

EncodeMapBeginToHessian4V2 encodes map to dst.

map = new HashMap(); map.put(new Integer(1), "fee"); map.put(new Integer(16), "fie"); map.put(new Integer(256), "foe"); j --- H # untyped map (HashMap for Java)

x91       # 1
x03 fee   # "fee"
xa0       # 16
x03 fie   # "fie"
xc9 x00   # 256
x03 foe   # "foe"
Z

func EncodeMapBeginToHessianV1

func EncodeMapBeginToHessianV1(o *EncodeContext, dst []byte, typ string) ([]byte, error)

func EncodeMapEndToHessian3V2

func EncodeMapEndToHessian3V2(o *EncodeContext, dst []byte) ([]byte, error)

func EncodeMapEndToHessian4V2

func EncodeMapEndToHessian4V2(o *EncodeContext, dst []byte) ([]byte, error)

func EncodeMapEndToHessianV1

func EncodeMapEndToHessianV1(o *EncodeContext, dst []byte) ([]byte, error)

func EncodeMapToHessian3V2

func EncodeMapToHessian3V2(o *EncodeContext, dst []byte, obj interface{}) ([]byte, error)

EncodeMapToHessian3V2 encodes map to dst.

func EncodeMapToHessian4V2

func EncodeMapToHessian4V2(o *EncodeContext, dst []byte, obj interface{}) ([]byte, error)

EncodeMapToHessian4V2 encodes map to dst.

func EncodeMapToHessianV1

func EncodeMapToHessianV1(o *EncodeContext, dst []byte, obj interface{}) ([]byte, error)

EncodeMapToHessianV1 encodes map to dst.

func EncodeNilToHessian3V2

func EncodeNilToHessian3V2(e *EncodeContext, dst []byte) ([]byte, error)

EncodeNilToHessian3V2 encoddes nil to dst with hessian3 v2 protocol.

func EncodeNilToHessian4V2

func EncodeNilToHessian4V2(o *EncodeContext, dst []byte) ([]byte, error)

EncodeNilToHessian4V2 encodes nil to dst.

null ::= N

func EncodeNilToHessianV1

func EncodeNilToHessianV1(e *EncodeContext, dst []byte) ([]byte, error)

EncodeNilToHessianV1 encoddes nil to dst with hessian3 v2 protocol.

func EncodeNilToJSON

func EncodeNilToJSON(ctx *JSONEncodeContext, dst []byte) ([]byte, error)

EncodeNilToJSON encodes nil to dst.

func EncodeObjectHessian3V2

func EncodeObjectHessian3V2(o *EncodeContext, obj interface{}) ([]byte, error)

func EncodeObjectHessian4V2

func EncodeObjectHessian4V2(o *EncodeContext, obj interface{}) ([]byte, error)

func EncodeObjectToHessian3V2

func EncodeObjectToHessian3V2(o *EncodeContext, dst []byte, obj interface{}) ([]byte, error)

func EncodeObjectToHessian4V2

func EncodeObjectToHessian4V2(o *EncodeContext, dst []byte, obj interface{}) ([]byte, error)

func EncodeObjectToHessianV1

func EncodeObjectToHessianV1(o *EncodeContext, dst []byte, obj interface{}) ([]byte, error)

func EncodeRawJSONBytesToHessian

func EncodeRawJSONBytesToHessian(ctx *JSONEncodeContext, encoder *Encoder, json []byte) error

EncodeRawJSONBytesToHessian transforms the json bytes to hessian encoder.

func EncodeRawJSONStringToHessian

func EncodeRawJSONStringToHessian(ctx *JSONEncodeContext, encoder *Encoder, json string) error

EncodeRawJSONStringToHessian transforms the json string to hessian encoder.

func EncodeRef4V2

func EncodeRef4V2(o *EncodeContext, dst []byte, refid uint32) ([]byte, error)

EncodeRef4V2 encodes refid to dst.

ref ::= x51 int

func EncodeRefHessian3V2

func EncodeRefHessian3V2(o *EncodeContext, dst []byte, refid uint32) ([]byte, error)

EncodeRefHessian3V2 encodes refid to dst.

func EncodeRefHessianV1

func EncodeRefHessianV1(o *EncodeContext, dst []byte, refid uint32) ([]byte, error)

EncodeRefHessianV1 encodes refid to dst.

func EncodeStringInterfaceMapToJSON

func EncodeStringInterfaceMapToJSON(ctx *JSONEncodeContext, dst []byte, m map[string]interface{}) ([]byte, error)

EncodeStringInterfaceMapToJSON encodes map[string]interface{} to dst.

func EncodeStringInterfaceMapValueToJSON

func EncodeStringInterfaceMapValueToJSON(ctx *JSONEncodeContext, dst []byte, value reflect.Value) ([]byte, error)

EncodeStringInterfaceMapValueToJSON encodes reflect.Value to dst.

func EncodeStringToHessian3V2

func EncodeStringToHessian3V2(o *EncodeContext, dst []byte, value string) ([]byte, error)

func EncodeStringToHessian4V2

func EncodeStringToHessian4V2(o *EncodeContext, dst []byte, value string) ([]byte, error)

EncodeStringToHessian4V2 encodes string to dst.

# UTF-8 encoded character string split into 64k chunks string0000 ::= x52 b1 b0 <utf8-data> string # non-final chunk 000000000000::= 'S' b1 b0 <utf8-data>00000000 # string of length 00000000000000000000000000000000000000000000 # 0-65535 000000000000::= [x00-x1f] <utf8-data>00000000 # string of length 00000000000000000000000000000000000000000000 # 0-31 000000000000::= [x30-x34] <utf8-data>00000000 # string of length 00000000000000000000000000000000000000000000 # 0-1023 A 16-bit unicode character string encoded in UTF-8. Strings are encoded in chunks. x53 ('S') represents the final chunk and x52 ('R') represents any non-final chunk. Each chunk has a 16-bit unsigned integer length value.

The length is the number of 16-bit characters, which may be different than the number of bytes.

String chunks may not split surrogate pairs.

func EncodeStringToHessianV1

func EncodeStringToHessianV1(o *EncodeContext, dst []byte, value string) ([]byte, error)

func EncodeStringToJSON

func EncodeStringToJSON(ctx *JSONEncodeContext, dst []byte, s string) ([]byte, error)

EncodeStringToJSON encodes string to dst.

func EncodeStructValueToJSON

func EncodeStructValueToJSON(ctx *JSONEncodeContext, dst []byte, typ reflect.Type,
	value reflect.Value) ([]byte, error)

EncodeStructValueToJSON encodes reflect.Value to dst.

func EncodeToHessian3V2

func EncodeToHessian3V2(o *EncodeContext, dst []byte, value interface{}) ([]byte, error)

EncodeToHessian3V2 encodes the interface to dst.

func EncodeToHessian4V2

func EncodeToHessian4V2(o *EncodeContext, dst []byte, value interface{}) ([]byte, error)

EncodeToHessian4V2 encodes the interface to dst.

func EncodeToHessianV1

func EncodeToHessianV1(o *EncodeContext, dst []byte, value interface{}) ([]byte, error)

EncodeToHessianV1 encodes the interface to dst.

func EncodeToJSON

func EncodeToJSON(ctx *JSONEncodeContext, dst []byte, obj interface{}) ([]byte, error)

EncodeToJSON encodes the interface to dst.

func EncodeValueToHessian3v2

func EncodeValueToHessian3v2(o *EncodeContext, dst []byte, value reflect.Value) ([]byte, error)

EncodeValueToHessian3v2 encodes reflect.Value to dst.

func EncodeValueToHessian4V2

func EncodeValueToHessian4V2(o *EncodeContext, dst []byte, value reflect.Value) ([]byte, error)

EncodeValueToHessian4V2 encodes reflect.Value to dst.

func EncodeValueToHessianV1

func EncodeValueToHessianV1(o *EncodeContext, dst []byte, value reflect.Value) ([]byte, error)

EncodeValueToHessianV1 encodes reflect.Value to dst.

func EncodeValueToJSON

func EncodeValueToJSON(ctx *JSONEncodeContext, dst []byte, value reflect.Value) ([]byte, error)

EncodeValueToJSON encodes reflect.Value to dst.

func Register

func Register(name string, value interface{}) (bool, error)

func RegisterBuiltinJavaClasses

func RegisterBuiltinJavaClasses()

RegisterBuiltinJavaClasses registers java classes.

nolint

func RegisterJSONToHessianEncoder

func RegisterJSONToHessianEncoder(classname string, e JSONToHessianEncoder)

RegisterJSONToHessianEncoder registers the JSONToHessianEncoder to global.

func RegisterJavaClass

func RegisterJavaClass(value JavaClassNameGetter) (bool, error)

func RegisterSofaRPCJavaClasses

func RegisterSofaRPCJavaClasses()

RegisterSofaRPCJavaClasses registers the java classes.

nolint

func RegisterToJSONEncoder

func RegisterToJSONEncoder(classname string, e ToJSONEncoder)

RegisterToJSONEncoder registers the ToJSONEncoder to global.

func ReleaseBytesBufioReader

func ReleaseBytesBufioReader(bbr *BytesBufioReader)

func ReleaseHessianDecodeContext

func ReleaseHessianDecodeContext(hd *DecodeContext)

ReleaseHessianDecodeContext releases decode context to sync.pool.

func ReleaseHessianDecoder

func ReleaseHessianDecoder(hd *Decoder)

ReleaseHessianDecoder releases decoder to sync.pool.

func ReleaseHessianEncodeContext

func ReleaseHessianEncodeContext(hc *EncodeContext)

ReleaseHessianEncodeContext releases encode context to sync.pool.

func ReleaseHessianEncoder

func ReleaseHessianEncoder(he *Encoder)

ReleaseHessianEncoder releases decoder to sync.pool.

func ReleaseJSONContext

func ReleaseJSONContext(jctx *JSONEncodeContext)

ReleaseJSONContext releases json context to sync.pool.

Types

type BytesBufioReader

type BytesBufioReader struct {
	// contains filtered or unexported fields
}

func AcquireBytesBufioReader

func AcquireBytesBufioReader(b []byte) *BytesBufioReader

func (*BytesBufioReader) GetBufioReader

func (bbr *BytesBufioReader) GetBufioReader() *bufio.Reader

func (*BytesBufioReader) Reset

func (bbr *BytesBufioReader) Reset(b []byte)

type ClassDefinition

type ClassDefinition struct {
	// contains filtered or unexported fields
}

type ClassRegistry

type ClassRegistry struct {
	// contains filtered or unexported fields
}

func NewClassRegistry

func NewClassRegistry() *ClassRegistry

func (*ClassRegistry) Load

func (tr *ClassRegistry) Load(name string) (*ClassTypeSchema, bool)

func (*ClassRegistry) Register

func (tr *ClassRegistry) Register(name string, value interface{}) (bool, error)

func (*ClassRegistry) RegisterJavaClass

func (tr *ClassRegistry) RegisterJavaClass(value JavaClassNameGetter) (bool, error)

type ClassTypeSchema

type ClassTypeSchema struct {
	// contains filtered or unexported fields
}

func Load

func Load(name string) (*ClassTypeSchema, bool)

type DecodeClassRefs

type DecodeClassRefs struct {
	// contains filtered or unexported fields
}

func NewDecodeClassRefs

func NewDecodeClassRefs() *DecodeClassRefs

func (*DecodeClassRefs) Append

func (j *DecodeClassRefs) Append(cf ClassDefinition)

func (*DecodeClassRefs) Get

func (j *DecodeClassRefs) Get(id int) (ClassDefinition, bool)

func (*DecodeClassRefs) Reset

func (j *DecodeClassRefs) Reset()

type DecodeContext

type DecodeContext struct {
	// contains filtered or unexported fields
}

DecodeContext holds the context of decoding.

func AcquireHessianDecodeContext

func AcquireHessianDecodeContext() *DecodeContext

AcquireHessianDecodeContext acquires decode context from sync.pool.

func NewDecodeContext

func NewDecodeContext() *DecodeContext

func (*DecodeContext) DisallowMissingField

func (d *DecodeContext) DisallowMissingField() *DecodeContext

func (*DecodeContext) GetMaxListLength

func (d *DecodeContext) GetMaxListLength() int

func (*DecodeContext) GetMaxObjectFields

func (d *DecodeContext) GetMaxObjectFields() int

func (*DecodeContext) GetVersion

func (d *DecodeContext) GetVersion() Version

func (*DecodeContext) Reset

func (d *DecodeContext) Reset()

func (*DecodeContext) SetClassRegistry

func (d *DecodeContext) SetClassRegistry(cr *ClassRegistry) *DecodeContext

func (*DecodeContext) SetClassrefs

func (d *DecodeContext) SetClassrefs(refs *DecodeClassRefs) *DecodeContext

func (*DecodeContext) SetMaxDepth

func (d *DecodeContext) SetMaxDepth(depth int) *DecodeContext

func (*DecodeContext) SetMaxListLength

func (d *DecodeContext) SetMaxListLength(m int) *DecodeContext

func (*DecodeContext) SetObjectrefs

func (d *DecodeContext) SetObjectrefs(refs *DecodeObjectRefs) *DecodeContext

func (*DecodeContext) SetTracer

func (d *DecodeContext) SetTracer(tracer Tracer) *DecodeContext

func (*DecodeContext) SetTyperefs

func (d *DecodeContext) SetTyperefs(refs *DecodeTypeRefs) *DecodeContext

func (*DecodeContext) SetVersion

func (d *DecodeContext) SetVersion(ver Version) *DecodeContext

type DecodeObjectRefs

type DecodeObjectRefs struct {
	// contains filtered or unexported fields
}

func NewDecodeObjectRefs

func NewDecodeObjectRefs() *DecodeObjectRefs

func (*DecodeObjectRefs) Append

func (t *DecodeObjectRefs) Append(obj interface{})

func (DecodeObjectRefs) Get

func (t DecodeObjectRefs) Get(id int) (interface{}, bool)

func (DecodeObjectRefs) Len

func (t DecodeObjectRefs) Len() int

func (*DecodeObjectRefs) Reset

func (t *DecodeObjectRefs) Reset()

type DecodeTypeRefs

type DecodeTypeRefs struct {
	// contains filtered or unexported fields
}

func NewDecodeTypeRefs

func NewDecodeTypeRefs() *DecodeTypeRefs

func (*DecodeTypeRefs) Append

func (t *DecodeTypeRefs) Append(typ string)

func (DecodeTypeRefs) Get

func (t DecodeTypeRefs) Get(id int) (string, bool)

func (DecodeTypeRefs) Len

func (t DecodeTypeRefs) Len() int

func (*DecodeTypeRefs) Reset

func (t *DecodeTypeRefs) Reset()

type Decoder

type Decoder struct {
	// contains filtered or unexported fields
}

Decoder reads the hessian type from reader.

func AcquireHessianDecoder

func AcquireHessianDecoder(ctx *DecodeContext, reader io.Reader) *Decoder

AcquireHessianDecoder acquires decoder from sync.pool.

func NewDecoder

func NewDecoder(ctx *DecodeContext, reader io.Reader) *Decoder

func (*Decoder) Decode

func (d *Decoder) Decode() (interface{}, error)

func (*Decoder) DecodeBinary

func (d *Decoder) DecodeBinary() ([]byte, error)

func (*Decoder) DecodeDate

func (d *Decoder) DecodeDate() (time.Time, error)

func (*Decoder) DecodeFloat64

func (d *Decoder) DecodeFloat64() (float64, error)

func (*Decoder) DecodeInt32

func (d *Decoder) DecodeInt32() (int32, error)

func (*Decoder) DecodeInt64

func (d *Decoder) DecodeInt64() (int64, error)

func (*Decoder) DecodeList

func (d *Decoder) DecodeList() (interface{}, error)

func (*Decoder) DecodeMap

func (d *Decoder) DecodeMap() (interface{}, error)

func (*Decoder) DecodeNil

func (d *Decoder) DecodeNil() error

func (*Decoder) DecodeObject

func (d *Decoder) DecodeObject() (interface{}, error)

func (*Decoder) DecodeString

func (d *Decoder) DecodeString() (string, error)

func (*Decoder) DecodeToFloat64

func (d *Decoder) DecodeToFloat64(f *float64) error

func (*Decoder) DecodeToInt32

func (d *Decoder) DecodeToInt32(i *int32) error

func (*Decoder) DecodeToInt64

func (d *Decoder) DecodeToInt64(i *int64) error

func (*Decoder) DecodeToObject

func (d *Decoder) DecodeToObject(obj interface{}) error

func (*Decoder) DecodeToString

func (d *Decoder) DecodeToString(s []byte) ([]byte, error)

func (*Decoder) GetContext

func (d *Decoder) GetContext() *DecodeContext

func (*Decoder) GetReader

func (d *Decoder) GetReader() *bufio.Reader

func (*Decoder) Reset

func (d *Decoder) Reset(reader io.Reader)

Reset resets the decoder status.

func (*Decoder) ResetWithContext

func (d *Decoder) ResetWithContext(ctx *DecodeContext, reader io.Reader)

ResetWithContext resets the decoder status with context.

type DummyTracer

type DummyTracer struct{}

func NewDummyTracer

func NewDummyTracer() *DummyTracer

func (*DummyTracer) OnTraceStart

func (t *DummyTracer) OnTraceStart(event string)

func (*DummyTracer) OnTraceStop

func (t *DummyTracer) OnTraceStop(event string)

type EncodeClassrefs

type EncodeClassrefs struct {
	// contains filtered or unexported fields
}

func NewEncodeClassrefs

func NewEncodeClassrefs() *EncodeClassrefs

func (*EncodeClassrefs) Add

func (c *EncodeClassrefs) Add(cls interface{}) (ref int, referenced bool)

func (*EncodeClassrefs) Get

func (c *EncodeClassrefs) Get(cls interface{}) int

func (*EncodeClassrefs) Reset

func (c *EncodeClassrefs) Reset()

type EncodeContext

type EncodeContext struct {
	// contains filtered or unexported fields
}

EncodeContext holds the context of encoding.

func AcquireHessianEncodeContext

func AcquireHessianEncodeContext() *EncodeContext

AcquireHessianEncodeContext acquires encode context from sync.pool.

func NewEncodeContext

func NewEncodeContext() *EncodeContext

NewEncodeContext returns a new EncodeContext.

func (*EncodeContext) DisableObjectrefs

func (e *EncodeContext) DisableObjectrefs() *EncodeContext

func (*EncodeContext) GetVersion

func (e *EncodeContext) GetVersion() Version

func (*EncodeContext) Reset

func (e *EncodeContext) Reset()

Reset resets the context.

func (*EncodeContext) SetClassrefs

func (e *EncodeContext) SetClassrefs(ref *EncodeClassrefs) *EncodeContext

func (*EncodeContext) SetLessFunc

func (e *EncodeContext) SetLessFunc(fn func(keyi, keyj, valuei, valuej interface{}) bool) *EncodeContext

func (*EncodeContext) SetMaxDepth

func (e *EncodeContext) SetMaxDepth(depth int) *EncodeContext

func (*EncodeContext) SetObjectrefs

func (e *EncodeContext) SetObjectrefs(ref *EncodeObjectrefs) *EncodeContext

func (*EncodeContext) SetTracer

func (e *EncodeContext) SetTracer(tracer Tracer) *EncodeContext

func (*EncodeContext) SetTyperefs

func (e *EncodeContext) SetTyperefs(ref *EncodeTypeRefs) *EncodeContext

func (*EncodeContext) SetVersion

func (e *EncodeContext) SetVersion(ver Version) *EncodeContext

SetVersion sets the version to encode.

type EncodeObjectrefs

type EncodeObjectrefs struct {
	// contains filtered or unexported fields
}

func NewEncodeObjectrefs

func NewEncodeObjectrefs() *EncodeObjectrefs

func (*EncodeObjectrefs) Add

func (c *EncodeObjectrefs) Add(obj interface{}) int

func (*EncodeObjectrefs) Get

func (c *EncodeObjectrefs) Get(obj interface{}) int

func (*EncodeObjectrefs) Reset

func (c *EncodeObjectrefs) Reset()

type EncodeTypeRefs

type EncodeTypeRefs struct {
	// contains filtered or unexported fields
}

func NewEncodeTyperefs

func NewEncodeTyperefs() *EncodeTypeRefs

func (*EncodeTypeRefs) Get

func (e *EncodeTypeRefs) Get(typ string) (int, bool)

func (*EncodeTypeRefs) Reset

func (e *EncodeTypeRefs) Reset()

func (*EncodeTypeRefs) Set

func (e *EncodeTypeRefs) Set(typ string)

type Encoder

type Encoder struct {
	// contains filtered or unexported fields
}

Encoder writes hessian type to underlying buffer.

func AcquireHessianEncoder

func AcquireHessianEncoder(ctx *EncodeContext) *Encoder

AcquireHessianEncoder acquires encoder from sync.pool.

func NewEncoder

func NewEncoder(o *EncodeContext) *Encoder

NewEncoder returns the encoder.

func (*Encoder) Bytes

func (e *Encoder) Bytes() []byte

Bytes returns the encoded bytes.

func (*Encoder) Encode

func (e *Encoder) Encode(i interface{}) (err error)

Encode encodes the interface to encoder.

Encode cannot represent cyclic data structures. Passing cyclic data structures will result in panic.

func (*Encoder) EncodeBinary

func (e *Encoder) EncodeBinary(b []byte) (err error)

EncodeBinary encodes []byte to encoder.

func (*Encoder) EncodeBool

func (e *Encoder) EncodeBool(b bool) (err error)

EncodeBool encodes bool to encoder.

func (*Encoder) EncodeBytes

func (e *Encoder) EncodeBytes(b []byte)

EncodeBytes encodes bytes to encoder.

func (*Encoder) EncodeClassDefinition

func (e *Encoder) EncodeClassDefinition(typ string, fields []string) (err error)

func (*Encoder) EncodeDate

func (e *Encoder) EncodeDate(t time.Time) (err error)

EncodeDate encodes time.Time to encoder.

func (*Encoder) EncodeFastJSON

func (e *Encoder) EncodeFastJSON(ctx *JSONEncodeContext, j *fastjson.Value) error

EncodeFastJSON encodes fastjson to dst.

func (*Encoder) EncodeFloat64

func (e *Encoder) EncodeFloat64(f64 float64) (err error)

EncodeFloat64 encodes float64 to encoder.

func (*Encoder) EncodeInt32

func (e *Encoder) EncodeInt32(i32 int32) (err error)

EncodeInt32 encodes int32 to encoder.

func (*Encoder) EncodeInt64

func (e *Encoder) EncodeInt64(i64 int64) (err error)

EncodeInt64 encodes int64 to encoder.

func (*Encoder) EncodeJSONBytes

func (e *Encoder) EncodeJSONBytes(ctx *JSONEncodeContext, b []byte) error

EncodeJSONBytes encodes JSON bytes to encoder.

func (*Encoder) EncodeJSONString

func (e *Encoder) EncodeJSONString(ctx *JSONEncodeContext, b string) error

EncodeJSONString encodes JSON string to encoder.

func (*Encoder) EncodeList

func (e *Encoder) EncodeList(slice interface{}) (err error)

EncodeList encodes []T to encoder.

func (*Encoder) EncodeListBegin

func (e *Encoder) EncodeListBegin(length int, typ string) (end bool, err error)

EncodeListBegin encodes list prefix to encoder.

func (*Encoder) EncodeListEnd

func (e *Encoder) EncodeListEnd(end bool) (err error)

EncodeListEnd encodes list end to encoder.

func (*Encoder) EncodeMap

func (e *Encoder) EncodeMap(m interface{}) (err error)

EncodeMap encodes map[T]T to encoder.

func (*Encoder) EncodeMapBegin

func (e *Encoder) EncodeMapBegin() (err error)

EncodeMapBegin encodes map prefix to encoder.

func (*Encoder) EncodeMapEnd

func (e *Encoder) EncodeMapEnd() (err error)

EncodeMapEnd encodes map end to encoder.

func (*Encoder) EncodeNil

func (e *Encoder) EncodeNil() (err error)

EncodeNil encodes nil to encoder.

func (*Encoder) EncodeObject

func (e *Encoder) EncodeObject(obj interface{}) (err error)

EncodeObject encodes object to encoder.

func (*Encoder) EncodeStreamingJSONBytes

func (e *Encoder) EncodeStreamingJSONBytes(ctx *JSONEncodeContext, b []byte) error

EncodeStreamingJSONBytes encodes the json stream to encoder.

func (*Encoder) EncodeString

func (e *Encoder) EncodeString(s string) (err error)

EncodeString encodes string to encoder.

func (*Encoder) EncodeValue

func (e *Encoder) EncodeValue(value reflect.Value) (err error)

EncodeValue encodes reflect.Value to encoder.

func (*Encoder) GetContext

func (e *Encoder) GetContext() *EncodeContext

GetContext reads the context of encoding.

func (*Encoder) Reset

func (e *Encoder) Reset()

Reset resets the encoder status.

func (*Encoder) ResetWithContext

func (e *Encoder) ResetWithContext(o *EncodeContext)

ResetWithContext resets the encoder status with context.

type HessianDecoder

type HessianDecoder interface {
	HessianDecode(ctx *DecodeContext, br *bufio.Reader) error
}

type HessianEncoder

type HessianEncoder interface {
	HessianEncode(ctx *EncodeContext, b []byte) ([]byte, error)
}

type IdentityIntMap

type IdentityIntMap struct {
	// contains filtered or unexported fields
}

IdentityIntMap implements the identity map of java in hessian with Golang.

func NewIdentityIntMap

func NewIdentityIntMap() *IdentityIntMap

func (*IdentityIntMap) Get

func (m *IdentityIntMap) Get(key interface{}) int

func (*IdentityIntMap) Put

func (m *IdentityIntMap) Put(key interface{}, value int, replaced bool) int

func (*IdentityIntMap) Size

func (m *IdentityIntMap) Size() int

type JSONEncodeContext

type JSONEncodeContext struct {
	// contains filtered or unexported fields
}

JSONEncodeContext holds the context of json encoding.

func AcquireJSONContext

func AcquireJSONContext() *JSONEncodeContext

AcquireJSONContext acquires json context from sync.pool.

func NewJSONEncodeContext

func NewJSONEncodeContext() *JSONEncodeContext

NewJSONEncodeContext returns a new JSONEncodeContext.

func (*JSONEncodeContext) LoadToJSONEncoder

func (e *JSONEncodeContext) LoadToJSONEncoder(className string) (ToJSONEncoder, bool)

func (*JSONEncodeContext) Reset

func (e *JSONEncodeContext) Reset()

Reset resets the context.

func (*JSONEncodeContext) SetLessFunc

func (e *JSONEncodeContext) SetLessFunc(fn func(keyi, keyj, valuei, valuej interface{}) bool) *JSONEncodeContext

func (*JSONEncodeContext) SetMaxDepth

func (e *JSONEncodeContext) SetMaxDepth(depth int) *JSONEncodeContext

SetMaxDepth sets the maximum depth for recursive.

func (*JSONEncodeContext) SetMaxPtrCycles

func (e *JSONEncodeContext) SetMaxPtrCycles(m uint) *JSONEncodeContext

func (*JSONEncodeContext) SetTracer

func (e *JSONEncodeContext) SetTracer(tracer Tracer) *JSONEncodeContext

SetTracer sets the tracer for JSONEncodeContext.

type JSONToHessianEncoder

type JSONToHessianEncoder interface {
	EncodeJSONToHessian(ctx *JSONEncodeContext, encoder *Encoder, v *fastjson.Value, classname string) error
}

JSONToHessianEncoder represents the custom encoder to encode json to hessian.

func LoadJSONToHessianEncoder

func LoadJSONToHessianEncoder(classname string) (JSONToHessianEncoder, bool)

LoadJSONToHessianEncoder loads the JSONToHessianEncoder from global.

type JSONToHessianEncoderFunc

type JSONToHessianEncoderFunc func(ctx *JSONEncodeContext, encoder *Encoder, v *fastjson.Value, classname string) error

func (JSONToHessianEncoderFunc) EncodeJSONToHessian

func (j JSONToHessianEncoderFunc) EncodeJSONToHessian(ctx *JSONEncodeContext,
	encoder *Encoder, v *fastjson.Value, classname string) error

type JavaClassNameGetter

type JavaClassNameGetter interface {
	GetJavaClassName() string
}

JavaClassNameGetter represents the java class name interface.

type JavaList

type JavaList struct {
	// contains filtered or unexported fields
}

func (*JavaList) GetJavaClassName

func (jl *JavaList) GetJavaClassName() string

func (*JavaList) GetValue

func (jl *JavaList) GetValue() []interface{}

func (*JavaList) HessianEncode

func (jl *JavaList) HessianEncode(ctx *EncodeContext, b []byte) ([]byte, error)

func (*JavaList) HessianEncode3V2

func (jl *JavaList) HessianEncode3V2(o *EncodeContext, dst []byte) ([]byte, error)

func (*JavaList) HessianEncode4V2

func (jl *JavaList) HessianEncode4V2(o *EncodeContext, dst []byte) ([]byte, error)

func (*JavaList) HessianEncodeV1

func (jl *JavaList) HessianEncodeV1(o *EncodeContext, dst []byte) ([]byte, error)

type JavaMap

type JavaMap struct {
	// contains filtered or unexported fields
}

func NewJavaMap

func NewJavaMap(class string, m map[interface{}]interface{}) *JavaMap

func (*JavaMap) GetJavaClassName

func (j *JavaMap) GetJavaClassName() string

func (*JavaMap) GetValue

func (j *JavaMap) GetValue() map[interface{}]interface{}

func (*JavaMap) HessianEncode

func (j *JavaMap) HessianEncode(ctx *EncodeContext, b []byte) ([]byte, error)

func (*JavaMap) HessianEncode3V2

func (j *JavaMap) HessianEncode3V2(ctx *EncodeContext, b []byte) ([]byte, error)

func (*JavaMap) HessianEncode4V2

func (j *JavaMap) HessianEncode4V2(ctx *EncodeContext, b []byte) ([]byte, error)

func (*JavaMap) HessianEncodeV1

func (j *JavaMap) HessianEncodeV1(ctx *EncodeContext, b []byte) ([]byte, error)

type JavaObject

type JavaObject struct {
	// contains filtered or unexported fields
}

func (*JavaObject) EncodeObjectDefinitionHessian3V2

func (jo *JavaObject) EncodeObjectDefinitionHessian3V2(o *EncodeContext, dst []byte) ([]byte, error)

func (*JavaObject) EncodeObjectDefinitionHessian4V2

func (jo *JavaObject) EncodeObjectDefinitionHessian4V2(o *EncodeContext, dst []byte,
	obj interface{}, t reflect.Type, v reflect.Value) ([]byte, error)

func (*JavaObject) GetJavaClassName

func (jo *JavaObject) GetJavaClassName() string

func (*JavaObject) GetKey

func (jo *JavaObject) GetKey(i int) string

func (*JavaObject) GetValue

func (jo *JavaObject) GetValue(i int) interface{}

func (*JavaObject) HessianEncode

func (jo *JavaObject) HessianEncode(ctx *EncodeContext, b []byte) ([]byte, error)

func (*JavaObject) HessianEncode3V2

func (jo *JavaObject) HessianEncode3V2(o *EncodeContext, dst []byte) ([]byte, error)

func (*JavaObject) HessianEncode4V2

func (jo *JavaObject) HessianEncode4V2(o *EncodeContext, dst []byte) ([]byte, error)

func (*JavaObject) Len

func (jo *JavaObject) Len() int

type StderrTracer

type StderrTracer struct {
	// contains filtered or unexported fields
}

func NewStderrTracer

func NewStderrTracer() *StderrTracer

func (*StderrTracer) OnTraceStart

func (t *StderrTracer) OnTraceStart(event string)

func (*StderrTracer) OnTraceStop

func (t *StderrTracer) OnTraceStop(event string)

type StdoutTracer

type StdoutTracer struct {
	// contains filtered or unexported fields
}

func NewStdoutTracer

func NewStdoutTracer() *StdoutTracer

func (*StdoutTracer) OnTraceStart

func (t *StdoutTracer) OnTraceStart(event string)

func (*StdoutTracer) OnTraceStop

func (t *StdoutTracer) OnTraceStop(event string)

type ToJSONEncoder

type ToJSONEncoder interface {
	EncodeToJSON(ctx *JSONEncodeContext, dst []byte, obj interface{}) ([]byte, error)
}

func LoadToJSONEncoder

func LoadToJSONEncoder(classname string) (ToJSONEncoder, bool)

LoadToJSONEncoder loads the ToJSONEncoder from global.

type ToJSONEncoderFunc

type ToJSONEncoderFunc func(ctx *JSONEncodeContext, dst []byte, obj interface{}) ([]byte, error)

func (ToJSONEncoderFunc) EncodeToJSON

func (t ToJSONEncoderFunc) EncodeToJSON(ctx *JSONEncodeContext, dst []byte, obj interface{}) ([]byte, error)

type Tracer

type Tracer interface {
	OnTraceStart(event string)
	OnTraceStop(event string)
}

type Version

type Version uint8
const (
	Hessian4xV2 Version = iota // default Hessian4x
	Hessian3xV2
	HessianV1
)

type WriterTracer

type WriterTracer struct {
	// contains filtered or unexported fields
}

func NewWriterTracer

func NewWriterTracer(w io.Writer) *WriterTracer

func (*WriterTracer) OnTraceStart

func (t *WriterTracer) OnTraceStart(event string)

func (*WriterTracer) OnTraceStop

func (t *WriterTracer) OnTraceStop(event string)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL