📄 iclint.java
字号:
package com.sri.oaa2.icl;
/**
* Represents an integer with at least 64 bits of precision.
*/
public class IclInt extends IclAtomic
{
/// internal value
protected Long value;
protected void setSign(long i)
{
this.setValueFromLong(i * this.toLong());
}
/**
* Create a new IclInt with no value. You must use setValue or setValueFromInt
*/
public IclInt()
{
super(OaaPrologVocabTokenTypes.INT);
}
/**
* Create a new IclInt with the given value
*/
public IclInt(int v)
{
super(OaaPrologVocabTokenTypes.INT);
setValue(new Long(v));
}
/**
* Create a new IclInt with the given value
*/
public IclInt(long v)
{
super(OaaPrologVocabTokenTypes.INT);
setValue(new Long(v));
}
/**
* Set the value from an int.
*/
protected final void setValueFromInt(int i)
{
setValue(new Long(i));
}
/**
* Set the value from a long.
*/
protected final void setValueFromLong(long l)
{
setValue(new Long(l));
}
/**
* Set the value from an Integer object
*/
protected final void setValue(Integer i)
{
if(i == null) {
throw new NullPointerException("IclInt.setValue() cannot set value from null");
}
setValue(new Long(i.longValue()));
}
/**
* Set the value from a Long object
*/
protected final void setValue(Long i)
{
if(i == null) {
throw new NullPointerException("IclInt.setValue() cannot set value from null");
}
value = i;
this.setCrc(i.hashCode());
}
/**
* Get the value as a Long object
*/
protected final Long getValue()
{
return value;
}
/**
* Get the value as an int
*/
public final int toInt()
{
return getValue().intValue();
}
/**
* Get the value as a long
*/
public final long toLong()
{
return getValue().longValue();
}
/**
* Get the value as an Integer object
*/
public final Integer toInteger()
{
return new Integer(toInt());
}
/**
* Get the value as a Long object
*/
public final Long toLongObject()
{
return getValue();
}
/** Accept the visitor. **/
protected final Object accept(OaaPrologVisitor visitor, Object data) {
return visitor.visit(this, data);
}
/**
* @deprecated use toInt()
*/
public final int iclInt()
{
return toInt();
}
/**
* @deprecated use toInteger().floatValue()
*/
public final float iclFloat()
{
return toInteger().floatValue();
}
public boolean equals(Object o)
{
if(!(o instanceof IclInt)) {
return false;
}
IclInt i = (IclInt)o;
if(this.getCrc() != i.getCrc()) {
return false;
}
if(!this.getValue().equals(i.getValue())) {
return false;
}
return true;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -