summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/uic/barcode/asn1/datatypes/Asn1BigInteger.java
blob: 4adca2294d5cdebb825e161ebe94c8d693349fb2 (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
package org.uic.barcode.asn1.datatypes;

import java.math.BigInteger;

//outdated: use BigInteger 
public class Asn1BigInteger {

    private final BigInteger value;

    public Asn1BigInteger(final BigInteger value) {
        this.value = value;
    }

    @Override public String toString() {
        return "" + value;
    }

    public BigInteger value() { return value; }
    
    public Long longValue() {
    	return value.longValue();
    }
    
    public Integer intValue() {
    	return value.intValue();
    }    
    
	public Asn1BigInteger(Long num) {
		this.value = BigInteger.valueOf(num);
	}
	
	public Asn1BigInteger(long num) {
		this.value = BigInteger.valueOf(num);
	}	
	
	public Asn1BigInteger(Integer num) {
		this.value = BigInteger.valueOf(num);
	}
	
	public Asn1BigInteger(int num) {
		this.value = BigInteger.valueOf(num);
	}		
	
	public static Long toLong(Asn1BigInteger object) {
		if (object == null) return null;
		return object.longValue();
	}
	
	public static Asn1BigInteger toAsn1(Long object) {
		if (object == null) return null;
		return new Asn1BigInteger(object);
	}

	public static Asn1BigInteger toAsn1(Integer object) {
		if (object == null) return null;
		return new Asn1BigInteger(object);
	}
	
	public Long toLong(){
		if (this.value != null) {
			return this.value.longValue();
		} 
		return null;
	}
	
	public BigInteger toBigInteger(){
		return value;
	}
	
	
	
}