This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
> Specifically, lets say I have a scheme script called test.scm. If you already have the test.scm file there I would (as Per also suggests) just compile test.scm and call the function directly from Java. This is easier than trying to load the file/definition on the fly. Attached is an example with a completely arbitrary cash equivalent algorithm. Regards, Chris Dean
import kawa.standard.Scheme; public class JavaCaller { static public void main( String args[] ) throws Throwable { Scheme.registerEnvironment(); Security mySecurity1 = new Security( 1, 2, 3 ); SchemeRunner.checkCash( mySecurity1 ); if( mySecurity1.isCashEquiv() ) System.out.println( "Security1 is a cash equivalent." ); else System.err.println( "Security1 is not a cash equivalent." ); Security mySecurity2 = new Security( 0, 0, 0 ); SchemeRunner.checkCash( mySecurity2 ); if( mySecurity2.isCashEquiv() ) System.out.println( "Security2 is a cash equivalent." ); else System.err.println( "Security2 is not a cash equivalent." ); } }
Attachment:
SchemeRunner.scm
Description: SchemeRunner.scm
public class Security { public Security( int assetClass, int secType, int daysToMaturity ) { setAssetClass( assetClass ); setSecType( secType ); setDaysToMaturity( daysToMaturity ); } private int mAssetClass; public int getAssetClass() { return( mAssetClass ); } public void setAssetClass( int val ) { mAssetClass = val; } private int mSecType; public int getSecType() { return( mSecType ); } public void setSecType( int val ) { mSecType = val; } private int mDaysToMaturity; public int getDaysToMaturity() { return( mDaysToMaturity ); } public void setDaysToMaturity( int val ) { mDaysToMaturity = val; } private boolean mCashEquiv; public boolean isCashEquiv() { return( mCashEquiv ); } public void setCashEquiv( boolean val ) { mCashEquiv = val; } }
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |