Home » Modeling » EMF » Does Template support function definenation?
| Does Template support function definenation? [message #376682] |
Wed, 22 January 2003 09:41  |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
--------------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. 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:
<blockquote>/**
<br> *
<br> */
<br>package a.b.c;
<p>import org.eclipse.emf.codegen.*;
<p>/**
<br> *
<br> */
<br>public class SKELETON_CLASS
<br>{
<br> /**
<br> *
<br> */
<br> public static String generate(Object model)
<br> {
<br> return "";
<br> }
<br>}</blockquote>
<p><br>Eric Suen wrote:
<blockquote TYPE=CITE>Hi all,
<p> In JSP, I can use <%! %> 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><%!
<br> private String getCategory(String name) {
<br> ...
<br> return ...;
<br> }
<br>%>
<p>Regards,
<p>Eric Suen</blockquote>
<p>--
<br>Ed Merks
<br> </html>
--------------191AF4F88E5E215D1570B184--
|
|
|
| Re: Does Template support function definenation? [message #376737 is a reply to message #376697] |
Thu, 30 January 2003 08:43  |
Eclipse User |
|
|
|
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宋体 size=3D2>Thanks,</FONT></DIV>
<DIV><FONT face=3D宋体 size=3D2></FONT> </DIV>
<DIV><FONT face=3D宋体 size=3D2> I have =
found another way to do=20
this, use inner class, like this:</FONT></DIV>
<DIV><FONT face=3D宋体 size=3D2></FONT> </DIV>
<DIV><FONT face=3D宋体 size=3D2><%<BR>class Category =
{<BR> private Map=20
categories =3D null;<BR> <BR> private String LOCATION =3D=20
"Location";<BR> private String SIZE =3D =
"Size";<BR> <BR> public=20
Category() {<BR> if (categories =3D=3D null)=20
{<BR> categories =3D new=20
HashMap();<BR> categories.put( "x",=20
LOCATION);<BR> categories.put( "y",=20
LOCATION);<BR> <BR> categories.put( "wid=
th",=20
SIZE);<BR> categories.put("height ",=20
SIZE);<BR> }<BR> }<BR> <BR> public String=20
getCategory(String name) {<BR> String=20
category;<BR> category =3D (String)=20
categories.get(name);<BR> if (category =3D=3D null)=20
{<BR> category =3D=20
APPEARANCE;<BR> }<BR> return=20
category;<BR> }<BR>}</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3D宋体 size=3D2>Category category =3D new=20
Category();<BR>%><BR></FONT></DIV>
<DIV><FONT face=3D宋体 size=3D2>Then I can use category in =
the following code like=20
this:</FONT></DIV>
<DIV><FONT face=3D宋体 size=3D2></FONT> </DIV>
<DIV><FONT face=3D宋体 size=3D2><%for (Iterator=20
i=3DgenClass.getPropertyFeatures().iterator(); i.hasNext();) { =
GenFeature=20
genFeature =3D=20
(GenFeature)i.next();%><BR> add<%=3DgenFeature.get=
CapName()%>PropertyDescriptor(object,=20
" <%=3Dcategory.getCategory(genFeature.getName())%& gt; ");<BR><%}%>=
;<BR></FONT><FONT=20
face=3D宋体 size=3D2></DIV></FONT>
<DIV><FONT face=3D宋体 size=3D2>Regards,</FONT></DIV>
<DIV><FONT face=3D宋体 size=3D2></FONT> </DIV>
<DIV><FONT face=3D宋体 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" <<A =
href=3D"mailto:merks@ca.ibm.com">merks@ca.ibm.com</A>>=20
=
写入消息新 闻:3E314A5B.B0846982@ca.ibm=
..com...</DIV>Eric,=20
<P>No, we don't support that. 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. The .java skeleton file could look like =
this:=20
<BLOCKQUOTE>/** <BR> * <BR> */ <BR>package a.b.c;=20
<P>import org.eclipse.emf.codegen.*;=20
<P>/** <BR> * <BR> */ <BR>public class SKELETON_CLASS =
<BR>{=20
<BR> /** <BR> * <BR> */ <BR> =
public=20
static String generate(Object model) <BR> { =
<BR> =20
return ""; <BR> } <BR>}</P></BLOCKQUOTE>
<P><BR>Eric Suen wrote:=20
<BLOCKQUOTE TYPE=3D"CITE">Hi all,=20
<P> In JSP, I can use <%! %> 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><%! <BR> private String getCategory(String name) {=20
<BR> ... <BR> return ...; <BR> } =
<BR>%>=20
<P>Regards,=20
<P>Eric Suen</P></BLOCKQUOTE>
<P>-- <BR>Ed Merks <BR> </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  |
Eclipse User |
|
|
|
--------------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! 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> <font face="??"><font size=-1>
I have found another way to do this, use inner class, like this:</font></font> <font face="??"><font size=-1><%</font></font>
<br><font face="??"><font size=-1>class Category {</font></font>
<br><font face="??"><font size=-1> private Map categories = null;</font></font>
<p><font face="??"><font size=-1> private String LOCATION = "Location";</font></font>
<br><font face="??"><font size=-1> private String SIZE = "Size";</font></font>
<p><font face="??"><font size=-1> public Category() {</font></font>
<br><font face="??"><font size=-1> if (categories == null) {</font></font>
<br><font face="??"><font size=-1> categories = new HashMap();</font></font>
<br><font face="??"><font size=-1> categories.put("x", LOCATION);</font></font>
<br><font face="??"><font size=-1> categories.put("y", LOCATION);</font></font>
<p><font face="??"><font size=-1> categories.put("width", SIZE);</font></font>
<br><font face="??"><font size=-1> categories.put("height",
SIZE);</font></font>
<br><font face="??"><font size=-1> }</font></font>
<br><font face="??"><font size=-1> }</font></font>
<p><font face="??"><font size=-1> public String getCategory(String
name) {</font></font>
<br><font face="??"><font size=-1> String category;</font></font>
<br><font face="??"><font size=-1> category = (String) categories.get(name);</font></font>
<br><font face="??"><font size=-1> if (category == null) {</font></font>
<br><font face="??"><font size=-1> category = APPEARANCE;</font></font>
<br><font face="??"><font size=-1> }</font></font>
<br><font face="??"><font size=-1> return category;</font></font>
<br><font face="??"><font size=-1> }</font></font>
<br><font face="??"><font size=-1>}</font></font> <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> <font face="??"><font size=-1><%for
(Iterator i=genClass.getPropertyFeatures().iterator(); i.hasNext();) {
GenFeature genFeature = (GenFeature)i.next();%></font></font>
<br><font face="??"><font size=-1> add<%=genFeature.getCapName()%>PropertyDescriptor(object,
"<%=category.getCategory(genFeature.getName())%>");</font ></font>
<br><font face="??"><font size=-1><%}%></font></font><font face="??"><font size=-1>Regards,</font></font> <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" <<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. 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:
<blockquote>/**
<br> *
<br> */
<br>package a.b.c;
<p>import org.eclipse.emf.codegen.*;
<p>/**
<br> *
<br> */
<br>public class SKELETON_CLASS
<br>{
<br> /**
<br> *
<br> */
<br> public static String generate(Object model)
<br> {
<br> return "";
<br> }
<br>}</blockquote>
<p><br>Eric Suen wrote:
<blockquote TYPE="CITE">Hi all,
<p> In JSP, I can use <%! %> 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><%!
<br> private String getCategory(String name) {
<br> ...
<br> return ...;
<br> }
<br>%>
<p>Regards,
<p>Eric Suen</blockquote>
--
<br>Ed Merks
<br> </blockquote>
</blockquote>
<p>--
<br>Ed Merks
<br>
</body>
</html>
--------------8ABE3799E10E568F84904417--
|
|
|
Goto Forum:
Current Time: Wed Nov 05 11:33:17 EST 2025
Powered by FUDForum. Page generated in 0.23923 seconds
|