class DataMetaByteSer::RendCtx
Rendering context with rendering-related properties and settings.
Attributes
Base name of the type, without a namespace.
Field currently on the context.
Set of imports if any, each as symbol.
DataMeta DOM Model on the context.
Java package.
Record currently worked on.
The data type of the entity on the context.
Public Class Methods
Creates a new context.
# File lib/dataMetaByteSer/util.rb, line 66 def initialize; @imps = Set.new end
Public Instance Methods
Add an import to the context, returns self for call chaining.
# File lib/dataMetaByteSer/util.rb, line 82 def <<(import) @imps << import.to_sym if import self end
Effective field type
# File lib/dataMetaByteSer/util.rb, line 102 def fType isMapping ? @refType.fromT : @fld.dataType end
Setter for the field on the context, the field currently worked on.
# File lib/dataMetaByteSer/util.rb, line 71 def fld=(val); @fld = val end
Formats imports into Java source, sorted.
# File lib/dataMetaByteSer/util.rb, line 90 def importsText @imps.to_a.map{|k| "import #{k};"}.sort.join("\n") end
Initialize the context with the model, the record, the package and the basename. Returns self for call chaining.
# File lib/dataMetaByteSer/util.rb, line 77 def init(model, rec, pckg, baseName); @model = model; @rec = rec; @pckg = pckg; @baseName = baseName; self end
Determines if the refType is a DataMetaDom::Mapping.
# File lib/dataMetaByteSer/util.rb, line 97 def isMapping @refType.kind_of?(DataMetaDom::Mapping) && !@refType.kind_of?(DataMetaDom::BitSet) end
Readwrap
# File lib/dataMetaByteSer/util.rb, line 107 def rw isMapping ? lambda{|t| "new #{condenseType(@fld.dataType.type, self)}(#{t})"} : lambda{|t| t} end
Getter name for the current field, if the type is Mapping, includes .getKey()
too.
# File lib/dataMetaByteSer/util.rb, line 114 def valGetter "#{DataMetaDom.getterName(@fld)}()" + ( isMapping ? '.getKey()' : '') end