Hi Ernest,
In the documentation regarding I/O routers (Ch 10. p.66 in the PDF), it
says:
"...Note also that although these functions accept and return generic Reader
and Writer objects, Jess internally uses java.io.PrintWriter and
java.io.BufferedReader. If you pass in other types, Jess will construct one
of these preferred classes to "wrap" the object you pass in..."
OK, but that seems to create unexpected behavior for
Rete.getOutputRouter(String
s).
For example, if I follow JIA p.320 and do something like...
StringWriter sw = new StringWriter();
engine.addOutputRouter("sw", sw);
...then later on, I code something like...
StringWriter out = (StringWriter)(engine.getOutputWriter("sw"));
Jess complains that I can't downcast java.io.PrintWriter to StringWriter.
Upon inspection, it seems like Jess is returning the internally wrapped
PrintWriter object rather than the StringWriter object that was originally
assigned to the router. Jess's javadocs say that getOutputRouter() returns
a java.io.Writer, which seems to hide the fact that it is really returning a
java.io.PrintWriter. I note that getErrStream() and getOutStream() both
explicitly return java.io.PrintWriter objects.
What am I missing?
Cheers,
Jason
-----------------------------------------------------------
Jason C. Morris
Worcester Polytechnic Institute Phone: (508) 831-5006
Department of Computer Science FAX: (508) 831-5776
Fuller Laboratories - Room 312 [EMAIL PROTECTED]
Artificial Intelligence Lab (AIRG)
100 Institute Road
Worcester, MA 01609-2280
-----------------------------------------------------------