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 35 public class NonPositiveInteger extends BigInteger { 36 37 public NonPositiveInteger(byte[] val) { 38 super(val); 39 checkValidity(); 40 } 42 public NonPositiveInteger(int signum, byte[] magnitude) { 43 super(signum, magnitude); 44 checkValidity(); 45 } 47 public NonPositiveInteger(int bitLength, int certainty, Random rnd) { 48 super(bitLength, certainty, rnd); 49 checkValidity(); 50 } 52 public NonPositiveInteger(int numBits, Random rnd) { 53 super(numBits, rnd); 54 checkValidity(); 55 } 57 public NonPositiveInteger(String val) { 58 super(val); 59 checkValidity(); 60 } 61 62 public NonPositiveInteger(String val, int radix) { 63 super(val, radix); 64 checkValidity(); 65 } 67 70 private BigInteger zero = new BigInteger ("0"); 71 private void checkValidity() { 72 if (compareTo(zero) > 0) { 73 throw new NumberFormatException ( 74 Messages.getMessage("badNonPosInt00") 75 + ": " + this); 76 } 77 } 79 84 public Object writeReplace() throws ObjectStreamException { 85 return new BigIntegerRep(toByteArray()); 86 } 87 88 protected static class BigIntegerRep implements java.io.Serializable { 89 private byte[] array; 90 protected BigIntegerRep(byte[] array) { 91 this.array = array; 92 } 93 protected Object readResolve() throws java.io.ObjectStreamException { 94 return new NonPositiveInteger(array); 95 } 96 } 97 } | Popular Tags |