Revision Log
Revision: 1.1 - (view) (download) (as text)
| 1 : | ktanaka | 1.1 | // |
| 2 : | public final class Fixnum extends LispObject{ | ||
| 3 : | int val; | ||
| 4 : | Fixnum(int val){ this.val=val; } | ||
| 5 : | Fixnum(String name){ this(Integer.parseInt(name)); } | ||
| 6 : | public int getType(){ return FIXNUM; } | ||
| 7 : | public int getInteger(){ return val; } | ||
| 8 : | public String toString(){ return ""+val; } | ||
| 9 : | public static boolean isFixnumString(String name){ | ||
| 10 : | char c; | ||
| 11 : | if(name.length()==0) return false; | ||
| 12 : | if((c=name.charAt(0))=='+' || c=='-'){ | ||
| 13 : | name=name.substring(1); | ||
| 14 : | } | ||
| 15 : | int i,len; | ||
| 16 : | if((len=name.length())==0) return false; | ||
| 17 : | for(i=0;i<len;i++) | ||
| 18 : | if(!Character.isDigit(name.charAt(i))) | ||
| 19 : | return false; | ||
| 20 : | return true; | ||
| 21 : | } | ||
| 22 : | } |
|
ktanaka Powered by ViewCVS 1.0-dev |
ViewCVS and CVS Help |