FR [ 2804629 ] AbstractExcelExporter getters should be public

https://sourceforge.net/tracker/?func=detail&aid=2804629&group_id=176962&atid=879335
This commit is contained in:
teo_sarca 2009-06-11 06:57:15 +00:00
parent ecf839802b
commit 98832daff2
5 changed files with 93 additions and 41 deletions

View File

@ -50,18 +50,70 @@ import org.compiere.util.Util;
*/ */
public abstract class AbstractExcelExporter public abstract class AbstractExcelExporter
{ {
protected abstract boolean isFunctionRow(); /**
protected abstract int getColumnCount(); * Is the current Row a Function Row
protected abstract int getRowCount(); * @return true if function row
*/
public abstract boolean isFunctionRow();
/**
* Get Columns Count
* @return number of columns
*/
public abstract int getColumnCount();
/**
* Get Rows Count
* @return number of rows
*/
public abstract int getRowCount();
/**
* Set current row
* @param row row index
*/
protected abstract void setCurrentRow(int row); protected abstract void setCurrentRow(int row);
protected abstract boolean isColumnPrinted(int col);
protected abstract String getHeaderName(int col); /**
protected abstract int getDisplayType(int row, int col); * Check if column is printed (displayed)
protected abstract Object getValueAt(int row, int col); * @param col column index
protected abstract boolean isPageBreak(int row, int col); * @return true if is visible
*/
public abstract boolean isColumnPrinted(int col);
/**
* Get column header name
* @param col column index
* @return header name
*/
public abstract String getHeaderName(int col);
/**
* Get cell display type (see {@link DisplayType})
* @param row row index
* @param col column index
* @return display type
*/
public abstract int getDisplayType(int row, int col);
/**
* Get cell value
* @param row row index
* @param col column index
* @return cell value
*/
public abstract Object getValueAt(int row, int col);
/**
* Check if there is a page break on given cell
* @param row row index
* @param col column index
* @return true if there is a page break
*/
public abstract boolean isPageBreak(int row, int col);
/** Logger */ /** Logger */
protected CLogger log = CLogger.getCLogger(getClass()); protected final CLogger log = CLogger.getCLogger(getClass());
// //
private HSSFWorkbook m_workbook; private HSSFWorkbook m_workbook;
private HSSFDataFormat m_dataFormat; private HSSFDataFormat m_dataFormat;

View File

@ -42,12 +42,12 @@ public class ArrayExcelExporter extends AbstractExcelExporter {
} }
@Override @Override
protected int getColumnCount() { public int getColumnCount() {
return m_data.get(0).size(); return m_data.get(0).size();
} }
@Override @Override
protected int getDisplayType(int row, int col) { public int getDisplayType(int row, int col) {
ArrayList<Object> dataRow = m_data.get(row+1); ArrayList<Object> dataRow = m_data.get(row+1);
Object value = dataRow.get(col); Object value = dataRow.get(col);
if (value == null) if (value == null)
@ -74,7 +74,7 @@ public class ArrayExcelExporter extends AbstractExcelExporter {
} }
@Override @Override
protected String getHeaderName(int col) { public String getHeaderName(int col) {
Object o = m_data.get(0).get(col); Object o = m_data.get(0).get(col);
String name = o != null ? o.toString() : null; String name = o != null ? o.toString() : null;
String nameTrl = Msg.translate(getLanguage(), name); String nameTrl = Msg.translate(getLanguage(), name);
@ -84,29 +84,29 @@ public class ArrayExcelExporter extends AbstractExcelExporter {
} }
@Override @Override
protected int getRowCount() { public int getRowCount() {
return m_data.size() - 1; return m_data.size() - 1;
} }
@Override @Override
protected Object getValueAt(int row, int col) { public Object getValueAt(int row, int col) {
ArrayList<Object> dataRow = m_data.get(row+1); ArrayList<Object> dataRow = m_data.get(row+1);
Object value = dataRow.get(col); Object value = dataRow.get(col);
return value; return value;
} }
@Override @Override
protected boolean isColumnPrinted(int col) { public boolean isColumnPrinted(int col) {
return true; return true;
} }
@Override @Override
protected boolean isFunctionRow() { public boolean isFunctionRow() {
return false; return false;
} }
@Override @Override
protected boolean isPageBreak(int row, int col) { public boolean isPageBreak(int row, int col) {
return false; return false;
} }

View File

@ -40,31 +40,31 @@ public class GridTabExcelExporter extends AbstractExcelExporter
} }
@Override @Override
protected int getColumnCount() public int getColumnCount()
{ {
return m_tab.getFieldCount(); return m_tab.getFieldCount();
} }
@Override @Override
protected int getDisplayType(int row, int col) public int getDisplayType(int row, int col)
{ {
return m_tab.getField(col).getDisplayType(); return m_tab.getField(col).getDisplayType();
} }
@Override @Override
protected String getHeaderName(int col) public String getHeaderName(int col)
{ {
return m_tab.getField(col).getHeader(); return m_tab.getField(col).getHeader();
} }
@Override @Override
protected int getRowCount() public int getRowCount()
{ {
return m_tab.getRowCount(); return m_tab.getRowCount();
} }
@Override @Override
protected Object getValueAt(int row, int col) public Object getValueAt(int row, int col)
{ {
GridField f = m_tab.getField(col); GridField f = m_tab.getField(col);
Object key = m_tab.getValue(row, f.getColumnName()); Object key = m_tab.getValue(row, f.getColumnName());
@ -87,7 +87,7 @@ public class GridTabExcelExporter extends AbstractExcelExporter
} }
@Override @Override
protected boolean isColumnPrinted(int col) public boolean isColumnPrinted(int col)
{ {
GridField f = m_tab.getField(col); GridField f = m_tab.getField(col);
// Hide not displayed fields // Hide not displayed fields
@ -103,13 +103,13 @@ public class GridTabExcelExporter extends AbstractExcelExporter
} }
@Override @Override
protected boolean isFunctionRow() public boolean isFunctionRow()
{ {
return false; return false;
} }
@Override @Override
protected boolean isPageBreak(int row, int col) public boolean isPageBreak(int row, int col)
{ {
return false; return false;
} }

View File

@ -46,7 +46,7 @@ extends AbstractExcelExporter
} }
@Override @Override
protected int getColumnCount() { public int getColumnCount() {
return m_printFormat.getItemCount(); return m_printFormat.getItemCount();
} }
@ -65,7 +65,7 @@ extends AbstractExcelExporter
return null; return null;
} }
@Override @Override
protected int getDisplayType(int row, int col) { public int getDisplayType(int row, int col) {
PrintDataElement pde = getPDE(row, col); PrintDataElement pde = getPDE(row, col);
if (pde != null) { if (pde != null) {
return pde.getDisplayType(); return pde.getDisplayType();
@ -75,7 +75,7 @@ extends AbstractExcelExporter
} }
@Override @Override
protected Object getValueAt(int row, int col) { public Object getValueAt(int row, int col) {
PrintDataElement pde = getPDE(row, col); PrintDataElement pde = getPDE(row, col);
Object value = null; Object value = null;
if (pde == null) if (pde == null)
@ -107,23 +107,23 @@ extends AbstractExcelExporter
} }
@Override @Override
protected String getHeaderName(int col) { public String getHeaderName(int col) {
return m_printFormat.getItem(col).getPrintName(getLanguage()); return m_printFormat.getItem(col).getPrintName(getLanguage());
} }
@Override @Override
protected int getRowCount() { public int getRowCount() {
return m_printData.getRowCount(); return m_printData.getRowCount();
} }
@Override @Override
protected boolean isColumnPrinted(int col) { public boolean isColumnPrinted(int col) {
MPrintFormatItem item = m_printFormat.getItem(col); MPrintFormatItem item = m_printFormat.getItem(col);
return item.isPrinted(); return item.isPrinted();
} }
@Override @Override
protected boolean isPageBreak(int row, int col) { public boolean isPageBreak(int row, int col) {
PrintDataElement pde = getPDE(row, col); PrintDataElement pde = getPDE(row, col);
return pde != null ? pde.isPageBreak() : false; return pde != null ? pde.isPageBreak() : false;
} }
@ -134,7 +134,7 @@ extends AbstractExcelExporter
} }
@Override @Override
protected boolean isFunctionRow() { public boolean isFunctionRow() {
return m_printData.isFunctionRow(); return m_printData.isFunctionRow();
} }

