The JessToken.toString() method that you're calling isn't used
internally by Jess; it's just for debugging. But as it turns out,
you've found a bug in it -- it apparently doesn't properly convert
RU.LONG values! A patch for jess/JessToken.java in Jess 7.0p1 could
look like
diff -r1.27 JessToken.java
87a88,89
> else if (m_ttype == JessToken.LONG_TOK)
> return String.valueOf(m_lval) + "L";
Otherwise, a workaround would be
jt = rt.nextToken();
if (jt.m_ttype == JessToken.LONG_TOK)
System.out.println("Tok="+jt.m_lval + "L");
else
System.out.println("Tok="+jt.toString());
Typically, consumers of JessToken objects wouldn't turn around and
convert everything back to a String like this, though. The JessToken
class stores int and double values in m_nval, Strings and tokens in
m_sval, character values in m_ttype, and longs in m_lval, and you'd
probably want to use these values directly.
On Apr 11, 2007, at 10:14 PM, Jim Yates wrote:
I'm using the ReaderTokenizer.nextToken method to read in a CLP
file and parse the contents. I have a line
(test(member$ ?costctr (create$ 403L 111L 702L 189L 489L))). The
nextToken method returns a "" for the list values. I tried upper
and lower case L's, with no difference.
I need the L's because the costctr variable is defined as a long in
a Java Class, and the member$ won't find a match otherwise. I'm
using Jess 7.0p1. Sample java code and clp file attached.
(test(member$ ?costctr (create$ 403L 111L 702L 189L 489L)))
package com.accuserverx.accucharge.rule;
import java.io.FileReader;
import jess.JessToken;
import jess.ReaderTokenizer;
public class TokenTest {
public TokenTest() {
FileReader file;
ReaderTokenizer rt;
JessToken jt;
try {
file = new FileReader("/usr/jboss/rules/
tokentest.clp");
rt = new ReaderTokenizer(file, true);
jt = rt.nextToken();
while (!jt.isEOF()) {
jt = rt.nextToken();
System.out.println("Tok="+jt.toString());
}
}
catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
TokenTest tokenTest = new TokenTest();
}
}
<jim.yates.vcf>
---------------------------------------------------------
Ernest Friedman-Hill
Advanced Software Research Phone: (925) 294-2154
Sandia National Labs FAX: (925) 294-2234
PO Box 969, MS 9012 [EMAIL PROTECTED]
Livermore, CA 94550 http://www.jessrules.com
--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------