From: <ber...@ya...> - 2001-09-12 15:49:26
|
With the java code below, I obtain the list of available methods of the StringTonenizer class (but not of mother classes) while I am unable to obtain them for my own Enum class. Is there somebody able to explain me this difference and where it is documented (sorry if it is but I didn't find it) ? Here is the jython console where I try to introspect my Enum class (made for demonstration purpose). Jython 2.0 on java1.3.0 (JIT: null) >>> dir(enum.__class__) [] >>> dir(tokenizer.__class__) ['countTokens', 'hasMoreTokens', 'nextToken'] >>> a = enum.nextElement() >>> a 'one' >>> a = enum.nextElement() >>> a 'two' >>> a = tokenizer.nextElement() >>> a 'This' >>> a = tokenizer.nextElement() >>> a 'is' >>> And here is the java code. package trybox; import org.python.core.*; import org.python.util.InteractiveConsole; import java.util.Enumeration; import java.util.StringTokenizer; public class TryJython { public TryJython() { } public static void main(String[] args) { TryJython tryJython = new TryJython(); tryJython.doIt(); } void doIt() { Enumeration enum = new Enum(); Enumeration tokenizer = new StringTokenizer("This is a test"); InteractiveConsole console = new InteractiveConsole(); console.set("enum", enum); console.set("tokenizer", tokenizer); console.interact(); } public class Enum implements Enumeration { String [] values = {"one", "two", "tree", "four", "five"}; int index = 0; public boolean hasMoreElements() { return (index < values.length); } public Object nextElement() { return values[index++]; } } } TIA. Bertrand. ___________________________________________________________ Do You Yahoo!? -- Un e-mail gratuit @yahoo.fr ! Yahoo! Courrier : http://fr.mail.yahoo.com |