class DataMetaByteSer::RendCtx

Rendering context with rendering-related properties and settings.

Attributes

baseName[RW]

Base name of the type, without a namespace.

fld[R]

Field currently on the context.

imps[RW]

Set of imports if any, each as symbol.

model[RW]

DataMeta DOM Model on the context.

pckg[RW]

Java package.

rec[RW]

Record currently worked on.

refType[RW]

The data type of the entity on the context.

Public Class Methods

new() click to toggle source

Creates a new context.

# File lib/dataMetaByteSer/util.rb, line 66
def initialize; @imps = Set.new end

Public Instance Methods

<<(import) click to toggle source

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
fType() click to toggle source

Effective field type

# File lib/dataMetaByteSer/util.rb, line 102
def fType
    isMapping ? @refType.fromT : @fld.dataType
end
fld=(val) click to toggle source

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
importsText() click to toggle source

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
init(model, rec, pckg, baseName) click to toggle source

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
isMapping() click to toggle source

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
rw() click to toggle source

Readwrap

# File lib/dataMetaByteSer/util.rb, line 107
def rw
    isMapping ? lambda{|t| "new #{condenseType(@fld.dataType.type, self)}(#{t})"} : lambda{|t| t}
end
valGetter() click to toggle source

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