| 1 |
/** |
| 2 |
* ======================================== |
| 3 |
* JFreeReport : a free Java report library |
| 4 |
* ======================================== |
| 5 |
* |
| 6 |
* Project Info: http://reporting.pentaho.org/ |
| 7 |
* |
| 8 |
* (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors. |
| 9 |
* |
| 10 |
* This library is free software; you can redistribute it and/or modify it under the terms |
| 11 |
* of the GNU Lesser General Public License as published by the Free Software Foundation; |
| 12 |
* either version 2.1 of the License, or (at your option) any later version. |
| 13 |
* |
| 14 |
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 15 |
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 16 |
* See the GNU Lesser General Public License for more details. |
| 17 |
* |
| 18 |
* You should have received a copy of the GNU Lesser General Public License along with this |
| 19 |
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, |
| 20 |
* Boston, MA 02111-1307, USA. |
| 21 |
* |
| 22 |
* [Java is a trademark or registered trademark of Sun Microsystems, Inc. |
| 23 |
* in the United States and other countries.] |
| 24 |
* |
| 25 |
* ------------ |
| 26 |
* $Id: DefaultDataFlags.java 10756 2009-12-02 15:58:24Z tmorgner $ |
| 27 |
* ------------ |
| 28 |
* (C) Copyright 2000-2005, by Object Refinery Limited. |
| 29 |
* (C) Copyright 2005-2007, by Pentaho Corporation. |
| 30 |
*/ |
| 31 |
package org.jfree.report.data; |
| 32 |
|
| 33 |
import java.util.Date; |
| 34 |
|
| 35 |
import org.jfree.report.DataFlags; |
| 36 |
|
| 37 |
/** |
| 38 |
* Creation-Date: 20.02.2006, 16:00:34 |
| 39 |
* |
| 40 |
* @author Thomas Morgner |
| 41 |
*/ |
| 42 |
public class DefaultDataFlags implements DataFlags |
| 43 |
{ |
| 44 |
private Object value; |
| 45 |
private boolean changed; |
| 46 |
private String name; |
| 47 |
|
| 48 |
public DefaultDataFlags(final String name, |
| 49 |
final Object value, |
| 50 |
final boolean changed) |
| 51 |
{ |
| 52 |
this.value = value; |
| 53 |
this.changed = changed; |
| 54 |
this.name = name; |
| 55 |
} |
| 56 |
|
| 57 |
public boolean isNumeric() |
| 58 |
{ |
| 59 |
return value instanceof Number; |
| 60 |
} |
| 61 |
|
| 62 |
public boolean isDate() |
| 63 |
{ |
| 64 |
return value instanceof Date; |
| 65 |
} |
| 66 |
|
| 67 |
public boolean isNull() |
| 68 |
{ |
| 69 |
return value == null; |
| 70 |
} |
| 71 |
|
| 72 |
public boolean isZero() |
| 73 |
{ |
| 74 |
if (isNumeric() == false) |
| 75 |
{ |
| 76 |
return false; |
| 77 |
} |
| 78 |
Number n = (Number) value; |
| 79 |
return (n.floatValue() == 0); |
| 80 |
} |
| 81 |
|
| 82 |
public boolean isNegative() |
| 83 |
{ |
| 84 |
if (isNumeric() == false) |
| 85 |
{ |
| 86 |
return false; |
| 87 |
} |
| 88 |
Number n = (Number) value; |
| 89 |
return (n.floatValue() < 0); |
| 90 |
} |
| 91 |
|
| 92 |
public boolean isPositive() |
| 93 |
{ |
| 94 |
if (isNumeric() == false) |
| 95 |
{ |
| 96 |
return false; |
| 97 |
} |
| 98 |
Number n = (Number) value; |
| 99 |
return (n.floatValue() > 0); |
| 100 |
} |
| 101 |
|
| 102 |
public boolean isChanged() |
| 103 |
{ |
| 104 |
return changed; |
| 105 |
} |
| 106 |
|
| 107 |
public Object getValue() |
| 108 |
{ |
| 109 |
return value; |
| 110 |
} |
| 111 |
|
| 112 |
public String getName() |
| 113 |
{ |
| 114 |
return name; |
| 115 |
} |
| 116 |
|
| 117 |
public String toString () |
| 118 |
{ |
| 119 |
StringBuffer b = new StringBuffer(); |
| 120 |
b.append("DefaultDataFlags={name="); |
| 121 |
b.append(name); |
| 122 |
b.append(", value="); |
| 123 |
b.append(value); |
| 124 |
b.append(", changed="); |
| 125 |
b.append(changed); |
| 126 |
b.append("}"); |
| 127 |
return b.toString(); |
| 128 |
} |
| 129 |
} |