summaryrefslogtreecommitdiff
path: root/javalib/src/main/scala/java/util/Throwables.scala
blob: c4bb3d6528d72d5781ead17cb93dccec8f060059 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
package java.util

class ServiceConfigurationError(s: String, e: Throwable) extends Error(s, e) {
  def this(s: String) = this(s, null)
}

class ConcurrentModificationException(s: String) extends RuntimeException(s) {
  def this() = this(null)
}

class DuplicateFormatFlagsException private() extends IllegalFormatException {
  private var flags: String = null 
  def this(f: String) {
    this()
    if (f == null)
      throw new NullPointerException()
    flags = f
  }
  def getFlags(): String = flags
  override def getMessage(): String = s"Flags = '$flags'"
}

class EmptyStackException extends RuntimeException

class FormatFlagsConversionMismatchException private(private val c: Char) extends IllegalFormatException {
  private var f: String = null 
  def this(f: String, c: Char) {
    this(c)
    if (f == null)
      throw new NullPointerException()
    this.f = f
  }
  def getFlags(): String = f
  def getConversion(): Char = c
  override def getMessage(): String = "Conversion = " + c + ", Flags = " + f
}

class FormatterClosedException extends IllegalStateException

class IllegalFormatCodePointException(private val c: Int) extends IllegalFormatException {
  def getCodePoint(): Int = c
  override def getMessage(): String = s"Code point = $c"
}

class IllegalFormatConversionException private(private val c: Char) extends IllegalFormatException {
  private var arg: Class[_] = null
  def this(c: Char, arg: Class[_]) {
    this(c)
    if (arg == null)
      throw new NullPointerException()
    this.arg = arg
  }
  def getConversion(): Char = c
  def getArgumentClass(): Class[_] = arg
  override def getMessage(): String = s"$c != ${arg.getName()}"
}

class IllegalFormatException private[util] () extends IllegalArgumentException

class IllegalFormatFlagsException private() extends IllegalFormatException {
  private var flags: String = null
  def this(f: String) {
    this()
    if (f == null)
      throw new NullPointerException()
    this.flags = f
  }
  def getFlags(): String = flags
  override def getMessage(): String = "Flags = '" + flags + "'"
}

class IllegalFormatPrecisionException(private val p: Int) extends IllegalFormatException {
  def getPrecision(): Int = p
  override def getMessage(): String = Integer.toString(p)
}

class IllegalFormatWidthException(private val w: Int) extends IllegalFormatException {
  def getWidth(): Int = w
  override def getMessage(): String = Integer.toString(w)
}

class IllformedLocaleException(s: String, errorIndex: Int)
  extends RuntimeException(s + (if(errorIndex < 0) "" else " [at index " + errorIndex + "]")) {
  def this() = this(null, -1)
  def this(s: String) = this(s, -1)
  def getErrorIndex(): Int = errorIndex
}

class InputMismatchException(s: String) extends NoSuchElementException(s) {
  def this() = this(null)
}

class InvalidPropertiesFormatException(s: String) extends java.io.IOException(s) {
  def this(e: Throwable) {
    this(if(e == null) null.asInstanceOf[String] else e.toString())
    this.initCause(e)
  }
  // private def writeObject(out: java.io.ObjectOutputStream) =
  //   throw new java.io.NotSerializableException("Not serializable.")
  // private def readObject(in: java.io.ObjectInputStream) = 
  //   throw new java.io.NotSerializableException("Not serializable.")
}

class MissingFormatArgumentException private() extends IllegalFormatException {
  private var s: String = null
  def this(s: String) {
    this()
    if (s == null)
      throw new NullPointerException()
    this.s = s
  }
  def getFormatSpecifier(): String = s
  override def getMessage(): String = "Format specifier '" + s + "'"
}

class MissingFormatWidthException private() extends IllegalFormatException {
  private var s: String = null
  def this(s: String) {
    this()
    if (s == null)
      throw new NullPointerException()
    this.s = s
  }
  def getFormatSpecifier(): String = s
  override def getMessage(): String = s
}

class MissingResourceException private[util](
    s: String, private var className: String, private var key: String, e: Throwable)
    extends RuntimeException(s, e) {
  def this(s: String, className: String, key: String) = this(s, className, key, null)
  def getClassName(): String = className
  def getKey(): String = key
}

class NoSuchElementException(s: String) extends RuntimeException(s) {
  def this() = this(null)
}

class TooManyListenersException(s: String) extends Exception(s) {
  def this() = this(null)
}

class UnknownFormatConversionException private () extends IllegalFormatException {
  private var s: String = null
  def this(s: String) {
    this()
    if (s == null)
      throw new NullPointerException()
    this.s = s
  }
  def getConversion(): String = s
  override def getMessage(): String = s"Conversion = '$s'"
}

class UnknownFormatFlagsException private() extends IllegalFormatException {
  private var flags: String = null
  def this(f: String) {
    this()
    if (f == null)
      throw new NullPointerException()
    this.flags = f
  }
  def getFlags(): String = flags
  override def getMessage(): String = "Flags = " + flags
}