001    /*
002     * $Id: ModularNotInvertibleException.java 3472 2011-01-07 17:19:22Z kredel $
003     */
004    
005    package edu.jas.arith;
006    
007    
008    import edu.jas.structure.NotInvertibleException;
009    import edu.jas.structure.GcdRingElem;
010    
011    
012    /**
013     * Modular integer NotInvertibleException class.
014     * Runtime Exception to be thrown for not invertible modular integers.
015     * Container for the non-trivial factors found by the inversion algorithm.
016     * <b>Note: </b> cannot be generic because of Throwable.
017     * @author Heinz Kredel
018     */
019    public class ModularNotInvertibleException extends NotInvertibleException {
020    
021    
022        public final GcdRingElem f; // = f1 * f2
023    
024        public final GcdRingElem f1;
025    
026        public final GcdRingElem f2;
027    
028    
029        public ModularNotInvertibleException() {
030            this(null,null,null);
031        }
032    
033    
034        public ModularNotInvertibleException(String c) {
035            this(c,null,null,null);
036        }
037    
038    
039        public ModularNotInvertibleException(String c, Throwable t) {
040            this(c,t,null,null,null);
041        }
042    
043    
044        public ModularNotInvertibleException(Throwable t) {
045            this(t,null,null,null);
046        }
047    
048    
049        /**
050         * Constructor.
051         * @param f gcd ring element with f = f1 * f2.
052         * @param f1 gcd ring element.
053         * @param f2 gcd ring element.
054         */
055        public ModularNotInvertibleException(GcdRingElem f, GcdRingElem f1, GcdRingElem f2) {
056            super("ModularNotInvertibleException");
057            this.f = f;
058            this.f1 = f1;
059            this.f2 = f2;
060        }
061    
062    
063        /**
064         * Constructor.
065         * @param f gcd ring element with f = f1 * f2.
066         * @param f1 gcd ring element.
067         * @param f2 gcd ring element.
068         */
069        public ModularNotInvertibleException(String c, GcdRingElem f, GcdRingElem f1, GcdRingElem f2) {
070            super(c);
071            this.f = f;
072            this.f1 = f1;
073            this.f2 = f2;
074        }
075    
076    
077        /**
078         * Constructor.
079         * @param f gcd ring element with f = f1 * f2.
080         * @param f1 gcd ring element.
081         * @param f2 gcd ring element.
082         */
083        public ModularNotInvertibleException(String c, Throwable t, GcdRingElem f, GcdRingElem f1, GcdRingElem f2) {
084            super(c,t);
085            this.f = f;
086            this.f1 = f1;
087            this.f2 = f2;
088        }
089    
090    
091        /**
092         * Constructor.
093         * @param f gcd ring element with f = f1 * f2.
094         * @param f1 gcd ring element.
095         * @param f2 gcd ring element.
096         */
097        public ModularNotInvertibleException(Throwable t, GcdRingElem f, GcdRingElem f1, GcdRingElem f2) {
098            super("ModularNotInvertibleException",t);
099            this.f = f;
100            this.f1 = f1;
101            this.f2 = f2;
102        }
103    
104    
105        /**
106         * Get the String representation.
107         * @see java.lang.Object#toString()
108         */
109        @Override
110        public String toString() {
111            String s = super.toString();
112            if ( f != null || f1 != null || f2 != null) {
113                s += ", f = " + f + ", f1 = " + f1 + ", f2 = " + f2;
114            }
115            return s;
116        }
117    
118    }