pkg

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2020 License: Apache-2.0, Apache-2.0 Imports: 15 Imported by: 49

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EvaluateAddition added in v1.2.1

func EvaluateAddition(left, right reflect.Value) (reflect.Value, error)

EvaluateAddition will evaluate addition operation over two value

func EvaluateBitAnd added in v1.2.1

func EvaluateBitAnd(left, right reflect.Value) (reflect.Value, error)

EvaluateBitAnd will evaluate Bitwise And operation over two value

func EvaluateBitOr added in v1.2.1

func EvaluateBitOr(left, right reflect.Value) (reflect.Value, error)

EvaluateBitOr will evaluate Bitwise Or operation over two value

func EvaluateDivision added in v1.2.1

func EvaluateDivision(left, right reflect.Value) (reflect.Value, error)

EvaluateDivision will evaluate division operation over two value

func EvaluateEqual added in v1.2.1

func EvaluateEqual(left, right reflect.Value) (reflect.Value, error)

EvaluateEqual will evaluate Equal operation over two value

func EvaluateGreaterThan added in v1.2.1

func EvaluateGreaterThan(left, right reflect.Value) (reflect.Value, error)

EvaluateGreaterThan will evaluate GreaterThan operation over two value

func EvaluateGreaterThanEqual added in v1.2.1

func EvaluateGreaterThanEqual(left, right reflect.Value) (reflect.Value, error)

EvaluateGreaterThanEqual will evaluate GreaterThanEqual operation over two value

func EvaluateLesserThan added in v1.2.1

func EvaluateLesserThan(left, right reflect.Value) (reflect.Value, error)

EvaluateLesserThan will evaluate LesserThan operation over two value

func EvaluateLesserThanEqual added in v1.2.1

func EvaluateLesserThanEqual(left, right reflect.Value) (reflect.Value, error)

EvaluateLesserThanEqual will evaluate LesserThanEqual operation over two value

func EvaluateLogicAnd added in v1.2.1

func EvaluateLogicAnd(left, right reflect.Value) (reflect.Value, error)

EvaluateLogicAnd will evaluate LogicalAnd operation over two value

func EvaluateLogicOr added in v1.2.1

func EvaluateLogicOr(left, right reflect.Value) (reflect.Value, error)

EvaluateLogicOr will evaluate LogicalOr operation over two value

func EvaluateModulo added in v1.2.1

func EvaluateModulo(left, right reflect.Value) (reflect.Value, error)

EvaluateModulo will evaluate modulo operation over two value

func EvaluateMultiplication added in v1.2.1

func EvaluateMultiplication(left, right reflect.Value) (reflect.Value, error)

EvaluateMultiplication will evaluate multiplication operation over two value

func EvaluateNotEqual added in v1.2.1

func EvaluateNotEqual(left, right reflect.Value) (reflect.Value, error)

EvaluateNotEqual will evaluate NotEqual operation over two value

func EvaluateSubstraction added in v1.2.1

func EvaluateSubstraction(left, right reflect.Value) (reflect.Value, error)

EvaluateSubstraction will evaluate substraction operation over two value

func GetAttributeBoolValue

func GetAttributeBoolValue(obj interface{}, fieldName string) (bool, error)

GetAttributeBoolValue will try to obtain member variable's bool value

func GetAttributeFloat32Value

func GetAttributeFloat32Value(obj interface{}, fieldName string) (float32, error)

GetAttributeFloat32Value will try to obtain member variable's float32 value

func GetAttributeFloat64Value

func GetAttributeFloat64Value(obj interface{}, fieldName string) (float64, error)

GetAttributeFloat64Value will try to obtain member variable's float64 value

func GetAttributeInt8Value

func GetAttributeInt8Value(obj interface{}, fieldName string) (int8, error)

GetAttributeInt8Value will try to obtain member variable's int8 value

func GetAttributeInt16Value

func GetAttributeInt16Value(obj interface{}, fieldName string) (int16, error)

GetAttributeInt16Value will try to obtain member variable's int16 value

func GetAttributeInt32Value

func GetAttributeInt32Value(obj interface{}, fieldName string) (int32, error)

