#!/usr/bin/env python import string, cgi, os, whrandom, pickle, sys import cgitb; cgitb.enable() #sys.path.insert(0, '/home/mu.org/home/gus/fm/fmblog') #import fmbloglib,fmblog print 'Content-type: text/html\r\n' print ''' gus mueller
Here\'s a class to do some simple beanish introspection:



import java.io.*;
import java.util.*;
import java.lang.reflect.*;



import javax.servlet.*;
import javax.servlet.http.*;



public class Spect {
    
    public static void main(String [] args) {
        Spect i = new Spect();
        
        test t = new test();
        
        i.setIt(t, "x", "sam");
        
        System.out.println(t);
    }
    
    public static void spect(HttpServletRequest req, Object o) {
        try {
            Enumeration e = req.getParameterNames();
            while ( e.hasMoreElements() ) {
                String name  = (String) e.nextElement();
                String value = req.getParameter(name);
                if (value == null || value.equals(""))
                    continue;
                
                setIt(o, name, value);
            }
        }
        catch(Exception e) {
            e.printStackTrace(System.out);
        }
    }
    
    public static void setIt(Object o, String name, String value) {
        
        Class  [] class_array = new Class[1];
        Object [] arguments = {value};
        
        try {
            class_array[0] = value.getClass();
            
            String function = "set" +
                name.toUpperCase().substring(0, 1) +
                name.substring(1);
            
            Method m = o.getClass().getDeclaredMethod(function, class_array);
            m.invoke(o, arguments);
        }
        catch(Exception e) { }
    }
    
    public static final void log(String s) {
        System.out.println(s);
        System.out.flush();
    }
}




All things copyright © 2001, 2002 August Mueller

gmdc:
flying meat
contact
resume
photos
images
free font
cocoa bits
java bits
unix bits
osx bits
cvsdist
my words
mcommand
ja
links
my rss feed
book list
who\'s linken\'
login
wishlist
theories

people
andy
byron
jeff
jeremy
joe
kory
lynn
mary
murphy
ryan d

when bored
slashdot
maccentral
y! most viewed
cars
there gus
explodingdog
the onion
dotw
tonypierce
prior art
chimera

resources
Cafe au Lait
Cafe con Leche
design patterns
anitpatterns
java r.o.t.d
c.l.c
c.l.j
c.s.m.p.h
c.s.m.p.c



'''