1 16 package org.apache.axis.types; 17 18 import org.apache.axis.utils.Messages; 19 20 import java.math.BigInteger ; 21 import java.util.Random ; 22 import java.io.ObjectStreamException ; 23 24 36 public class NegativeInteger extends NonPositiveInteger { 37 38 public NegativeInteger(byte[] val) { 39 super(val); 40 checkValidity(); 41 } 43 public NegativeInteger(int signum, byte[] magnitude) { 44 super(signum, magnitude); 45 checkValidity(); 46 } 48 public NegativeInteger(int bitLength, int certainty, Random rnd) { 49 super(bitLength, certainty, rnd); 50 checkValidity(); 51 } 53 public NegativeInteger(int numBits, Random rnd) { 54 super(numBits, rnd); 55 checkValidity(); 56 } 58 public NegativeInteger(String val) { 59 super(val); 60 checkValidity(); 61 } 62 63 public NegativeInteger(String val, int radix) { 64 super(val, radix); 65 checkValidity(); 66 } 68 71 private BigInteger zero = new BigInteger ("0"); 72 private void checkValidity() { 73 if (compareTo(zero) >= 0) { 74 throw new NumberFormatException ( 75 Messages.getMessage("badnegInt00") 76 + ": " + this); 77 } 78 } 80 85 public Object writeReplace() throws ObjectStreamException { 86 return new BigIntegerRep(toByteArray()); 87 } 88 89 protected static class BigIntegerRep implements java.io.Serializable { 90 private byte[] array; 91 protected BigIntegerRep(byte[] array) { 92 this.array = array; 93 } 94 protected Object readResolve() throws java.io.ObjectStreamException { 95 return new NegativeInteger(array); 96 } 97 } 98 } | Popular Tags |