001: /**
002: * ===========================================
003: * JFreeReport : a free Java reporting library
004: * ===========================================
005: *
006: * Project Info: http://reporting.pentaho.org/
007: *
008: * (C) Copyright 2001-2007, by Object Refinery Ltd, 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: * FormatSpecification.java
027: * ------------
028: * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
029: */package org.jfree.report.filter;
030:
031: /**
032: * The FormatSpecification classifies a format string into the 4 known classes of format-strings of Java. This is used
033: * by the Excel-export to transform the raw-formatstring into a suitable cell-format.
034: * <p/>
035: * This class is plain value-carrier. It is mutable and should not be used outside the scope of querying
036: * raw-datasources.
037: *
038: * @author : Thomas Morgner
039: */
040: public class FormatSpecification {
041: /**
042: * A constant declaring that the format-type cannot be determined in a reliable way.
043: */
044: public static final int TYPE_UNDEFINED = 0;
045: /**
046: * A constant declaring that the format-type is a simple date-format.
047: */
048: public static final int TYPE_DATE_FORMAT = 1;
049: /**
050: * A constant declaring that the format-type is a decimal-format.
051: */
052: public static final int TYPE_DECIMAL_FORMAT = 2;
053: /**
054: * A constant declaring that the format-type is a message-format.
055: */
056: public static final int TYPE_MESSAGE_FORMAT = 3;
057: /**
058: * A constant declaring that the format-type is a choice-format.
059: */
060: public static final int TYPE_CHOICE_FORMAT = 4;
061: /**
062: * The format type as one of the constants defined in this class.
063: */
064: private int type;
065: /**
066: * The raw java format string.
067: */
068: private String formatString;
069:
070: /**
071: * Creates an empty object. This object must be filled with valid values by calling {@link #redefine(int,String)}
072: * later.
073: */
074: public FormatSpecification() {
075: }
076:
077: /**
078: * Redefines the values stored in this specification object.
079: *
080: * @param type the type, one of the constants declared in this class.
081: * @param formatString the format string.
082: */
083: public void redefine(final int type, final String formatString) {
084: this .type = type;
085: this .formatString = formatString;
086: }
087:
088: /**
089: * Returns the type of the format string contained in this class.
090: *
091: * @return the type.
092: */
093: public int getType() {
094: return type;
095: }
096:
097: /**
098: * Returns the raw-format-string.
099: *
100: * @return the format string.
101: */
102: public String getFormatString() {
103: return formatString;
104: }
105: }
|