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 a decimal value to avoid parsing.
16: *
17: * @author Arjohn Kampman
18: */
19: public class DecimalMemLiteral extends MemLiteral {
20:
21: /*-----------*
22: * Variables *
23: *-----------*/
24:
25: /**
26: *
27: */
28: private static final long serialVersionUID = 6760727653986046772L;
29:
30: private BigDecimal value;
31:
32: /*--------------*
33: * Constructors *
34: *--------------*/
35:
36: public DecimalMemLiteral(Object creator, BigDecimal value) {
37: this (creator, value, XMLSchema.DECIMAL);
38: }
39:
40: public DecimalMemLiteral(Object creator, BigDecimal value,
41: URI datatype) {
42: this (creator, value.toPlainString(), value, datatype);
43: }
44:
45: public DecimalMemLiteral(Object creator, String label,
46: BigDecimal 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.toBigInteger();
88: }
89:
90: @Override
91: public BigDecimal decimalValue() {
92: return value;
93: }
94: }
|