01: /*
02: * Copyright Aduna (http://www.aduna-software.com/) (c) 2007.
03: *
04: * Licensed under the Aduna BSD-style license.
05: */
06: package org.openrdf.sail.memory.model;
07:
08: import java.math.BigDecimal;
09: import java.math.BigInteger;
10:
11: import org.openrdf.model.URI;
12: import org.openrdf.model.vocabulary.XMLSchema;
13:
14: /**
15: * An extension of MemLiteral that stores an integer value to avoid parsing.
16: *
17: * @author Arjohn Kampman
18: */
19: public class IntegerMemLiteral extends MemLiteral {
20:
21: /*-----------*
22: * Variables *
23: *-----------*/
24:
25: /**
26: *
27: */
28: private static final long serialVersionUID = -8121416400439616510L;
29:
30: private BigInteger value;
31:
32: /*--------------*
33: * Constructors *
34: *--------------*/
35:
36: public IntegerMemLiteral(Object creator, BigInteger value) {
37: this (creator, value, XMLSchema.INTEGER);
38: }
39:
40: public IntegerMemLiteral(Object creator, BigInteger value,
41: URI datatype) {
42: this (creator, value.toString(), value, datatype);
43: }
44:
45: public IntegerMemLiteral(Object creator, String label,
46: BigInteger value, URI datatype) {
47: super (creator, label, datatype);
48: this .value = value;
49: }
50:
51: /*---------*
52: * Methods *
53: *---------*/
54:
55: @Override
56: public byte byteValue() {
57: return value.byteValue();
58: }
59:
60: @Override
61: public short shortValue() {
62: return value.shortValue();
63: }
64:
65: @Override
66: public int intValue() {
67: return value.intValue();
68: }
69:
70: @Override
71: public long longValue() {
72: return value.longValue();
73: }
74:
75: @Override
76: public float floatValue() {
77: return value.floatValue();
78: }
79:
80: @Override
81: public double doubleValue() {
82: return value.doubleValue();
83: }
84:
85: @Override
86: public BigInteger integerValue() {
87: return value;
88: }
89:
90: @Override
91: public BigDecimal decimalValue() {
92: return new BigDecimal(value);
93: }
94: }
|