View File

@ -31,42 +31,42 @@ extends AbstractExcelExporter
} }
@Override @Override
protected int getColumnCount() { public int getColumnCount() {
return m_model.getColumnCount(); return m_model.getColumnCount();
} }
@Override @Override
protected int getDisplayType(int row, int col) { public int getDisplayType(int row, int col) {
return m_model.getRColumn(col).getDisplayType(); return m_model.getRColumn(col).getDisplayType();
} }
@Override @Override
protected String getHeaderName(int col) { public String getHeaderName(int col) {
return m_model.getRColumn(col).getColHeader(); return m_model.getRColumn(col).getColHeader();
} }
@Override @Override
protected int getRowCount() { public int getRowCount() {
return m_model.getRowCount(); return m_model.getRowCount();
} }
@Override @Override
protected Object getValueAt(int row, int col) { public Object getValueAt(int row, int col) {
return m_model.getValueAt(row, col); return m_model.getValueAt(row, col);
} }
@Override @Override
protected boolean isColumnPrinted(int col) { public boolean isColumnPrinted(int col) {
return true; return true;
} }
@Override @Override
protected boolean isFunctionRow() { public boolean isFunctionRow() {
return m_model.isGroupRow(m_currentRow); return m_model.isGroupRow(m_currentRow);
} }
@Override @Override
protected boolean isPageBreak(int row, int col) { public boolean isPageBreak(int row, int col) {
return false; return false;
} }