Documentation ¶
Index ¶
- func EvaluateAddition(left, right reflect.Value) (reflect.Value, error)
- func EvaluateBitAnd(left, right reflect.Value) (reflect.Value, error)
- func EvaluateBitOr(left, right reflect.Value) (reflect.Value, error)
- func EvaluateDivision(left, right reflect.Value) (reflect.Value, error)
- func EvaluateEqual(left, right reflect.Value) (reflect.Value, error)
- func EvaluateGreaterThan(left, right reflect.Value) (reflect.Value, error)
- func EvaluateGreaterThanEqual(left, right reflect.Value) (reflect.Value, error)
- func EvaluateLesserThan(left, right reflect.Value) (reflect.Value, error)
- func EvaluateLesserThanEqual(left, right reflect.Value) (reflect.Value, error)
- func EvaluateLogicAnd(left, right reflect.Value) (reflect.Value, error)
- func EvaluateLogicOr(left, right reflect.Value) (reflect.Value, error)
- func EvaluateLogicSingle(left reflect.Value) (reflect.Value, error)
- func EvaluateModulo(left, right reflect.Value) (reflect.Value, error)
- func EvaluateMultiplication(left, right reflect.Value) (reflect.Value, error)
- func EvaluateNotEqual(left, right reflect.Value) (reflect.Value, error)
- func EvaluateSubtraction(left, right reflect.Value) (reflect.Value, error)
- func GetAttributeInterface(obj reflect.Value, fieldName string) (interface{}, error)
- func GetAttributeList(obj reflect.Value) ([]string, error)
- func GetAttributeType(obj reflect.Value, fieldName string) (reflect.Type, error)
- func GetAttributeValue(obj reflect.Value, fieldName string) (reflect.Value, error)
- func GetBaseKind(val reflect.Value) reflect.Kind
- func GetFunctionList(obj reflect.Value) ([]string, error)
- func GetFunctionParameterTypes(obj reflect.Value, methodName string) ([]reflect.Type, bool, error)
- func GetFunctionReturnTypes(obj reflect.Value, methodName string) ([]reflect.Type, error)
- func GetMapArrayValue(mapArray, selector interface{}) (ret interface{}, err error)
- func InvokeFunction(obj reflect.Value, methodName string, param []reflect.Value) (retval []reflect.Value, err error)
- func IsAttributeArray(objVal reflect.Value, fieldName string) (bool, error)
- func IsAttributeMap(obj reflect.Value, fieldName string) (bool, error)
- func IsAttributeNilOrZero(obj reflect.Value, fieldName string) (bool, error)
- func IsNumber(val reflect.Value) bool
- func IsStruct(val reflect.Value) bool
- func IsValidField(objVal reflect.Value, fieldName string) bool
- func ParseJSONRuleset(data []byte) (rs string, err error)
- func ParseRule(rule *GruleJSON) (r string, err error)
- func SetAttributeInterface(obj reflect.Value, fieldName string, value interface{}) error
- func SetAttributeValue(objVal reflect.Value, fieldName string, value reflect.Value) error
- func SetMapArrayValue(mapArray, selector reflect.Value, newValue reflect.Value) (err error)
- func ValueToInterface(v reflect.Value) interface{}
- type BytesResource
- type CloneRecord
- type CloneTable
- type FileResource
- type FileResourceBundle
- type GITResource
- type GITResourceBundle
- type GruleErrorReporter
- type GruleJSON
- type JSONResource
- type JSONResourceBundle
- type ReaderResource
- type ResouceBundle
- type Resource
- type URLResource
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EvaluateAddition ¶
EvaluateAddition will evaluate addition operation over two value
func EvaluateBitAnd ¶
EvaluateBitAnd will evaluate Bitwise And operation over two value
func EvaluateBitOr ¶
EvaluateBitOr will evaluate Bitwise Or operation over two value
func EvaluateDivision ¶
EvaluateDivision will evaluate division operation over two value
func EvaluateEqual ¶
EvaluateEqual will evaluate Equal operation over two value
func EvaluateGreaterThan ¶
EvaluateGreaterThan will evaluate GreaterThan operation over two value
func EvaluateGreaterThanEqual ¶
EvaluateGreaterThanEqual will evaluate GreaterThanEqual operation over two value
func EvaluateLesserThan ¶
EvaluateLesserThan will evaluate LesserThan operation over two value
func EvaluateLesserThanEqual ¶
EvaluateLesserThanEqual will evaluate LesserThanEqual operation over two value
func EvaluateLogicAnd ¶
EvaluateLogicAnd will evaluate LogicalAnd operation over two value
func EvaluateLogicOr ¶
EvaluateLogicOr will evaluate LogicalOr operation over two value
func EvaluateLogicSingle ¶
EvaluateLogicSingle will evaluate single expression value
func EvaluateModulo ¶
EvaluateModulo will evaluate modulo operation over two value
func EvaluateMultiplication ¶
EvaluateMultiplication will evaluate multiplication operation over two value
func EvaluateNotEqual ¶
EvaluateNotEqual will evaluate NotEqual operation over two value
func EvaluateSubtraction ¶
EvaluateSubtraction will evaluate subtraction operation over two value
func GetAttributeInterface ¶
GetAttributeInterface will retrieve a members variable value as usable interface.
func GetAttributeList ¶
GetAttributeList will populate list of struct's public member variable.
func GetAttributeType ¶
GetAttributeType will return the type of a specific member variable
func GetAttributeValue ¶
GetAttributeValue will retrieve a members variable value.
func GetBaseKind ¶
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 ¶
GetFunctionList get list of functions in a struct instance
func GetFunctionParameterTypes ¶
GetFunctionParameterTypes get list of parameter types of specific function in a struct instance
func GetFunctionReturnTypes ¶
GetFunctionReturnTypes get list of return types of specific function in a struct instance
func GetMapArrayValue ¶
func GetMapArrayValue(mapArray, selector interface{}) (ret interface{}, err error)
GetMapArrayValue get value of map, array atau slice by its selector value
func InvokeFunction ¶
func InvokeFunction(obj reflect.Value, methodName string, param []reflect.Value) (retval []reflect.Value, err error)
InvokeFunction invokes a specific function in a struct instance, using parameters array
func IsAttributeArray ¶
IsAttributeArray validate if a member variable is an array or a slice.
func IsAttributeMap ¶
IsAttributeMap validate if a member variable is a map.
func IsAttributeNilOrZero ¶
IsAttributeNilOrZero validate if a member variable is nil or zero.
func IsValidField ¶
IsValidField validates if an instance struct have a field with such name
func ParseJSONRuleset ¶
ParseJSONRuleset accepts a byte array containing an array of rules in JSON format to be parsed into GRule syntax.
func ParseRule ¶
ParseRule Accepts a struct of GruleJSON rule and returns the parsed string of GRule.
func SetAttributeInterface ¶
SetAttributeInterface will try to set a member variable value with a value from an interface
func SetAttributeValue ¶
SetAttributeValue will try to set a member variable value with a new one.
func SetMapArrayValue ¶
SetMapArrayValue will set a value into map array indicated by a selector
func ValueToInterface ¶
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 CloneRecord ¶
type CloneRecord struct { OriginAstID string CloneAstID string OriginInstance interface{} CloneInstance interface{} }
CloneRecord contains information about all AST versions, instance, their cloned version and cloned instance.
type CloneTable ¶
type CloneTable struct {
Records map[string]*CloneRecord
}
CloneTable will stores all meta information about AST object being cloned under one KnowledgeBase.
func NewCloneTable ¶
func NewCloneTable() *CloneTable
NewCloneTable create new instance of CloneTable
func (*CloneTable) IsCloned ¶
func (tab *CloneTable) IsCloned(astID string) bool
IsCloned will check if an AST object with identified astId has a clone.
func (*CloneTable) MarkCloned ¶
func (tab *CloneTable) MarkCloned(originAst, cloneAst string, origin, clone interface{})
MarkCloned will record that an Ast object are now been cloned, so all other cloned object should reference to the newly cloned Ast object
type FileResource ¶
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 ¶
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 NewFileResourceBundle ¶
func NewFileResourceBundle(basePath string, pathPattern ...string) *FileResourceBundle
NewFileResourceBundle creates new instance of FileResourceBundle struct basePath denotes the directory location where the file is located. pathPattern are list of paths that filters the files. Its important that the pattern will include the base path as it filter. For example, if the base path is "/some/base/path" The pattern to accept all GRL file is "/some/base/path/**/*.grl". This will accept all *.grl files under /some/base/path and its directories.
func (*FileResourceBundle) Load ¶
func (bundle *FileResourceBundle) Load() ([]Resource, error)
Load all file resources that locateed under BasePath that conform to the PathPattern.
func (*FileResourceBundle) MustLoad ¶
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 ¶
GITResource resource implementation that loaded from GIT
func (*GITResource) Load ¶
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 ¶
func (res *GITResource) String() string
String will state the resource url.
type GITResourceBundle ¶
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 NewGITResourceBundle ¶
func NewGITResourceBundle(url string, pathPattern ...string) *GITResourceBundle
NewGITResourceBundle will create a new instance of GITResourceBundle url is the GIT http/https url. pathPattern are list of file pattern (glob) to filter files located in the repository
func (*GITResourceBundle) Load ¶
func (bundle *GITResourceBundle) Load() ([]Resource, error)
Load will load the file from your git repository
func (*GITResourceBundle) MustLoad ¶
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 GruleErrorReporter ¶
type GruleErrorReporter struct { *antlr.DefaultErrorListener // Embed default which ensures we fit the interface Errors []error }
GruleErrorReporter is an implementation of ErrorListener interface by antlr. The purpose is to capture errors during lexer tokenization and parsing.
func (*GruleErrorReporter) AddError ¶
func (c *GruleErrorReporter) AddError(err error)
AddError simply add an error into this reporter
func (*GruleErrorReporter) Error ¶
func (c *GruleErrorReporter) Error() string
Error return an error text. This function is there for compatibility reason.
func (*GruleErrorReporter) HasError ¶
func (c *GruleErrorReporter) HasError() bool
HasError check if this reporter has an error
func (*GruleErrorReporter) SyntaxError ¶
func (c *GruleErrorReporter) SyntaxError(recognizer antlr.Recognizer, offendingSymbol interface{}, line, column int, msg string, e antlr.RecognitionException)
SyntaxError call back which will be called upon parsing error
type GruleJSON ¶
type GruleJSON struct { Name string `json:"name"` Description string `json:"desc"` Salience int `json:"salience"` When interface{} `json:"when"` Then []interface{} `json:"then"` }
GruleJSON represents a rule in JSON format
type JSONResource ¶
type JSONResource struct {
// contains filtered or unexported fields
}
JSONResource will parse rules in JSON fromat from underlying resource provider.
func (*JSONResource) Load ¶
func (jr *JSONResource) Load() ([]byte, error)
Load will load the underlying Resource and parse the JSON rules into standard GRule syntax.
func (*JSONResource) String ¶
func (jr *JSONResource) String() string
String will state the resource source.
type JSONResourceBundle ¶
type JSONResourceBundle struct {
// contains filtered or unexported fields
}
JSONResourceBundle will parse a set of rules in JSON format from an underlying bundle resource provider.
func (*JSONResourceBundle) Load ¶
func (jrb *JSONResourceBundle) Load() ([]Resource, error)
Load will load the underlying ResourceBundle and parse the JSON rules into standard GRule syntax.
func (*JSONResourceBundle) MustLoad ¶
func (jrb *JSONResourceBundle) MustLoad() []Resource
MustLoad operates the same as load except it will panic in the event of an error.
type ReaderResource ¶
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 ¶
ResouceBundle is a helper struct to help load multiple resource at once.
func NewJSONResourceBundleFromBundle ¶
func NewJSONResourceBundleFromBundle(bundle ResouceBundle) ResouceBundle
NewJSONResourceBundleFromBundle innstantiates a new bundled JSON resource parser from an underlying ResourceBundle.
type Resource ¶
Resource should be implemented by any resource model so it can be loaded and parsed by the grule parser.
func NewBytesResource ¶
NewBytesResource will create a new Resource using a byte array.
func NewFileResource ¶
NewFileResource will create a new Resource using a file located in path.
func NewJSONResourceFromResource ¶
NewJSONResourceFromResource innstantiates a new JSON resource parser from an underlying Resource.
func NewReaderResource ¶
NewReaderResource will create a new Resource using a common reader.
func NewURLResource ¶
NewURLResource will create a new Resource using a resource as located in the url
type URLResource ¶
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.