-
Notifications
You must be signed in to change notification settings - Fork 24
/
JSONInteger.java
86 lines (71 loc) · 1.8 KB
/
JSONInteger.java
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
import java.io.PrintWriter;
import java.math.BigInteger;
/**
* JSON integers.
*/
public class JSONInteger implements JSONValue {
// +--------+------------------------------------------------------
// | Fields |
// +--------+
/**
* The underlying integer.
*/
BigInteger value;
// +--------------+------------------------------------------------
// | Constructors |
// +--------------+
/**
* Create a new integer given the underlying string.
*/
public JSONInteger(String str) {
this.value = new BigInteger(str);
} // JSONInteger(String)
/**
* Create a new integer given a BigInteger.
*/
public JSONInteger(BigInteger value) {
this.value = value;
} // JSONInteger(BigInteger)
/**
* Create a new integer given an integer or long.
*/
public JSONInteger(long l) {
this.value = BigInteger.valueOf(l);
} // JSONInteger(long)
// +-------------------------+-------------------------------------
// | Standard object methods |
// +-------------------------+
/**
* Convert to a string (e.g., for printing).
*/
public String toString() {
return this.value.toString();
} // toString()
/**
* Compare to another object.
*/
public boolean equals(Object other) {
return true; // STUB
} // equals(Object)
/**
* Compute the hash code.
*/
public int hashCode() {
return 0; // STUB
} // hashCode()
// +--------------------+------------------------------------------
// | Additional methods |
// +--------------------+
/**
* Write the value as JSON.
*/
public void writeJSON(PrintWriter pen) {
// STUB
} // writeJSON(PrintWriter)
/**
* Get the underlying value.
*/
public BigInteger getValue() {
return this.value;
} // getValue()
} // class JSONInteger