Skip to main content



      Home
Home » Modeling » EMF » Does Template support function definenation?
Does Template support function definenation? [message #376682] Wed, 22 January 2003 09:41 Go to next message
Eclipse UserFriend
Hi all,

In JSP, I can use <%! %> define my owner function!
I think it is useful. And I try to do it in emf template,
but it not works, I want to do something like this:

<%!
private String getCategory(String name) {
...
return ...;
}
%>

Regards,

Eric Suen
Re: Does Template support function definenation? [message #376697 is a reply to message #376682] Fri, 24 January 2003 09:14 Go to previous messageGo to next message
Eclipse UserFriend
--------------191AF4F88E5E215D1570B184
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Eric,

No, we don't support that. But the initial jet directive can contain a
"skeleton" attribute that points to a .java file which will be used in
place of the default skeleton. The .java skeleton file could look like
this:

/**
*
*/
package a.b.c;

import org.eclipse.emf.codegen.*;

/**
*
*/
public class SKELETON_CLASS
{
/**
*
*/
public static String generate(Object model)
{
return "";
}
}

Eric Suen wrote:

> Hi all,
>
> In JSP, I can use <%! %> define my owner function!
> I think it is useful. And I try to do it in emf template,
> but it not works, I want to do something like this:
>
> <%!
> private String getCategory(String name) {
> ...
> return ...;
> }
> %>
>
> Regards,
>
> Eric Suen

--
Ed Merks


--------------191AF4F88E5E215D1570B184
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Eric,
<p>No, we don't support that.&nbsp; But the initial jet directive can contain
a "skeleton" attribute that points to a .java file which will be used in
place of the default skeleton.&nbsp; The .java skeleton file could look
like this:
<blockquote>/**
<br>&nbsp;*
<br>&nbsp;*/
<br>package a.b.c;
<p>import org.eclipse.emf.codegen.*;
<p>/**
<br>&nbsp;*
<br>&nbsp;*/
<br>public class SKELETON_CLASS
<br>{
<br>&nbsp; /**
<br>&nbsp;&nbsp; *
<br>&nbsp;&nbsp; */
<br>&nbsp; public static String generate(Object model)
<br>&nbsp; {
<br>&nbsp;&nbsp;&nbsp; return "";
<br>&nbsp; }
<br>}</blockquote>

<p><br>Eric Suen wrote:
<blockquote TYPE=CITE>Hi all,
<p>&nbsp;&nbsp;&nbsp; In JSP, I can use &lt;%! %> define my owner function!
<br>I think it is useful. And I try to do it in emf template,
<br>but it not works, I want to do something like this:
<p>&lt;%!
<br>&nbsp;private String getCategory(String name) {
<br>&nbsp;&nbsp; ...
<br>&nbsp;&nbsp; return ...;
<br>&nbsp;}
<br>%>
<p>Regards,
<p>Eric Suen</blockquote>

<p>--
<br>Ed Merks
<br>&nbsp;</html>

--------------191AF4F88E5E215D1570B184--
Re: Does Template support function definenation? [message #376737 is a reply to message #376697] Thu, 30 January 2003 08:43 Go to previous message
Eclipse UserFriend
This is a multi-part message in MIME format.

------=_NextPart_000_0041_01C2C8A8.B2907DF0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Thanks,

I have found another way to do this, use inner class, like this:

<%
class Category {
private Map categories =3D null;
=20
private String LOCATION =3D "Location";
private String SIZE =3D "Size";
=20
public Category() {
if (categories =3D=3D null) {
categories =3D new HashMap();
categories.put("x", LOCATION);
categories.put("y", LOCATION);
=20
categories.put("width", SIZE);
categories.put("height", SIZE);
}
}
=20
public String getCategory(String name) {
String category;
category =3D (String) categories.get(name);
if (category =3D=3D null) {
category =3D APPEARANCE;
}
return category;
}
}

Category category =3D new Category();
%>

Then I can use category in the following code like this:

<%for (Iterator i=3DgenClass.getPropertyFeatures().iterator(); =
i.hasNext();) { GenFeature genFeature =3D (GenFeature)i.next();%>
add<%=3DgenFeature.getCapName()%>PropertyDescriptor(object, =
"<%=3Dcategory.getCategory(genFeature.getName())%>");
<%}%>

Regards,

Eric Suen
"Ed Merks" <merks@ca.ibm.com> ??????:3E314A5B.B0846982@ca.ibm.com...
Eric,=20
No, we don't support that. But the initial jet directive can contain =
a "skeleton" attribute that points to a .java file which will be used in =
place of the default skeleton. The .java skeleton file could look like =
this:=20

/**=20
*=20
*/=20
package a.b.c;=20
import org.eclipse.emf.codegen.*;=20

/**=20
*=20
*/=20
public class SKELETON_CLASS=20
{=20
/**=20
*=20
*/=20
public static String generate(Object model)=20
{=20
return "";=20
}=20
}


Eric Suen wrote:=20

Hi all,=20
In JSP, I can use <%! %> define my owner function!=20
I think it is useful. And I try to do it in emf template,=20
but it not works, I want to do something like this:=20

<%!=20
private String getCategory(String name) {=20
...=20
return ...;=20
}=20
%>=20

Regards,=20

Eric Suen

--=20
Ed Merks=20
=20

------=_NextPart_000_0041_01C2C8A8.B2907DF0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1126" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3D&#23435;&#20307; size=3D2>Thanks,</FONT></DIV>
<DIV><FONT face=3D&#23435;&#20307; size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D&#23435;&#20307; size=3D2>&nbsp;&nbsp;&nbsp; I have =
found another way to do=20
this, use inner class, like this:</FONT></DIV>
<DIV><FONT face=3D&#23435;&#20307; size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D&#23435;&#20307; size=3D2>&lt;%<BR>class Category =
{<BR>&nbsp;private Map=20
categories =3D null;<BR>&nbsp;<BR>&nbsp;private String LOCATION =3D=20
"Location";<BR>&nbsp;private String SIZE =3D =
"Size";<BR>&nbsp;<BR>&nbsp;public=20
Category() {<BR>&nbsp;&nbsp;if (categories =3D=3D null)=20
{<BR>&nbsp;&nbsp;&nbsp;categories =3D new=20
HashMap();<BR>&nbsp;&nbsp;&nbsp;categories.put( "x",=20
LOCATION);<BR>&nbsp;&nbsp;&nbsp;categories.put( "y",=20
LOCATION);<BR>&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;categories.put( "wid=
th",=20
SIZE);<BR>&nbsp;&nbsp;&nbsp;categories.put("height ",=20
SIZE);<BR>&nbsp;&nbsp;}<BR>&nbsp;}<BR>&nbsp; <BR>&nbsp;public String=20
getCategory(String name) {<BR>&nbsp;&nbsp;String=20
category;<BR>&nbsp;&nbsp;category =3D (String)=20
categories.get(name);<BR>&nbsp;&nbsp;if (category =3D=3D null)=20
{<BR>&nbsp;&nbsp;&nbsp;category =3D=20
APPEARANCE;<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;return=20
category;<BR>&nbsp;}<BR>}</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3D&#23435;&#20307; size=3D2>Category category =3D new=20
Category();<BR>%&gt;<BR></FONT></DIV>
<DIV><FONT face=3D&#23435;&#20307; size=3D2>Then I can use category in =
the following code like=20
this:</FONT></DIV>
<DIV><FONT face=3D&#23435;&#20307; size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D&#23435;&#20307; size=3D2>&lt;%for (Iterator=20
i=3DgenClass.getPropertyFeatures().iterator(); i.hasNext();) { =
GenFeature=20
genFeature =3D=20
(GenFeature)i.next();%&gt;<BR> &nbsp;&nbsp;&nbsp;add&lt;%=3DgenFeature.get=
CapName()%&gt;PropertyDescriptor(object,=20
" &lt;%=3Dcategory.getCategory(genFeature.getName())%& gt; ");<BR>&lt;%}%&gt=
;<BR></FONT><FONT=20
face=3D&#23435;&#20307; size=3D2></DIV></FONT>
<DIV><FONT face=3D&#23435;&#20307; size=3D2>Regards,</FONT></DIV>
<DIV><FONT face=3D&#23435;&#20307; size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D&#23435;&#20307; size=3D2>Eric Suen</FONT></DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ed Merks" &lt;<A =
href=3D"mailto:merks@ca.ibm.com">merks@ca.ibm.com</A>&gt;=20
=
&#20889;&#20837;&#28040;&#24687;&#26032; &#38395;:3E314A5B.B0846982@ca.ibm=
..com...</DIV>Eric,=20
<P>No, we don't support that.&nbsp; But the initial jet directive can =
contain=20
a "skeleton" attribute that points to a .java file which will be used =
in place=20
of the default skeleton.&nbsp; The .java skeleton file could look like =
this:=20
<BLOCKQUOTE>/** <BR>&nbsp;* <BR>&nbsp;*/ <BR>package a.b.c;=20
<P>import org.eclipse.emf.codegen.*;=20
<P>/** <BR>&nbsp;* <BR>&nbsp;*/ <BR>public class SKELETON_CLASS =
<BR>{=20
<BR>&nbsp; /** <BR>&nbsp;&nbsp; * <BR>&nbsp;&nbsp; */ <BR>&nbsp; =
public=20
static String generate(Object model) <BR>&nbsp; { =
<BR>&nbsp;&nbsp;&nbsp;=20
return ""; <BR>&nbsp; } <BR>}</P></BLOCKQUOTE>
<P><BR>Eric Suen wrote:=20
<BLOCKQUOTE TYPE=3D"CITE">Hi all,=20
<P>&nbsp;&nbsp;&nbsp; In JSP, I can use &lt;%! %&gt; define my owner =

function! <BR>I think it is useful. And I try to do it in emf =
template,=20
<BR>but it not works, I want to do something like this:=20
<P>&lt;%! <BR>&nbsp;private String getCategory(String name) {=20
<BR>&nbsp;&nbsp; ... <BR>&nbsp;&nbsp; return ...; <BR>&nbsp;} =
<BR>%&gt;=20
<P>Regards,=20
<P>Eric Suen</P></BLOCKQUOTE>
<P>-- <BR>Ed Merks <BR>&nbsp; </P></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_0041_01C2C8A8.B2907DF0--
Re: Does Template support function definenation? [message #376744 is a reply to message #376737] Thu, 30 January 2003 08:41 Go to previous message
Eclipse UserFriend
--------------8ABE3799E10E568F84904417
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Eric,

Cool! That's a good idea. Thanks for providing the information on the
forum.

Eric Suen wrote:

> Thanks, I have found another way to do this, use inner class, like
> this: <%
> class Category {
> private Map categories = null;
>
> private String LOCATION = "Location";
> private String SIZE = "Size";
>
> public Category() {
> if (categories == null) {
> categories = new HashMap();
> categories.put("x", LOCATION);
> categories.put("y", LOCATION);
>
> categories.put("width", SIZE);
> categories.put("height", SIZE);
> }
> }
>
> public String getCategory(String name) {
> String category;
> category = (String) categories.get(name);
> if (category == null) {
> category = APPEARANCE;
> }
> return category;
> }
> } Category category = new Category();
> %>Then I can use category in the following code like this: <%for
> (Iterator i=genClass.getPropertyFeatures().iterator(); i.hasNext();) {
> GenFeature genFeature = (GenFeature)i.next();%>
> add<%=genFeature.getCapName()%>PropertyDescriptor(object,
> "<%=category.getCategory(genFeature.getName())%>");
> <%}%>Regards, Eric Suen
>
> "Ed Merks" <merks@ca.ibm.com>
> ??????:3E314A5B.B0846982@ca.ibm.com...Eric,
>
> No, we don't support that. But the initial jet directive
> can contain a "skeleton" attribute that points to a .java
> file which will be used in place of the default skeleton.
> The .java skeleton file could look like this:
>
> /**
> *
> */
> package a.b.c;
>
> import org.eclipse.emf.codegen.*;
>
> /**
> *
> */
> public class SKELETON_CLASS
> {
> /**
> *
> */
> public static String generate(Object model)
> {
> return "";
> }
> }
>
>
> Eric Suen wrote:
>
> > Hi all,
> >
> > In JSP, I can use <%! %> define my owner function!
> > I think it is useful. And I try to do it in emf template,
> > but it not works, I want to do something like this:
> >
> > <%!
> > private String getCategory(String name) {
> > ...
> > return ...;
> > }
> > %>
> >
> > Regards,
> >
> > Eric Suen
>
> --
> Ed Merks
>
>
--
Ed Merks


--------------8ABE3799E10E568F84904417
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<body bgcolor="#FFFFFF">
Eric,
<p>Cool!&nbsp; That's a good idea. Thanks for providing the information
on the forum.
<p>Eric Suen wrote:
<blockquote TYPE=CITE><style></style>
<font face="??"><font size=-1>Thanks,</font></font>&nbsp;<font face="??"><font size=-1>&nbsp;&nbsp;&nbsp;
I have found another way to do this, use inner class, like this:</font></font>&nbsp;<font face="??"><font size=-1>&lt;%</font></font>
<br><font face="??"><font size=-1>class Category {</font></font>
<br><font face="??"><font size=-1>&nbsp;private Map categories = null;</font></font>
<p><font face="??"><font size=-1>&nbsp;private String LOCATION = "Location";</font></font>
<br><font face="??"><font size=-1>&nbsp;private String SIZE = "Size";</font></font>
<p><font face="??"><font size=-1>&nbsp;public Category() {</font></font>
<br><font face="??"><font size=-1>&nbsp; if (categories == null) {</font></font>
<br><font face="??"><font size=-1>&nbsp;&nbsp; categories = new HashMap();</font></font>
<br><font face="??"><font size=-1>&nbsp;&nbsp; categories.put("x", LOCATION);</font></font>
<br><font face="??"><font size=-1>&nbsp;&nbsp; categories.put("y", LOCATION);</font></font>
<p><font face="??"><font size=-1>&nbsp;&nbsp; categories.put("width", SIZE);</font></font>
<br><font face="??"><font size=-1>&nbsp;&nbsp; categories.put("height",
SIZE);</font></font>
<br><font face="??"><font size=-1>&nbsp; }</font></font>
<br><font face="??"><font size=-1>&nbsp;}</font></font>
<p><font face="??"><font size=-1>&nbsp;public String getCategory(String
name) {</font></font>
<br><font face="??"><font size=-1>&nbsp; String category;</font></font>
<br><font face="??"><font size=-1>&nbsp; category = (String) categories.get(name);</font></font>
<br><font face="??"><font size=-1>&nbsp; if (category == null) {</font></font>
<br><font face="??"><font size=-1>&nbsp;&nbsp; category = APPEARANCE;</font></font>
<br><font face="??"><font size=-1>&nbsp; }</font></font>
<br><font face="??"><font size=-1>&nbsp; return category;</font></font>
<br><font face="??"><font size=-1>&nbsp;}</font></font>
<br><font face="??"><font size=-1>}</font></font>&nbsp;<font face="??"><font size=-1>Category
category = new Category();</font></font>
<br><font face="??"><font size=-1>%></font></font><font face="??"><font size=-1>Then
I can use category in the following code like this:</font></font>&nbsp;<font face="??"><font size=-1>&lt;%for
(Iterator i=genClass.getPropertyFeatures().iterator(); i.hasNext();) {
GenFeature genFeature = (GenFeature)i.next();%></font></font>
<br><font face="??"><font size=-1>&nbsp;&nbsp; add&lt;%=genFeature.getCapName()%>PropertyDescriptor(object,
"&lt;%=category.getCategory(genFeature.getName())%>");</font ></font>
<br><font face="??"><font size=-1>&lt;%}%></font></font><font face="??"><font size=-1>Regards,</font></font>&nbsp;<font face="??"><font size=-1>Eric
Suen</font></font>
<blockquote dir=ltr
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">"Ed
Merks" &lt;<a href="mailto:merks@ca.ibm.com">merks@ca.ibm.com</a>> ??????:3E314A5B.B0846982@ca.ibm.com...Eric,
<p>No, we don't support that.&nbsp; But the initial jet directive can contain
a "skeleton" attribute that points to a .java file which will be used in
place of the default skeleton.&nbsp; The .java skeleton file could look
like this:
<blockquote>/**
<br>&nbsp;*
<br>&nbsp;*/
<br>package a.b.c;
<p>import org.eclipse.emf.codegen.*;
<p>/**
<br>&nbsp;*
<br>&nbsp;*/
<br>public class SKELETON_CLASS
<br>{
<br>&nbsp; /**
<br>&nbsp;&nbsp; *
<br>&nbsp;&nbsp; */
<br>&nbsp; public static String generate(Object model)
<br>&nbsp; {
<br>&nbsp;&nbsp;&nbsp; return "";
<br>&nbsp; }
<br>}</blockquote>

<p><br>Eric Suen wrote:
<blockquote TYPE="CITE">Hi all,
<p>&nbsp;&nbsp;&nbsp; In JSP, I can use &lt;%! %> define my owner function!
<br>I think it is useful. And I try to do it in emf template,
<br>but it not works, I want to do something like this:
<p>&lt;%!
<br>&nbsp;private String getCategory(String name) {
<br>&nbsp;&nbsp; ...
<br>&nbsp;&nbsp; return ...;
<br>&nbsp;}
<br>%>
<p>Regards,
<p>Eric Suen</blockquote>
--
<br>Ed Merks
<br>&nbsp;</blockquote>
</blockquote>

<p>--
<br>Ed Merks
<br>&nbsp;
</body>
</html>

--------------8ABE3799E10E568F84904417--
Previous Topic:Any way to get resolving ELists on container relationships?
Next Topic:[NEWBIE] library.xsd --> cant see the diagramm
Goto Forum:
  


Current Time: Wed Nov 05 11:33:17 EST 2025

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

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

Back to the top