GetAttributeInt32Value will try to obtain member variable's int32 value

func GetAttributeInt64Value

func GetAttributeInt64Value(obj interface{}, fieldName string) (int64, error)

GetAttributeInt64Value will try to obtain member variable's int64 value

func GetAttributeIntValue

func GetAttributeIntValue(obj interface{}, fieldName string) (int, error)

GetAttributeIntValue will try to obtain member variable's int value

func GetAttributeInterface

func GetAttributeInterface(obj interface{}, fieldName string) (interface{}, error)

GetAttributeInterface will retrieve a members variable value as usable interface.

func GetAttributeList

func GetAttributeList(obj interface{}) ([]string, error)

GetAttributeList will populate list of struct's public member variable.

func GetAttributeStringValue

func GetAttributeStringValue(obj interface{}, fieldName string) (string, error)

GetAttributeStringValue will try to obtain member variable's string value

func GetAttributeTimeValue

func GetAttributeTimeValue(obj interface{}, fieldName string) (time.Time, error)

GetAttributeTimeValue will try to obtain member variable's time.Time value

func GetAttributeType

func GetAttributeType(obj interface{}, fieldName string) (reflect.Type, error)

GetAttributeType will return the type of a specific member variable

func GetAttributeUInt8Value

func GetAttributeUInt8Value(obj interface{}, fieldName string) (uint8, error)

GetAttributeUInt8Value will try to obtain member variable's uint8 value

func GetAttributeUInt16Value

func GetAttributeUInt16Value(obj interface{}, fieldName string) (uint16, error)

GetAttributeUInt16Value will try to obtain member variable's uint16 value

func GetAttributeUInt32Value

func GetAttributeUInt32Value(obj interface{}, fieldName string) (uint32, error)

GetAttributeUInt32Value will try to obtain member variable's uint32 value

func GetAttributeUInt64Value

func GetAttributeUInt64Value(obj interface{}, fieldName string) (uint64, error)

GetAttributeUInt64Value will try to obtain member variable's uint64 value

func GetAttributeUIntValue

func GetAttributeUIntValue(obj interface{}, fieldName string) (uint, error)

GetAttributeUIntValue will try to obtain member variable's uint value

func GetAttributeValue

func GetAttributeValue(obj interface{}, fieldName string) (reflect.Value, error)

GetAttributeValue will retrieve a members variable value.

func GetBaseKind

func GetBaseKind(val reflect.Value) reflect.Kind

GetBaseKind will try to obtain base obtainable kind of a value, so we know what method to call val.Int(), val.Uint(), etc.

func GetFunctionList

func GetFunctionList(obj interface{}) ([]string, error)

GetFunctionList get list of functions in a struct instance

func GetFunctionParameterTypes

func GetFunctionParameterTypes(obj interface{}, methodName string) ([]reflect.Type, error)

GetFunctionParameterTypes get list of parameter types of specific function in a struct instance

func GetFunctionReturnTypes

func GetFunctionReturnTypes(obj interface{}, methodName string) ([]reflect.Type, error)

GetFunctionReturnTypes get list of return types of specific function in a struct instance

func InvokeFunction

func InvokeFunction(obj interface{}, methodName string, param []interface{}) ([]interface{}, error)

InvokeFunction invokes a specific function in a struct instance, using parameters array

func IsAttributeArray

func IsAttributeArray(obj interface{}, fieldName string) (bool, error)

IsAttributeArray validate if a member variable is an array or a slice.

func IsAttributeMap

func IsAttributeMap(obj interface{}, fieldName string) (bool, error)

IsAttributeMap validate if a member variable is a map.

func IsAttributeNilOrZero

func IsAttributeNilOrZero(obj interface{}, fieldName string) (bool, error)

IsAttributeNilOrZero validate if a member variable is nil or zero.

func IsStruct

func IsStruct(obj interface{}) bool

IsStruct validates if an instance is struct or pointer to struct

func IsValidField

func IsValidField(obj interface{}, fieldName string) bool

IsValidField validates if an instance struct have a field with such name

func SetAttributeBoolValue

