00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 package jpl;
00029
00030 import java.util.Map;
00031 import jpl.fli.Int64Holder;
00032 import jpl.fli.Prolog;
00033 import jpl.fli.term_t;
00034
00035
00036
00065 public class Integer extends Term {
00066
00067
00068
00069
00070
00074 protected final long value;
00075
00076
00077
00078
00079
00083 public Integer(long value) {
00084 this.value = value;
00085 }
00086
00087
00088
00089
00090
00096 public Term arg(int ano) {
00097 throw new JPLException("jpl." + this.typeName() + ".arg() is undefined");
00098 }
00099
00105 public Term[] args() {
00106 return new Term[] {
00107 };
00108 }
00109
00115 public final boolean hasFunctor(int val, int arity) {
00116 return val == this.value && arity == 0;
00117 }
00118
00124 public boolean hasFunctor(String name, int arity) {
00125 return false;
00126 }
00127
00133 public boolean hasFunctor(double value, int arity) {
00134 return false;
00135 }
00136
00142 public final String name() {
00143 throw new JPLException("jpl.Integer#name() is undefined");
00144 }
00145
00151 public final int arity() {
00152 return 0;
00153 }
00154
00161 public final int intValue() {
00162 if (value < java.lang.Integer.MIN_VALUE || value > java.lang.Integer.MAX_VALUE) {
00163 throw new JPLException("cannot represent Integer value as an int");
00164 } else {
00165 return (int) value;
00166 }
00167 }
00168
00174 public final long longValue() {
00175 return value;
00176 }
00177
00183 public final float floatValue() {
00184 return (new java.lang.Long(value)).floatValue();
00185 }
00186
00192 public final double doubleValue() {
00193 return (new java.lang.Long(value)).doubleValue();
00194 }
00195
00196 public final int type() {
00197 return Prolog.INTEGER;
00198 }
00199
00200 public String typeName(){
00201 return "Integer";
00202 }
00203
00209 public String toString() {
00210 return "" + value;
00211 }
00212
00219 public final boolean equals(Object obj) {
00220 return this == obj || (obj instanceof Integer && value == ((Integer) obj).value);
00221 }
00222
00223
00224
00225
00226
00233 public final int value() {
00234 return (int) value;
00235 }
00236
00243 public String debugString() {
00244 return "(Integer " + toString() + ")";
00245 }
00246
00247
00248
00249
00250
00258 protected final void put(Map varnames_to_vars, term_t term) {
00259 Prolog.put_integer(term, value);
00260 }
00261
00262
00263
00264
00265
00273 protected static Term getTerm1(Map vars_to_Vars, term_t term) {
00274 Int64Holder int64_holder = new Int64Holder();
00275
00276 Prolog.get_integer(term, int64_holder);
00277 return new jpl.Integer(int64_holder.value);
00278 }
00279
00280
00281
00282
00283
00290 protected final void getSubst(Map varnames_to_Terms, Map vars_to_Vars) {
00291 }
00292
00293 public Object jrefToObject() {
00294 throw new JPLException("Integer.jrefToObject(): term is not a jref");
00295 }
00296
00297 }
00298
00299