1 16 package org.apache.axis.types; 17 18 19 20 import org.apache.axis.utils.Messages; 21 22 28 public class UnsignedInt extends java.lang.Number implements java.lang.Comparable { 29 30 protected Long lValue = new Long (0); 31 32 public UnsignedInt() { 33 } 34 35 39 public UnsignedInt(long iValue) throws NumberFormatException { 40 setValue(iValue); 41 } 42 43 public UnsignedInt(String stValue) throws NumberFormatException { 44 setValue(Long.parseLong(stValue)); 45 } 46 47 48 54 public void setValue(long iValue) throws NumberFormatException { 55 if (UnsignedInt.isValid(iValue) == false) 56 throw new NumberFormatException ( 57 Messages.getMessage("badUnsignedInt00") + 58 String.valueOf(iValue) + "]"); 59 lValue = new Long (iValue); 60 } 61 62 public String toString(){ 63 if (lValue != null) 64 return lValue.toString(); 65 else 66 return null; 67 } 68 69 public int hashCode(){ 70 if (lValue != null) 71 return lValue.hashCode(); 72 else 73 return 0; 74 } 75 76 81 public static boolean isValid(long iValue) { 82 if ( (iValue < 0L) || (iValue > 4294967295L)) 83 return false; 84 else 85 return true; 86 } 87 88 private Object __equalsCalc = null; 89 public synchronized boolean equals(Object obj) { 90 if (!(obj instanceof UnsignedInt)) return false; 91 UnsignedInt other = (UnsignedInt) obj; 92 if (obj == null) return false; 93 if (this == obj) return true; 94 if (__equalsCalc != null) { 95 return (__equalsCalc == obj); 96 } 97 __equalsCalc = obj; 98 boolean _equals; 99 _equals = true && 100 ((lValue ==null && other.lValue ==null) || 101 (lValue !=null && 102 lValue.equals(other.lValue))); 103 __equalsCalc = null; 104 return _equals; 105 } 106 107 public int compareTo(Object obj) { 109 if (lValue != null) 110 return lValue.compareTo(obj); 111 else 112 if (equals(obj) == true) 113 return 0; else 115 return 1; } 117 118 public byte byteValue() { return lValue.byteValue(); } 120 public short shortValue() { return lValue.shortValue(); } 121 public int intValue() { return lValue.intValue(); } 122 public long longValue() { return lValue.longValue(); } 123 public double doubleValue() { return lValue.doubleValue(); } 124 public float floatValue() { return lValue.floatValue(); } 125 126 127 } 128 | Popular Tags |