📄 plaindatarow.java
字号:
/**
* ========================================
* JFreeReport : a free Java report library
* ========================================
*
* Project Info: http://www.jfree.org/jfreereport/index.html
* Project Lead: Thomas Morgner (taquera@sherito.org);
*
* (C) Copyright 2000-2003, by Simba Management Limited and Contributors.
*
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* ------------------------------
* PlainDataRow.java
* ------------------------------
* (C)opyright 2003, by Thomas Morgner and Contributors.
*
* Original Author: Thomas Morgner;
* Contributor(s): David Gilbert (for Simba Management Limited);
*
* $Id: PlainDataRow.java,v 1.2 2004/04/20 18:54:53 taqua Exp $
*
* Changes
* -------------------------
* 28.10.2003 : Initial version
*
*/
package org.jfree.designer.visualeditor;
import java.io.Serializable;
import java.util.ArrayList;
import org.jfree.report.Band;
import org.jfree.report.DataRow;
import org.jfree.report.Element;
import org.jfree.report.Group;
import org.jfree.report.JFreeReport;
import org.jfree.report.filter.DataRowConnectable;
import org.jfree.report.filter.DataSource;
import org.jfree.report.states.DataRowConnector;
public final class PlainDataRow
implements DataRow, Serializable
{
private final ArrayList valueList;
private final ArrayList nameList;
public PlainDataRow ()
{
this.nameList = new ArrayList();
this.valueList = new ArrayList();
}
public final void clear ()
{
nameList.clear();
valueList.clear();
}
public final void removeColumn (final String name)
{
final int idx = nameList.indexOf(name);
if (idx == -1)
{
return;
}
nameList.remove(idx);
valueList.remove(idx);
}
/**
* Returns the column position of the column, expression or function with the given name
* or -1 if the given name does not exist in this DataRow.
*
* @param name the item name.
* @return the item index.
*/
public final int findColumn (final String name)
{
return nameList.indexOf(name);
}
/**
* Returns the value of the function, expression or column in the tablemodel using the
* column number. For functions and expressions, the <code>getValue()</code> method is
* called and for columns from the tablemodel the tablemodel method
* <code>getValueAt(row, column)</code> gets called.
*
* @param col the item index.
* @return the value.
*/
public final Object get (final int col)
{
return valueList.get(col);
}
/**
* Returns the value of the function, expression or column using its specific name. The
* given name is translated into a valid column number and the the column is queried.
* For functions and expressions, the <code>getValue()</code> method is called and for
* columns from the tablemodel the tablemodel method <code>getValueAt(row,
* column)</code> gets called.
*
* @param col the item index.
* @return the value.
*
* @throws IllegalStateException if the datarow detected a deadlock.
*/
public final Object get (final String col)
throws IllegalStateException
{
final int colIdx = findColumn(col);
if (colIdx == -1)
{
return null;
}
return get(colIdx);
}
/**
* Returns the number of columns, expressions and functions and marked ReportProperties
* in the report.
*
* @return the item count.
*/
public final int getColumnCount ()
{
return nameList.size();
}
/**
* Returns the name of the column, expression or function. For columns from the
* tablemodel, the tablemodels <code>getColumnName</code> method is called. For
* functions, expressions and report properties the assigned name is returned.
*
* @param col the item index.
* @return the name.
*/
public final String getColumnName (final int col)
{
return (String) nameList.get(col);
}
public final void addColumn (final String name, final Object value)
{
nameList.add(name);
valueList.add(value);
}
/**
* Connects the Report and all contained bands and all Elements within the bands to this
* DataRow.
*
* @param report the report which will be connected
*/
public final void connectDataSources (final JFreeReport report)
{
connectDataSources(report.getPageFooter());
connectDataSources(report.getPageHeader());
connectDataSources(report.getReportFooter());
connectDataSources(report.getReportHeader());
connectDataSources(report.getItemBand());
final int groupCount = report.getGroupCount();
for (int i = 0; i < groupCount; i++)
{
final Group g = report.getGroup(i);
connectDataSources(g.getFooter());
connectDataSources(g.getHeader());
}
}
/**
* Connects the Band and all Elements within the band to this DataRow.
*
* @param band the band which will be connected.
*/
protected final void connectDataSources (final Band band)
{
final Element[] elements = band.getElementArray();
for (int i = 0; i < elements.length; i++)
{
final Element e = elements[i];
if (e instanceof Band)
{
connectDataSources((Band) e);
}
else
{
connectDataSource(e);
}
}
}
public final void connectDataSource (final Element e)
{
final DataSource ds = DataRowConnector.getLastDatasource(e);
if (ds instanceof DataRowConnectable)
{
final DataRowConnectable dc = (DataRowConnectable) ds;
dc.connectDataRow(this);
}
}
/**
* Connects the Report and all contained bands and all Elements within the bands to this
* DataRow.
*
* @param report the report which will be connected
*/
public final void disconnectDataSources (final JFreeReport report)
{
disconnectDataSources(report.getPageFooter());
disconnectDataSources(report.getPageHeader());
disconnectDataSources(report.getReportFooter());
disconnectDataSources(report.getReportHeader());
disconnectDataSources(report.getItemBand());
final int groupCount = report.getGroupCount();
for (int i = 0; i < groupCount; i++)
{
final Group g = report.getGroup(i);
disconnectDataSources(g.getFooter());
disconnectDataSources(g.getHeader());
}
}
/**
* Connects the Band and all Elements within the band to this DataRow.
*
* @param band the band which will be connected.
*/
protected final void disconnectDataSources (final Band band)
{
final Element[] elements = band.getElementArray();
for (int i = 0; i < elements.length; i++)
{
final Element e = elements[i];
if (e instanceof Band)
{
connectDataSources((Band) e);
}
else
{
disconnectDataSource(e);
}
}
}
public final void disconnectDataSource (final Element e)
{
final DataSource ds = DataRowConnector.getLastDatasource(e);
if (ds instanceof DataRowConnectable)
{
final DataRowConnectable dc = (DataRowConnectable) ds;
dc.disconnectDataRow(this);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -