qse/ase/awk/Argument.java

81 lines
1.8 KiB
Java
Raw Normal View History

/*
2008-03-04 05:13:15 +00:00
* $Id: Argument.java 115 2008-03-03 11:13:15Z baconevi $
*
* {License}
*/
package ase.awk;
public class Argument implements Clearable
{
protected long runid;
//protected long valid;
public long valid;
/* An instance of the Argument class should not be used
* outside the context where it is availble. When it is
* referenced that way, the getXXX methods may cause
* JVM to crash */
Argument (Context ctx, long runid, long valid)
{
if (ctx != null) ctx.pushClearable (this);
this.runid = runid;
this.valid = valid;
}
Argument (long runid, long valid)
{
this (null, runid, valid);
}
public void clear ()
{
clearval (this.runid, this.valid);
}
public long getIntValue ()
{
if (this.valid == 0) return 0;
return getintval (this.runid, this.valid);
}
public double getRealValue ()
{
if (this.valid == 0) return 0.0;
return getrealval (this.runid, this.valid);
}
public String getStringValue () throws Exception
{
if (this.valid == 0) return "";
return getstrval (this.runid, this.valid);
}
public boolean isIndexed ()
{
if (this.valid == 0) return false;
return isindexed (this.runid, this.valid);
}
public Argument getIndexed (String idx) throws Exception
{
if (this.valid == 0) return null;
return getindexed (this.runid, this.valid, idx);
}
public Argument getIndexed (long idx) throws Exception
{
if (this.valid == 0) return null;
return getIndexed (Long.toString(idx));
}
protected native long getintval (long runid, long valid);
protected native double getrealval (long runid, long valid);
protected native String getstrval (long runid, long valid) throws Exception;
protected native boolean isindexed (long runid, long valid);
protected native Argument getindexed (long runid, long valid, String idx) throws Exception;
protected native void clearval (long runid, long valid);
}