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