func SetAttributeBoolValue(obj interface{}, fieldName string, newValue bool) error

SetAttributeBoolValue will try to set member variable's bool value

func SetAttributeFloat32Value

func SetAttributeFloat32Value(obj interface{}, fieldName string, newValue float32) error

SetAttributeFloat32Value will try to set member variable's float32 value

func SetAttributeFloat64Value

func SetAttributeFloat64Value(obj interface{}, fieldName string, newValue float64) error

SetAttributeFloat64Value will try to set member variable's float64 value

func SetAttributeInt8Value

func SetAttributeInt8Value(obj interface{}, fieldName string, newValue int8) error

SetAttributeInt8Value will try to set member variable's int8 value

func SetAttributeInt16Value

func SetAttributeInt16Value(obj interface{}, fieldName string, newValue int16) error

SetAttributeInt16Value will try to set member variable's int16 value

func SetAttributeInt32Value

func SetAttributeInt32Value(obj interface{}, fieldName string, newValue int32) error

SetAttributeInt32Value will try to set member variable's int32 value

func SetAttributeInt64Value

func SetAttributeInt64Value(obj interface{}, fieldName string, newValue int64) error

SetAttributeInt64Value will try to set member variable's int64 value

func SetAttributeIntValue

func SetAttributeIntValue(obj interface{}, fieldName string, newValue int) error

SetAttributeIntValue will try to set member variable's int value

func SetAttributeInterface

func SetAttributeInterface(obj interface{}, fieldName string, value interface{}) error

SetAttributeInterface will try to set a member variable value with a value from an interface

func SetAttributeStringValue

func SetAttributeStringValue(obj interface{}, fieldName string, newValue string) error

SetAttributeStringValue will try to set member variable's string value

func SetAttributeTimeValue

func SetAttributeTimeValue(obj interface{}, fieldName string, newValue time.Time) error

SetAttributeTimeValue will try to set member variable's time.Time value

func SetAttributeUInt8Value

func SetAttributeUInt8Value(obj interface{}, fieldName string, newValue uint8) error

SetAttributeUInt8Value will try to set member variable's uint8 value

func SetAttributeUInt16Value

func SetAttributeUInt16Value(obj interface{}, fieldName string, newValue uint16) error

SetAttributeUInt16Value will try to set member variable's uint16 value

func SetAttributeUInt32Value

func SetAttributeUInt32Value(obj interface{}, fieldName string, newValue uint32) error

SetAttributeUInt32Value will try to set member variable's uint32 value

func SetAttributeUInt64Value

func SetAttributeUInt64Value(obj interface{}, fieldName string, newValue uint64) error

SetAttributeUInt64Value will try to set member variable's uint64 value

func SetAttributeUIntValue

func SetAttributeUIntValue(obj interface{}, fieldName string, newValue uint) error

SetAttributeUIntValue will try to set member variable's uint value

func SetAttributeValue

func SetAttributeValue(obj interface{}, fieldName string, value reflect.Value) error

SetAttributeValue will try to set a member variable value with a new one.

func ValueToInterface

func ValueToInterface(v reflect.Value) interface{}

ValueToInterface will try to obtain an interface to a speciffic value. it will detect the value's kind.

Types

type BytesResource

type BytesResource struct {
	Bytes []byte
}

BytesResource is a struct that will hold the byte array data

func (*BytesResource) Load

func (res *BytesResource) Load() ([]byte, error)

Load will load the resource into byte array.

func (*BytesResource) String

func (res *BytesResource) String() string

String will state the resource byte array.

type FileResource

type FileResource struct {
	Path  string
	Bytes []byte
}

FileResource is a struct that will hold the file path and readed data bytes.

func (*FileResource) Load

func (res *FileResource) Load() ([]byte, error)

Load will load the resource into byte array. The load byte array will be cached by the FileResource. So Calling Load multiple time will only load the file once on the first call. If you wish to reload the file, simply create new instance using NewFileResource function.

func (*FileResource) String

func (res *FileResource) String() string

String will state the resource file path.

type FileResourceBundle added in v1.2.3

