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.awt.Color;
21: import java.io.IOException;
22:
23: import de.finix.contelligent.CallData;
24: import de.finix.contelligent.Component;
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 ContelligentColorContent extends ContelligentContent
30: implements ColorContent {
31: final static org.apache.log4j.Logger log = LoggingService
32: .getLogger(ContelligentColorContent.class);
33:
34: public ContelligentColorContent(Component component)
35: throws Exception {
36: super (component);
37: }
38:
39: public Object getContentValue(CallData callData)
40: throws IOException, ComponentPersistenceException {
41: return getColor(callData);
42: }
43:
44: private NumberResource getNumberResource(CallData callData) {
45: return (NumberResource) getResourceMap().get(
46: getResourceIdentifier(callData));
47: }
48:
49: public long lastModified(CallData callData) throws IOException {
50: return getNumberResource(callData).getLastModified();
51: }
52:
53: public Color getColor(CallData callData) throws IOException {
54: if (getNumberResource(callData) != null) {
55: return new Color(getNumberResource(callData).getNumber()
56: .intValue());
57: } else {
58: log
59: .warn("Undefined color requested, returning red as indicator for missing color");
60: return Color.red;
61: }
62: }
63: }
|