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.model.impl;
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 {@link LiteralImpl} that stores an integer value using a
16: * {@link BigDecimal} object.
17: *
18: * @author Arjohn Kampman
19: */
20: public class DecimalLiteralImpl extends LiteralImpl {
21:
22: private static final long serialVersionUID = -3310213093222314380L;
23:
24: private final BigDecimal value;
25:
26: /**
27: * Creates an xsd:decimal literal with the specified value.
28: */
29: public DecimalLiteralImpl(BigDecimal value) {
30: this (value, XMLSchema.DECIMAL);
31: }
32:
33: /**
34: * Creates a literal with the specified value and datatype.
35: */
36: public DecimalLiteralImpl(BigDecimal value, URI datatype) {
37: // TODO: maybe DecimalLiteralImpl should not extend LiteralImpl?
38: super (value.toPlainString(), datatype);
39: this .value = value;
40: }
41:
42: @Override
43: public byte byteValue() {
44: return value.byteValue();
45: }
46:
47: @Override
48: public short shortValue() {
49: return value.shortValue();
50: }
51:
52: @Override
53: public int intValue() {
54: return value.intValue();
55: }
56:
57: @Override
58: public long longValue() {
59: return value.longValue();
60: }
61:
62: @Override
63: public float floatValue() {
64: return value.floatValue();
65: }
66:
67: @Override
68: public double doubleValue() {
69: return value.doubleValue();
70: }
71:
72: @Override
73: public BigInteger integerValue() {
74: return value.toBigInteger();
75: }
76:
77: @Override
78: public BigDecimal decimalValue() {
79: return value;
80: }
81: }
|