util

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2024 License: Apache-2.0 Imports: 11 Imported by: 6

Documentation

Index

Constants

View Source
const (
	DefaultGrowSize   = 4096
	DefaultBufferSize = 1024
)
View Source
const (
	MaxBufferMsg = 65535
	Actived      = 0
	Deactived    = 1
)
View Source
const (
	JavaString  = "Ljava/lang/String;"
	JavaChar    = "Ljava/lang/Character;"
	JavaByte    = "Ljava/lang/Byte;"
	JavaShort   = "Ljava/lang/Short;"
	JavaInteger = "Ljava/lang/Integer;"
	JavaLong    = "Ljava/lang/Long;"
	JavaFloat   = "Ljava/lang/Float;"
	JavaDouble  = "Ljava/lang/Double;"
	JavaBoolean = "Ljava/lang/Boolean;"
	JavaArray   = "Ljava.util.Arrays;"
	JavaObject  = "Ljava/lang/Object;"
	JavaList    = "Ljava/util/List;"
	JavaMap     = "Ljava.util.Map;"
	JavaSplit   = ";"
)
View Source
const (
	//vod
	JvmVoid = byte('V')
	//boolean(Z).
	JvmBool = byte('Z')
	// byte(B)
	JvmByte = byte('B')
	// char(C).
	JvmChar = byte('C')
	// double(D).
	JvmDouble = byte('D')
	//float(F).
	JvmFloat = byte('F')
	// int(I).
	JvmInt = byte('I')
	// long(J).
	JvmLong = byte('J')
	// short(S).
	JvmShort = byte('S')

	//正则表达式
	JavaIdentRegex = "(?:[_$a-zA-Z][_$a-zA-Z0-9]*)"
	ClassDesc      = "(?:L" + JavaIdentRegex + "(?:\\/" + JavaIdentRegex + ")*;)"
	ArrayDesc      = "(?:\\[+(?:(?:[VZBCDFIJS])|" + ClassDesc + "))"
	ArrayRegex     = "(?:(?:[VZBCDFIJS])|" + ClassDesc + "|" + ArrayDesc + ")"
)

Constants ..

View Source
const (
	SchemaString  = "string"
	SchemaArray   = "array" //对应java  ARRAY和List
	SchemaMap     = "object"
	SchemaObject  = "object"
	SchemaNumber  = "number"
	SchemaInteger = "integer"
	SchemaInt32   = "int32"
	SchemaInt64   = "int64"
	SchemaFloat   = "float"
	SchemaDouble  = "double"
	SchemaByte    = "byte"
	SchemaBin     = "binary"
	SchemaBool    = "boolean"
	SchemaDate    = "date"
	SchemaTime    = "date-time"
	SchemaPasswd  = "password"
)

Variables

View Source
var SchemeTypeMAP map[string]string

SchemeTypeMAP is a variable of type map

View Source
var TypMap map[string]reflect.Type

TypMap is a variable of type map

Functions

func ArrayToQueryString

func ArrayToQueryString(key string, inlst interface{}) string

ArrayToQueryString is a function which converts array to a string

func Bytes2int

func Bytes2int(b []byte, off int) int32

Bytes2int is a function which converts byte to int

func Bytes2long

func Bytes2long(b []byte, off int) int64

Bytes2long is a function which converts byte to int64

func Bytes2short

func Bytes2short(b []byte, off int) uint16

Bytes2short is a function which converts byte to int

func GetJavaDesc

func GetJavaDesc(args []Argument) string

GetJavaDesc is a function

func Int2bytes

func Int2bytes(value int, b []byte, off int)

Int2bytes is a function which converts int to byte

func Long2bytes

func Long2bytes(i int64, b []byte, off int)

Long2bytes is a function which converts int64 to byte

func ObjectToString

func ObjectToString(dtype string, v interface{}) (string, error)

ObjectToString is a method which converts object to string

func RestByteToValue

func RestByteToValue(jType string, value []byte) (interface{}, error)

RestByteToValue is a function which converts byte to value type

func RestBytesToLstValue

func RestBytesToLstValue(jType string, value [][]byte) (interface{}, error)

RestBytesToLstValue is a function

func S2ByteSlice

func S2ByteSlice(str []string) [][]byte

S2ByteSlice is a function which converts string slice to byte slice

func Short2bytes

func Short2bytes(value int, b []byte, off int)

Short2bytes is a function which converts int to byte

Types

type Argument

type Argument struct {
	JavaType string
	Value    interface{}
}

Argument is a struct

func TypeDesToArgsObjArry

func TypeDesToArgsObjArry(desc string) []Argument

TypeDesToArgsObjArry is a function which converts description to array object

func (*Argument) GetJavaType

func (p *Argument) GetJavaType() string

GetJavaType is a method which returns javatype

func (*Argument) GetValue

func (p *Argument) GetValue() interface{}

GetValue is a method which gets value

