Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Getting FreeMarker to Wrap EMap as SimpleHash instead of SimpleSequence?
Getting FreeMarker to Wrap EMap as SimpleHash instead of SimpleSequence? [message #989760] Fri, 07 December 2012 15:57 Go to next message
Brandon Lewis is currently offline Brandon LewisFriend
Messages: 268
Registered: May 2012
Senior Member
I'm using FreeMarker for text output templating in my tool and passing my EMF model to FreeMarker's DEFAULT ObjectWrapper class.

So far, things have been working right out of the box.

Then I get to EMap. EMap seems to be implemented as an EList of Map entries. FreeMarker's ObjectWrapper appears to wrap that in a SimpleSequence, thus getting rid of my EMap interface.

I can't do ${myVar.getMyMap().get(myKey)} because FreeMarker says something like:

Expected hash. myVar.getMyMap() evaluated instead to FreeMarker.Template.SimpleSequence.


So, I think I have to make my own ObjectWrapper to sort this out. Has anyone done this, or does anyone know of a FreeMarker EMFObjectWrapper?

It's been a long week of getting my butt kicked by various things.
Re: Getting FreeMarker to Wrap EMap as SimpleHash instead of SimpleSequence? [message #989833 is a reply to message #989760] Sat, 08 December 2012 06:01 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Brandon,

If you use Suppress EMF Types, it will be surfaced as a java.util.Map in
the API so maybe that will make this tool happier.

On 07/12/2012 4:57 PM, Brandon Lewis wrote:
> I'm using FreeMarker for text output templating in my tool and passing
> my EMF model to FreeMarker's DEFAULT ObjectWrapper class.
>
> So far, things have been working right out of the box.
>
> Then I get to EMap. EMap seems to be implemented as an EList of Map
> entries. FreeMarker's ObjectWrapper appears to wrap that in a
> SimpleSequence, thus getting rid of my EMap interface.
>
> I can't do ${myVar.getMyMap().get(myKey)} because FreeMarker says
> something like:
>
> Expected hash. myVar.getMyMap() evaluated instead to
> FreeMarker.Template.SimpleSequence.
>
>
> So, I think I have to make my own ObjectWrapper to sort this out. Has
> anyone done this, or does anyone know of a FreeMarker EMFObjectWrapper?
>
> It's been a long week of getting my butt kicked by various things.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Getting FreeMarker to Wrap EMap as SimpleHash instead of SimpleSequence? [message #989888 is a reply to message #989833] Sun, 09 December 2012 13:36 Go to previous message
Brandon Lewis is currently offline Brandon LewisFriend
Messages: 268
Registered: May 2012
Senior Member
I'm happy to report that Suppressing EMF Types works and that's enough for FreeMarker to be able to see Java.util.Map and declare its own TemplateModel of SimpleHash for it.

We've got a couple of places in the code where we we are using EList's move methods, so I've got some minor tweaks to do since we're dealing with Lists now (since EList is suppressed too). But not a big deal - easier than figuring out my own ObjectWrapper in FreeMarker.

I appreciate your quick and accurate help Ed.

Brandon
Previous Topic:opposite reference from Map$Entry to its container
Next Topic:is there a way to manually build xcore instead of automatic build when something changes?
Goto Forum:
  


Current Time: Wed Apr 24 20:08:21 GMT 2024

Powered by FUDForum. Page generated in 0.03857 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top