001: /**
002: * ========================================
003: * JFreeReport : a free Java report library
004: * ========================================
005: *
006: * Project Info: http://reporting.pentaho.org/
007: *
008: * (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors.
009: *
010: * This library is free software; you can redistribute it and/or modify it under the terms
011: * of the GNU Lesser General Public License as published by the Free Software Foundation;
012: * either version 2.1 of the License, or (at your option) any later version.
013: *
014: * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
015: * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
016: * See the GNU Lesser General Public License for more details.
017: *
018: * You should have received a copy of the GNU Lesser General Public License along with this
019: * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
020: * Boston, MA 02111-1307, USA.
021: *
022: * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
023: * in the United States and other countries.]
024: *
025: * ------------
026: * $Id: DefaultDataFlags.java 3525 2007-10-16 11:43:48Z tmorgner $
027: * ------------
028: * (C) Copyright 2000-2005, by Object Refinery Limited.
029: * (C) Copyright 2005-2007, by Pentaho Corporation.
030: */package org.jfree.report.data;
031:
032: import java.util.Date;
033:
034: import org.jfree.report.DataFlags;
035:
036: /**
037: * Creation-Date: 20.02.2006, 16:00:34
038: *
039: * @author Thomas Morgner
040: */
041: public class DefaultDataFlags implements DataFlags {
042: private Object value;
043: private boolean changed;
044: private String name;
045:
046: public DefaultDataFlags(final String name, final Object value,
047: final boolean changed) {
048: this .value = value;
049: this .changed = changed;
050: this .name = name;
051: }
052:
053: public boolean isNumeric() {
054: return value instanceof Number;
055: }
056:
057: public boolean isDate() {
058: return value instanceof Date;
059: }
060:
061: public boolean isNull() {
062: return value == null;
063: }
064:
065: public boolean isZero() {
066: if (isNumeric() == false) {
067: return false;
068: }
069: final Number n = (Number) value;
070: return (n.floatValue() == 0);
071: }
072:
073: public boolean isNegative() {
074: if (isNumeric() == false) {
075: return false;
076: }
077: final Number n = (Number) value;
078: return (n.floatValue() < 0);
079: }
080:
081: public boolean isPositive() {
082: if (isNumeric() == false) {
083: return false;
084: }
085: final Number n = (Number) value;
086: return (n.floatValue() > 0);
087: }
088:
089: public boolean isChanged() {
090: return changed;
091: }
092:
093: public Object getValue() {
094: return value;
095: }
096:
097: public String getName() {
098: return name;
099: }
100:
101: public String toString() {
102: final StringBuffer b = new StringBuffer();
103: b.append("DefaultDataFlags={name=");
104: b.append(name);
105: b.append(", value=");
106: b.append(value);
107: b.append(", changed=");
108: b.append(changed);
109: b.append("}");
110: return b.toString();
111: }
112: }
|