1 package com.etymon.pj.object; 2 3 import java.io.*; 4 5 9 public class PjNumber 10 extends PjObject { 11 12 16 public PjNumber(float f) { 17 _f = f; 18 } 19 20 24 public float getFloat() { 25 return _f; 26 } 27 28 32 public int getInt() { 33 return new Float (_f).intValue(); 34 } 35 36 40 public long getLong() { 41 return new Float (_f).longValue(); 42 } 43 44 48 public boolean isInteger() { 49 return ( ((float)(new Float (_f).intValue())) == _f ); 50 } 51 52 58 public long writePdf(OutputStream os) throws IOException { 59 Float ft = new Float (_f); 60 int x = ft.intValue(); 61 if ((float)x == _f) { 62 return write(os, new Integer (x)); 63 } else { 64 return write(os, ft); 65 } 66 } 67 68 81 82 86 public Object clone() { 87 return this; 88 } 89 90 96 public boolean equals(Object obj) { 97 if (obj == null) { 98 return false; 99 } 100 if (obj instanceof PjNumber) { 101 return (_f == ((PjNumber)obj)._f); 102 } else { 103 return false; 104 } 105 } 106 107 111 public int hashCode() { 112 return new Float (_f).hashCode(); 113 } 114 115 public static final PjNumber ZERO = new PjNumber(0); 116 public static final PjNumber ONE = new PjNumber(1); 117 public static final PjNumber TWO = new PjNumber(2); 118 119 private float _f; 120 121 } 122 | Popular Tags |