Documentation
¶
Index ¶
- func ArrMapLen(arr reflect.Value, arg []reflect.Value) (reflect.Value, error)
- func SetNumberValue(target, newvalue reflect.Value) error
- func StrCompare(str string, arg []reflect.Value) (reflect.Value, error)
- func StrContains(str string, arg []reflect.Value) (reflect.Value, error)
- func StrCount(str string, arg []reflect.Value) (reflect.Value, error)
- func StrHasPrefix(str string, arg []reflect.Value) (reflect.Value, error)
- func StrHasSuffix(str string, arg []reflect.Value) (reflect.Value, error)
- func StrIndex(str string, arg []reflect.Value) (reflect.Value, error)
- func StrLastIndex(str string, arg []reflect.Value) (reflect.Value, error)
- func StrLen(str string, arg []reflect.Value) (reflect.Value, error)
- func StrRepeat(str string, arg []reflect.Value) (reflect.Value, error)
- func StrReplace(str string, arg []reflect.Value) (reflect.Value, error)
- func StrSplit(str string, arg []reflect.Value) (reflect.Value, error)
- func StrToLower(str string, arg []reflect.Value) (reflect.Value, error)
- func StrToUpper(str string, arg []reflect.Value) (reflect.Value, error)
- func StrTrim(str string, arg []reflect.Value) (reflect.Value, error)
- type GoValueNode
- func (node *GoValueNode) AppendValue(value []reflect.Value) (err error)
- func (node *GoValueNode) CallFunction(funcName string, args ...reflect.Value) (retval reflect.Value, err error)
- func (node *GoValueNode) ContinueWithValue(value reflect.Value, identifiedAs string) ValueNode
- func (node *GoValueNode) GetArrayType() (reflect.Type, error)
- func (node *GoValueNode) GetArrayValueAt(index int) (reflect.Value, error)
- func (node *GoValueNode) GetChildNodeByField(field string) (ValueNode, error)
- func (node *GoValueNode) GetChildNodeByIndex(index int) (ValueNode, error)
- func (node *GoValueNode) GetChildNodeBySelector(index reflect.Value) (ValueNode, error)
- func (node *GoValueNode) GetMapValueAt(index reflect.Value) (reflect.Value, error)
- func (node *GoValueNode) GetObjectTypeByField(field string) (typ reflect.Type, err error)
- func (node *GoValueNode) GetObjectValueByField(field string) (reflect.Value, error)
- func (node *GoValueNode) GetType() (reflect.Type, error)
- func (node *GoValueNode) GetValue() (reflect.Value, error)
- func (node *GoValueNode) HasParent() bool
- func (node *GoValueNode) IdentifiedAs() string
- func (node *GoValueNode) IsArray() bool
- func (node *GoValueNode) IsBool() bool
- func (node *GoValueNode) IsInteger() bool
- func (node *GoValueNode) IsMap() bool
- func (node *GoValueNode) IsObject() bool
- func (node *GoValueNode) IsReal() bool
- func (node *GoValueNode) IsString() bool
- func (node *GoValueNode) IsTime() bool
- func (node *GoValueNode) Length() (int, error)
- func (node *GoValueNode) Parent() ValueNode
- func (node *GoValueNode) SetArrayValueAt(index int, value reflect.Value) (err error)
- func (node *GoValueNode) SetMapValueAt(index, newValue reflect.Value) (err error)
- func (node *GoValueNode) SetObjectValueByField(field string, newValue reflect.Value) (err error)
- func (node *GoValueNode) Value() reflect.Value
- type ValueNode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetNumberValue ¶ added in v1.6.0
SetNumberValue will assign a numeric value to a numeric target value this helper function is to ensure assignment between numerical types is happening regardless of types, int, uint or float. The rule designer should be careful as conversion of types in automatic way like this will cause lost of precision during conversion. This will be removed in the future version.
func StrCompare ¶ added in v1.6.0
StrCompare is like strings.compare() function, to be called by the ValueNode function call if the underlying data is string.
func StrContains ¶ added in v1.6.0
StrContains is like strings.Contains() function, to be called by the ValueNode function call if the underlying data is string. is like strings.compare() function, to be called by the ValueNode functioncall if the underlying data is string.
func StrCount ¶ added in v1.6.0
StrCount is like strings.Count() function, to be called by the ValueNode function call if the underlying data is string.
func StrHasPrefix ¶ added in v1.6.0
StrHasPrefix is like strings.HasPrefix() function, to be called by the ValueNode functioncall if the underlying data is string.
func StrHasSuffix ¶ added in v1.6.0
StrHasSuffix is like strings.HasSuffix() function, to be called by the ValueNode functioncall if the underlying data is string.
func StrIndex ¶ added in v1.6.0
StrIndex is like strings.Index() function, to be called by the ValueNode functioncall if the underlying data is string.
func StrLastIndex ¶ added in v1.6.0
StrLastIndex is like strings.LastIndex() function, to be called by the ValueNode functioncall if the underlying data is string.
func StrRepeat ¶ added in v1.6.0
StrRepeat is like strings.Repeat() function, to be called by the ValueNode functioncall if the underlying data is string.
func StrReplace ¶ added in v1.6.0
StrReplace is like strings.Replace() function, to be called by the ValueNode functioncall if the underlying data is string.
func StrSplit ¶ added in v1.6.0
StrSplit is like strings.Split() function, to be called by the ValueNode functioncall if the underlying data is string.
func StrToLower ¶ added in v1.6.0
StrToLower is like strings.ToLower() function, to be called by the ValueNode functioncall if the underlying data is string.
func StrToUpper ¶ added in v1.6.0
StrToUpper is like strings.ToUpper() function, to be called by the ValueNode functioncall if the underlying data is string.
Types ¶
type GoValueNode ¶ added in v1.6.0
type GoValueNode struct {
// contains filtered or unexported fields
}
GoValueNode is an implementation of ValueNode that used to traverse native golang primitives through reflect package
func (*GoValueNode) AppendValue ¶ added in v1.6.0
func (node *GoValueNode) AppendValue(value []reflect.Value) (err error)
AppendValue will append the new values into the current underlying array. will return error if argument list are not compatible with the array element type.
func (*GoValueNode) CallFunction ¶ added in v1.6.0
func (node *GoValueNode) CallFunction(funcName string, args ...reflect.Value) (retval reflect.Value, err error)
CallFunction will call a function owned by the underlying value receiver. this function will artificially create a built-in functions for constants, array and map.
func (*GoValueNode) ContinueWithValue ¶ added in v1.6.0
func (node *GoValueNode) ContinueWithValue(value reflect.Value, identifiedAs string) ValueNode
ContinueWithValue will return a nother ValueNode to wrap the specified value and treated as child of current node. The main purpose of this is for easier debugging.
func (*GoValueNode) GetArrayType ¶ added in v1.6.0
func (node *GoValueNode) GetArrayType() (reflect.Type, error)
GetArrayType to get the type of underlying value array element types.
func (*GoValueNode) GetArrayValueAt ¶ added in v1.6.0
func (node *GoValueNode) GetArrayValueAt(index int) (reflect.Value, error)
GetArrayValueAt to get the value of an array element if the current underlying value is an array
func (*GoValueNode) GetChildNodeByField ¶ added in v1.6.0
func (node *GoValueNode) GetChildNodeByField(field string) (ValueNode, error)
GetChildNodeByField will retrieve the underlying struct's field and return the ValueNode wraper.
func (*GoValueNode) GetChildNodeByIndex ¶ added in v1.6.0
func (node *GoValueNode) GetChildNodeByIndex(index int) (ValueNode, error)
GetChildNodeByIndex is similar to `GetArrayValueAt`, where this will return a ValueNode that wrap the value.
func (*GoValueNode) GetChildNodeBySelector ¶ added in v1.6.0
func (node *GoValueNode) GetChildNodeBySelector(index reflect.Value) (ValueNode, error)
GetChildNodeBySelector is similar to GetMapValueAt, it retrieve a value of map element identified by a value index as ValueNode.
func (*GoValueNode) GetMapValueAt ¶ added in v1.6.0
GetMapValueAt will retrieve a map value by the specified key argument.
func (*GoValueNode) GetObjectTypeByField ¶ added in v1.6.0
func (node *GoValueNode) GetObjectTypeByField(field string) (typ reflect.Type, err error)
GetObjectTypeByField will return underlying type of the value's field
func (*GoValueNode) GetObjectValueByField ¶ added in v1.6.0
func (node *GoValueNode) GetObjectValueByField(field string) (reflect.Value, error)
GetObjectValueByField will return underlying value's field
func (*GoValueNode) GetType ¶ added in v1.6.0
func (node *GoValueNode) GetType() (reflect.Type, error)
GetType will return the underlying value's type
func (*GoValueNode) GetValue ¶ added in v1.6.0
func (node *GoValueNode) GetValue() (reflect.Value, error)
GetValue will return the underlying reflect.Value
func (*GoValueNode) HasParent ¶ added in v1.6.0
func (node *GoValueNode) HasParent() bool
HasParent returns `true` if the current value is a field, function, map, array, slice of another value
func (*GoValueNode) IdentifiedAs ¶ added in v1.6.0
func (node *GoValueNode) IdentifiedAs() string
IdentifiedAs return the current representation of this Value Node
func (*GoValueNode) IsArray ¶ added in v1.6.0
func (node *GoValueNode) IsArray() bool
IsArray to check if the underlying value is an array or not
func (*GoValueNode) IsBool ¶ added in v1.6.0
func (node *GoValueNode) IsBool() bool
IsBool will check if the underlying value is a type of boolean.
func (*GoValueNode) IsInteger ¶ added in v1.6.0
func (node *GoValueNode) IsInteger() bool
IsInteger will check if the underlying value is a type of int, or uint
func (*GoValueNode) IsMap ¶ added in v1.6.0
func (node *GoValueNode) IsMap() bool
IsMap will validate if the underlying value is a map.
func (*GoValueNode) IsObject ¶ added in v1.6.0
func (node *GoValueNode) IsObject() bool
IsObject will check if the underlying value is a struct or pointer to a struct
func (*GoValueNode) IsReal ¶ added in v1.6.0
func (node *GoValueNode) IsReal() bool
IsReal will check if the underlying value is a type of real number, float.
func (*GoValueNode) IsString ¶ added in v1.6.0
func (node *GoValueNode) IsString() bool
IsString will check if the underlying value is a type of string
func (*GoValueNode) IsTime ¶ added in v1.6.0
func (node *GoValueNode) IsTime() bool
IsTime will check if the underlying value is a time.Time
func (*GoValueNode) Length ¶ added in v1.6.0
func (node *GoValueNode) Length() (int, error)
Length will return the length of underlying value if its an array, slice, map or string
func (*GoValueNode) Parent ¶ added in v1.6.0
func (node *GoValueNode) Parent() ValueNode
Parent returns the value node of the parent value, if this node is a field, function, map, array, slice of another value
func (*GoValueNode) SetArrayValueAt ¶ added in v1.6.0
func (node *GoValueNode) SetArrayValueAt(index int, value reflect.Value) (err error)
SetArrayValueAt will set the value of specified array index on the current underlying array value.
func (*GoValueNode) SetMapValueAt ¶ added in v1.6.0
func (node *GoValueNode) SetMapValueAt(index, newValue reflect.Value) (err error)
SetMapValueAt will set the map value for the specified key, value argument
func (*GoValueNode) SetObjectValueByField ¶ added in v1.6.0
func (node *GoValueNode) SetObjectValueByField(field string, newValue reflect.Value) (err error)
SetObjectValueByField will set the underlying value's field with new value.
func (*GoValueNode) Value ¶ added in v1.6.0
func (node *GoValueNode) Value() reflect.Value
Value returns the underlying reflect.Value
type ValueNode ¶ added in v1.6.0
type ValueNode interface {
IdentifiedAs() string
Value() reflect.Value
HasParent() bool
Parent() ValueNode
ContinueWithValue(value reflect.Value, identifiedAs string) ValueNode
GetValue() (reflect.Value, error)
GetType() (reflect.Type, error)
IsArray() bool
GetArrayType() (reflect.Type, error)
GetArrayValueAt(index int) (reflect.Value, error)
GetChildNodeByIndex(index int) (ValueNode, error)
SetArrayValueAt(index int, value reflect.Value) error
AppendValue(value []reflect.Value) error
Length() (int, error)
IsMap() bool
GetMapValueAt(index reflect.Value) (reflect.Value, error)
SetMapValueAt(index, newValue reflect.Value) error
GetChildNodeBySelector(index reflect.Value) (ValueNode, error)
IsObject() bool
GetObjectValueByField(field string) (reflect.Value, error)
GetObjectTypeByField(field string) (reflect.Type, error)
SetObjectValueByField(field string, newValue reflect.Value) error
CallFunction(funcName string, args ...reflect.Value) (reflect.Value, error)
GetChildNodeByField(field string) (ValueNode, error)
IsTime() bool
IsInteger() bool
IsReal() bool
IsBool() bool
IsString() bool
}
ValueNode is an abstraction layer to access underlying dom style data. the node have tree kind of structure which each node are tied to an underlying data node.