type FileResourceBundle struct {
	// The base path where all the
	BasePath string
	// List Glob like file pattern.
	// *.grl           <- matches abc.grl but not /anyfolder/abc.grl
	// **/*.grl        <- matches abc/def.grl or abc/def/ghi.grl or abc/def/.grl
	// /abc/**/*.grl   <- matches /abc/def.grl or /abc/def/ghi.drl
	PathPattern []string
}

FileResourceBundle is a helper struct to load multiple files all at once by specifying the root location of the file and the file pattern to look for. It will look into sub-directories for the file with pattern matching.

func (*FileResourceBundle) Load added in v1.2.3

func (bundle *FileResourceBundle) Load() ([]Resource, error)

Load all file resources that locateed under BasePath that conform to the PathPattern.

func (*FileResourceBundle) MustLoad added in v1.2.3

func (bundle *FileResourceBundle) MustLoad() []Resource

MustLoad function is the same as Load with difference that it will panic if any error is raised

type GITResource added in v1.2.3

type GITResource struct {
	URL   string
	Path  string
	Bytes []byte
}

GITResource resource implementation that loaded from GIT

func (*GITResource) Load added in v1.2.3

func (res *GITResource) Load() ([]byte, error)

Load will load the resource into byte array. This implementation will no re-load resources from git when this method is called, it simply return the loaded data.

func (*GITResource) String added in v1.2.3

func (res *GITResource) String() string

String will state the resource url.

type GITResourceBundle added in v1.2.3

type GITResourceBundle struct {
	// GIT Repository HTTPS URL
	URL string
	// The Ref name to checkout, if you dont know, let it empty
	RefName string
	// The remote name. IF you left it empty, it will use origin
	Remote string
	// Specify the user name if your repository requires user/password authentication
	User string
	// Password for authentication
	Password string
	// File path pattern to load in your git. The path / is the root on the repository.
	PathPattern []string
}

GITResourceBundle is a helper struct to load multiple files from GIT all at once by specifying the necessary information needed to communicate to the GIT server. It will look into sub-directories, in the git, for the file with pattern matching.

func (*GITResourceBundle) Load added in v1.2.3

func (bundle *GITResourceBundle) Load() ([]Resource, error)

Load will load the file from your git repository

func (*GITResourceBundle) MustLoad added in v1.2.3

func (bundle *GITResourceBundle) MustLoad() []Resource

MustLoad is the same as Load, the difference is it will panic if an error is raised during fetching resources.

type ReaderResource

type ReaderResource struct {
	Reader io.Reader
}

ReaderResource is a struct that will hold the reader instance.

func (*ReaderResource) Load

func (res *ReaderResource) Load() ([]byte, error)

Load will load the resource into byte array.

func (*ReaderResource) String

func (res *ReaderResource) String() string

String will state the resource source.

type ResouceBundle added in v1.2.3

type ResouceBundle interface {
	Load() ([]Resource, error)
	MustLoad() []Resource
}

ResouceBundle is a helper struct to help load multiple resource at once.

type Resource

type Resource interface {
	Load() ([]byte, error)
	String() string
}

Resource should be implemented by any resource model so it can be loaded and parsed by the grule parser.

func NewBytesResource

func NewBytesResource(bytes []byte) Resource

NewBytesResource will create a new Resource using a byte array.

func NewFileResource

func NewFileResource(path string) Resource

NewFileResource will create a new Resource using a file located in path.

func NewReaderResource

func NewReaderResource(reader io.Reader) Resource

NewReaderResource will create a new Resource using a common reader.

func NewURLResource

func NewURLResource(url string) Resource

NewURLResource will create a new Resource using a resource as located in the url

type URLResource

type URLResource struct {
	URL   string
	Bytes []byte
}

URLResource is a struct that will hold the byte array data and URL source

func (*URLResource) Load

func (res *URLResource) Load() ([]byte, error)

Load will load the resource into byte array. This resource will cache the obtained result byte arrays. So calling this function multiple times only call the URL once at the first time. If you want to refresh the load, you simply create a new instance of URLResource using NewURLResource

func (*URLResource) String

func (res *URLResource) String() string

String will state the resource url.

Jump to

Keyboard shortcuts

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