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