The Artima Developer Community
Sponsored Link

Java Buzz Forum
Code Monkey

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Brian McCallister

Posts: 1282
Nickname: frums
Registered: Sep, 2003

Brian McCallister is JustaProgrammer who thinks too much.
Code Monkey Posted: Feb 10, 2005 7:42 PM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Brian McCallister.
Original Post: Code Monkey
Feed Title: Waste of Time
Feed URL: http://kasparov.skife.org/blog/index.rss
Feed Description: A simple waste of time and weblog experiment
Latest Java Buzz Posts
Latest Java Buzz Posts by Brian McCallister
Latest Posts From Waste of Time

Advertisement

I'm happy to share CodeMonkey.

CodeMonkey is a programmatic code generation tool. It is not a template based code generator like XDoclet or its ilk, it is entirely programmatic, for instance:

    public void testSample() throws Exception
    {
        Klass wombat = new Klass();
        wombat.setName("Wombat");
        wombat.setPackage("org.skife.example");

        Method belch = new Method();
        belch.setFinal(true);
        belch.setName("belch");
        belch.addParameter(new Parameter("int", "volume"));
        belch.setBody("System.out.print(\"BURP at level \" + volume);");

        wombat.addMethod(belch);
        BeanTool.addProperty(wombat, String.class, "name");
        BeanTool.addProperty(wombat, "int", "age");

        wombat.addInterface(Serializable.class);

        Generator generator = new Generator();
        String source = generator.generate(wombat);

        System.out.println(source);
    }

Will generate the output:

package org.skife.example;

public class Wombat implements java.io.Serializable
{
     private java.lang.String name0;
     private int age1;

    public void belch(int volume)
    {
        System.out.print("BURP at level " + volume);
    }

    public final void setName(java.lang.String name)
    {
        name0 = name;
    }

    public java.lang.String getName()
    {
        return name0;
    }

    public void setAge(int age)
    {
        age1 = age;
    }

    public int getAge()
    {
        return age1;
    }

 }

The library just has low level constructs right now (java language features), but more is sure to come, as I built it to solve other problems ;-)

CodeMonkey is *not* a replacement for XDoclet, Middlegen, etc. It *is* a useful tool for building semi-dynamic code (ie, from JDBC metadata or whatnot) at compile time.

Have fun!

Read: Code Monkey

Topic: [Feb 4, 2005 17:42 PST] 2 Links Previous Topic   Next Topic Topic: Sign the Online Petition For JDO 2.0!

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use