01: /*
02: * Copyright 2001-2006 C:1 Financial Services GmbH
03: *
04: * This software is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License Version 2.1, as published by the Free Software Foundation.
07: *
08: * This software is distributed in the hope that it will be useful,
09: * but WITHOUT ANY WARRANTY; without even the implied warranty of
10: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11: * Lesser General Public License for more details.
12: *
13: * You should have received a copy of the GNU Lesser General Public
14: * License along with this library; if not, write to the Free Software
15: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
16: */
17:
18: package de.finix.contelligent.content;
19:
20: import java.io.IOException;
21:
22: import de.finix.contelligent.CallData;
23: import de.finix.contelligent.Component;
24: import de.finix.contelligent.core.TimeService;
25: import de.finix.contelligent.exception.ComponentPersistenceException;
26: import de.finix.contelligent.logging.LoggingService;
27: import de.finix.contelligent.resource.NumberResource;
28:
29: public class ContelligentNumberContent extends ContelligentContent
30: implements NumberContent {
31: final static org.apache.log4j.Logger log = LoggingService
32: .getLogger(ContelligentNumberContent.class);
33:
34: public ContelligentNumberContent(Component component)
35: throws Exception {
36: super (component);
37: }
38:
39: private NumberResource getNumberResource(CallData callData)
40: throws IOException {
41: return (NumberResource) getResourceMap().get(
42: getResourceIdentifier(callData));
43: }
44:
45: public Object getContentValue(CallData callData)
46: throws IOException, ComponentPersistenceException {
47: return getNumber(callData);
48: }
49:
50: public long lastModified(CallData callData) throws IOException {
51: return getNumberResource(callData).getLastModified();
52: }
53:
54: public Number getNumber(CallData callData) throws IOException {
55: return getNumberResource(callData).getNumber();
56: }
57:
58: public void setNumber(Number value, CallData callData)
59: throws ComponentPersistenceException {
60: NumberResource resource = new NumberResource(value, TimeService
61: .getInstance().currentTimeMillis());
62: setResource(resource, callData);
63: }
64:
65: public int intValue(CallData callData) throws IOException {
66: return getNumberResource(callData).getNumber().intValue();
67: }
68:
69: public long longValue(CallData callData) throws IOException {
70: return getNumberResource(callData).getNumber().longValue();
71: }
72:
73: public float floatValue(CallData callData) throws IOException {
74: return getNumberResource(callData).getNumber().floatValue();
75: }
76:
77: public double doubleValue(CallData callData) throws IOException {
78: return getNumberResource(callData).getNumber().doubleValue();
79: }
80:
81: public String getConstraints(CallData callData) throws IOException {
82: return getNumberResource(callData).getConstraints();
83: }
84: }
|