func (*Argument) SetJavaType

func (p *Argument) SetJavaType(jType string)

SetJavaType is method which sets javatype

func (*Argument) SetValue

func (p *Argument) SetValue(value interface{})

SetValue is a method which sets value

type BaseError

type BaseError struct {
	ErrMsg string
}

BaseError is a struct

func (*BaseError) Error

func (p *BaseError) Error() string

type MsgQueue

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

MsgQueue thread safe queue

func NewMsgQueue

func NewMsgQueue() *MsgQueue

NewMsgQueue is a function which initializes msgqueue value

func (*MsgQueue) Deavtive

func (this *MsgQueue) Deavtive()

Deavtive is a method

func (*MsgQueue) Dequeue

func (this *MsgQueue) Dequeue() (interface{}, error)

Dequeue is a method which dequeues message from queue

func (*MsgQueue) Enqueue

func (this *MsgQueue) Enqueue(msg interface{}) error

Enqueue is method which enqueues message in queue

type ReadBuffer

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

ReadBuffer is a struct

func (*ReadBuffer) GetBuf

func (b *ReadBuffer) GetBuf() []byte

GetBuf is a method to get buffer

func (*ReadBuffer) Read

func (b *ReadBuffer) Read(p []byte) (n int, err error)

Read 实现io.Reader

func (*ReadBuffer) ReadByte

func (b *ReadBuffer) ReadByte() (byte, error)

ReadByte is a method to read particular byte from buffer

func (*ReadBuffer) ReadBytes

func (b *ReadBuffer) ReadBytes(len int) []byte

ReadBytes is a method to read data from buffer

func (*ReadBuffer) ReadMap

func (b *ReadBuffer) ReadMap() (map[string]string, error)

ReadMap is a method to read buffer and return as a map

func (*ReadBuffer) ReadObject

func (b *ReadBuffer) ReadObject() (interface{}, error)

ReadObject is a method to read buffer and return object

func (*ReadBuffer) ReadString

func (b *ReadBuffer) ReadString() string

ReadString is a method to read buffer and return as string

func (*ReadBuffer) SetBuffer

func (b *ReadBuffer) SetBuffer(src []byte)

SetBuffer is a method to set buffer data

type RoutineManager

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

RoutineManager is a struct

func NewRoutineManager

func NewRoutineManager() *RoutineManager

NewRoutineManager is a fucntion which initializes value for routine manager struct

func (*RoutineManager) Done

func (this *RoutineManager) Done()

Done is a method which tells waitgroup that it's done waiting

func (*RoutineManager) Spawn

func (this *RoutineManager) Spawn(task RoutineTask, agrs interface{}, routineName string)

Spawn is a method which spawns new routine

func (*RoutineManager) Wait

func (this *RoutineManager) Wait()

Wait is method which waits for until done function is called

type RoutineTask

type RoutineTask interface {
	Svc(agrs interface{}) interface{}
}

RoutineTask interface

type ThreadGroupWait

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

ThreadGroupWait realise a thread group wait

func NewThreadGroupWait

func NewThreadGroupWait() *ThreadGroupWait

NewThreadGroupWait is a function which initializes value for threadgroupwait struct and returns it

func (*ThreadGroupWait) Add

func (this *ThreadGroupWait) Add(count int)

Add is a method to add a thread waitgroup

func (*ThreadGroupWait) Done

func (this *ThreadGroupWait) Done()

Done is a method to say that waitgroup is done

func (*ThreadGroupWait) Wait

func (this *ThreadGroupWait) Wait()

Wait is a method which waits until done function is called

type WriteBuffer

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

WriteBuffer is a struct

func (*WriteBuffer) GetBuf

func (b *WriteBuffer) GetBuf() []byte

GetBuf is a method to get buffer

func (*WriteBuffer) GetValidData

func (b *WriteBuffer) GetValidData() []byte

GetValidData is a method to get valid data

func (*WriteBuffer) Init

func (b *WriteBuffer) Init(size int)

Init is a method to initialize write buffer attributes

func (*WriteBuffer) Write

func (b *WriteBuffer) Write(p []byte) (n int, err error)

Write is a method to write into buffer

func (*WriteBuffer) WriteByte

func (b *WriteBuffer) WriteByte(src byte) error

WriteByte is a method to write particular byte

func (*WriteBuffer) WriteBytes

func (b *WriteBuffer) WriteBytes(src []byte) int

WriteBytes is a method to write bytes

func (*WriteBuffer) WriteIndex

func (b *WriteBuffer) WriteIndex(index int) error

WriteIndex is a method to write index

func (*WriteBuffer) WriteObject

func (b *WriteBuffer) WriteObject(src interface{}) error

WriteObject is a method to write object

func (*WriteBuffer) WrittenBytes

func (b *WriteBuffer) WrittenBytes() int

WrittenBytes is a methodto get amount of bytes written

Jump to

Keyboard shortcuts

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