gitee.com/zhongguo168a/gocodes@v0.0.0-20230609140523-e1828349603f/datax/modifyx/modify-root.go (about)

     1  package modifyx
     2  
     3  import "strings"
     4  
     5  func NewRoot(source *Source) *Root {
     6  	obj := &Root{}
     7  	obj.Object = NewObject(obj)
     8  	obj.source = source
     9  	return obj
    10  }
    11  
    12  type Root struct {
    13  	*Object
    14  
    15  	source *Source
    16  	// 默认的上下文
    17  	ctx interface{}
    18  }
    19  
    20  func (s *Root) RefSetContext(ctx interface{}) {
    21  	s.ctx = ctx
    22  }
    23  
    24  func (s *Root) RefClassId() string {
    25  	return s.source.id
    26  }
    27  
    28  func (s *Root) RefClassKey() string {
    29  	return s.source.ClassKey()
    30  }
    31  
    32  func (s *Root) RefClassCatalog() string {
    33  	return s.source.ClassCatalog()
    34  }
    35  func (s *Root) RefClassType() string {
    36  	return s.source.ClassType()
    37  }
    38  
    39  func (s *Root) RefSource() *Source {
    40  	return s.source
    41  }
    42  
    43  func (s *Root) RefDispose() {
    44  	s.source.Dispose()
    45  	s.source = nil
    46  }
    47  
    48  func ParseKey(key string) (kind, id string) {
    49  	arr := strings.Split(key, "/")
    50  	kind = arr[0]
    51  	id = arr[1]
    52  	return
    53  }