Class: DataMetaByteSer::RendCtx

Inherits:
Object
  • Object
show all
Defined in:
lib/dataMetaByteSer/util.rb

Overview

Rendering context with rendering-related properties and settings.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRendCtx

Creates a new context.



66
# File 'lib/dataMetaByteSer/util.rb', line 66

def initialize; @imps = Set.new end

Instance Attribute Details

#baseNameObject

Base name of the type, without a namespace.



53
54
55
# File 'lib/dataMetaByteSer/util.rb', line 53

def baseName
  @baseName
end

#fldObject

Field currently on the context.



61
62
63
# File 'lib/dataMetaByteSer/util.rb', line 61

def fld
  @fld
end

#impsObject

Set of imports if any, each as symbol.



44
45
46
# File 'lib/dataMetaByteSer/util.rb', line 44

def imps
  @imps
end

#modelObject

DataMeta DOM Model on the context.



35
36
37
# File 'lib/dataMetaByteSer/util.rb', line 35

def model
  @model
end

#pckgObject

Java package.



49
50
51
# File 'lib/dataMetaByteSer/util.rb', line 49

def pckg
  @pckg
end

#recObject

Record currently worked on.



39
40
41
# File 'lib/dataMetaByteSer/util.rb', line 39

def rec
  @rec
end

#refTypeObject

The data type of the entity on the context.



57
58
59
# File 'lib/dataMetaByteSer/util.rb', line 57

def refType
  @refType
end

Instance Method Details

#<<(import) ⇒ Object

Add an import to the context, returns self for call chaining.



82
83
84
85
# File 'lib/dataMetaByteSer/util.rb', line 82

def <<(import)
    @imps << import.to_sym if import
    self
end

#fTypeObject

Effective field type



102
103
104
# File 'lib/dataMetaByteSer/util.rb', line 102

def fType
    isMapping ? @refType.fromT : @fld.dataType
end

#importsTextObject

Formats imports into Java source, sorted.



90
91
92
# File 'lib/dataMetaByteSer/util.rb', line 90

def importsText
    @imps.to_a.map{|k| "import #{k};"}.sort.join("\n")
end

#init(model, rec, pckg, baseName) ⇒ Object

Initialize the context with the model, the record, the package and the basename. Returns self for call chaining.



77
# File 'lib/dataMetaByteSer/util.rb', line 77

def init(model, rec, pckg, baseName); @model = model; @rec = rec; @pckg = pckg; @baseName = baseName; self end

#isMappingObject

Determines if the refType is a DataMetaDom::Mapping.



97
98
99
# File 'lib/dataMetaByteSer/util.rb', line 97

def isMapping
    @refType.kind_of?(DataMetaDom::Mapping) && !@refType.kind_of?(DataMetaDom::BitSet)
end

#rwObject

Readwrap



107
108
109
# File 'lib/dataMetaByteSer/util.rb', line 107

def rw
    isMapping ? lambda{|t| "new #{condenseType(@fld.dataType.type, self)}(#{t})"} : lambda{|t| t}
end

#valGetterObject

Getter name for the current field, if the type is Mapping, includes .getKey() too.



114
115
116
# File 'lib/dataMetaByteSer/util.rb', line 114

def valGetter
    "#{DataMetaDom.getterName(@fld)}()" + ( isMapping ? '.getKey()' : '')
end