Package eu.bandm.tools.umod
Class UMod2java.V_compileFieldDefs
java.lang.Object
eu.bandm.tools.umod.UMod.Visitor
eu.bandm.tools.umod.UMod2java.V_compileFieldDefs
- Enclosing class:
- UMod2java
-
Field Summary
Modifier and TypeFieldDescriptionprotected final GeneratedClass
(package private) UMod.ClassDef
protected final boolean
protected final int
protected final boolean
protected final UMod2visitors
Fields inherited from class eu.bandm.tools.umod.UMod.Visitor
result
-
Constructor Summary
ConstructorDescriptionV_compileFieldDefs
(GeneratedClass bv, UMod2visitors vc, boolean getterfunctions, boolean setterfunctions, boolean monolithic) Only constructor, sets all constant configuration values. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
action
(UMod.ClassDef cd) Setscurclass
and descends to field defs and sub class defs.protected void
action
(UMod.FieldDef fd) protected UMod.FieldDef
Finds a field defintion with the same name as its argument in a true super class of the class definition containing this argument.protected void
protected void
protected void
makePrefixMultipleContainsKey
(String fieldname, List<UMod.Type> types) protected void
makePrefixMultiplePut
(String fieldname, List<UMod.Type> types, boolean topIsOpt, boolean lastIsListoid, boolean lastIsMultimap) For a field declaration ...protected void
makeSetGet
(UMod.FieldDef fd, boolean getterfunctions, boolean setterfunctions, boolean isabstract) Methods inherited from class eu.bandm.tools.umod.UMod.Visitor
action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, descend_Forest$extBySequence, getResult, match
-
Field Details
-
basevisitor
-
visitorcompiler
-
getterfunctions
protected final boolean getterfunctions -
setterfunctions
protected final boolean setterfunctions -
modif_field
protected final int modif_field -
curclass
UMod.ClassDef curclass
-
-
Constructor Details
-
V_compileFieldDefs
public V_compileFieldDefs(GeneratedClass bv, UMod2visitors vc, boolean getterfunctions, boolean setterfunctions, boolean monolithic) Only constructor, sets all constant configuration values. The work is done by callingUMod.Visitor.match(eu.bandm.tools.umod.UMod.Item)
.
-
-
Method Details
-
findSuperField
Finds a field defintion with the same name as its argument in a true super class of the class definition containing this argument. -
action
Setscurclass
and descends to field defs and sub class defs.- Overrides:
action
in classUMod.Visitor
-
action
- Overrides:
action
in classUMod.Visitor
-
makeSetGet
protected void makeSetGet(UMod.FieldDef fd, boolean getterfunctions, boolean setterfunctions, boolean isabstract) -
makePrefixMultiplePut
protected void makePrefixMultiplePut(String fieldname, List<UMod.Type> types, boolean topIsOpt, boolean lastIsListoid, boolean lastIsMultimap) For a field declaration ...f: A -> B -> C -> D f: A -> SEQ (C -> D) // at each position; "SEQ.." f: A -> int->C -> D // is treated as "int->.."
... we generate ...put_f(a, Map[B,Map[C,D]]) // resp. put_f(a, Seq[Map[C,D]] ) put_f(a, b, Map[C,D]) putAll_f(a, b, x:Map[C,D]) put_f(a, b, c, d){ m0=g.get(a); if(m0==null){m0=new...();f.put(a,m0);} m1=m0.get(b); if(m1==null){m1=new...();m0.put(b,m0);} m1.put(c, d); // resp. m1.putAll(x); }
(The "addAll(..)" method is only realized at the very end of this chain. Up to now it did not show up as urgently requested with shorter prefices. In the example above you currently have to useif (get_f().containsKey(a)) f.get().get(a).putAll(x:MAP[b->MAP[c->d]]) else f.get().put(NEW COPY OF (x:MAP[b->MAP[c->d]]))
A future version could additionally generate such code, if requested by a command line switch.)
The chain of processed types always ends with a type with more than one element on its "right side", like SET or REL, of primitive type (or OPT, etc.) For a field declaration ...f: A -> B -> SET C
... we generate ...put_f(a, Map[B,SET C]) put_f(a, b, c:SET c){ m0=g.get(a); if(m0==null){m0=new...();f.put(a,m0);} m0.put(b,c); } addAll_f(a, b, x:SET[C]){ add_f(a, b, c){ m0=g.get(a); if(m0==null){m0=new...();f.put(a,m0);} m1=m0.get(b); if(m1==null){m1=new set...();m0.put(b,m0);} m1.add(c); // resp. m1.addAll(x); }
On the "reading side", the method "containsKey()" is generared for all prefices of the signature. A result of "true" implies the existance of all intermediate container classes and "get(..).get(..).get(..)" can be called conventionally.
in case of "put()", both following cases are treated identical:f: A -> B -> C ->D f: A -> OPT B -> C ->D
If the user calls a "put_f(a, b, c...)", then they want want that there exists an f(a), in any case, no matter whether it already existed. But if a "set_F(a, null)" has happened, then the attempt "put_f(a, b, X)" is a misuse and a nullpointer exception.
The treatment of multiple "get" is of course different:f: A -> B -> C g: A -> OPT B -> C
get_f(a).get(b) throws an exception if containsKey_f(a) is f false.
get_g(a).get(b) throws an exception if containsKey_f(a) is f false or if get_g(a) return null.
In no case "null" represents an empty map. BUT on toplevel "f:OPT(A -> B ->C)" the call "put_f(a, b, c)" will generate the toplevel map, if necessary. -
makeMultiplePut
-
makePrefixMultipleContainsKey
-
makeMultipleContainsKey
-