📄 reportconfig.java
字号:
/* CRMS, customer relationship management system Copyright (C) 2003 Service To Youth Council This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA For further information contact the SYC ICT department on GPL@syc.net.au 98 Kermode Street North Adelaide South Australia SA 5006 +61 (0)8 8367 0755 *//* * ReportConfig.java * * Created on 14 June 2003, 12:49 */package crms.vo;import java.util.ArrayList;import org.w3c.dom.*;import crms.util.*;import org.apache.log4j.Logger;import crms.report.*;/** * * @author Administrator */public class ReportConfig { public static Logger logger = Logger.getLogger(ReportConfig.class); public static String NODE_KEY = "key"; public static String NODE_COLUMNS = "columns"; public static String NODE_PROCESSOR_CLASS = "processor-class"; public static String NODE_REPORT_FORM = "report-form"; public static String NODE_REPORT_HEADING = "heading"; public static String NODE_REPORT_SUBHEADING = "sub-heading"; public static String NODE_REPORT_ORIENTATION = "orientation"; public static String NODE_REPORT_NAME = "name"; public static String NODE_REPORT_DESC = "description"; private String reportKey = null; private ArrayList columns = new ArrayList(); private String processorClass = null; private String reportForm = null; private String filePath = null; private String heading = null; private String subHeading = null; private String name = null; private String description = null; private int orientation = Report.ORIENTATION_PORTRAIT; /** Creates a new instance of ReportConfig */ public ReportConfig() { } public ReportConfig(String key) { this.reportKey = key; } public void setKey(String key) { this.reportKey = key; } public String getKey() { return reportKey; } public void setProcessorClass(String className) { this.processorClass = className; } public String getProcessorClass() { return processorClass; } public void setReportForm(String formClassName) { this.reportForm = formClassName; } public String getReportForm() { return reportForm; } public void setHeading(String heading) { this.heading = heading; } public String getHeading() { return heading; } /** * <p>Sets the text that will appear as the sub-heading of the report.</p> * <p><b>Note:</b> If this is set in the ReportProcessor code, it will * overrride the default sub-heading specified in the ReportConfig's XML * file.</p> * * @param subHead Text to set sub-heading. */ public void setSubHeading(String subHead) { this.subHeading = subHead; } public String getSubHeading() { return subHeading; } public void setOrientation(int orientation) { this.orientation = orientation; } public int getOrientation() { return orientation; } public void setName(String name) { this.name = name; } public String getName() { return name; } public void setDescription(String desc) { this.description = desc; } public String getDescription() { return description; } public void addColumn(ReportColumn col) { columns.add(col); } public ReportColumn getColumn(int i) { return (ReportColumn) columns.get(i); } public int getColumnCount() { return columns.size(); } public void setFilePath(String filePath) { this.filePath = filePath; } public String getFilePath() { return filePath; } public String[] getHeadings() { String[] headings = new String[getColumnCount()]; for (int i=0; i < getColumnCount(); i++) { headings[i] = getColumn(i).getHeading(); } return headings; } public int[] getWidths() { int[] widths = new int[getColumnCount()]; for (int i=0; i < getColumnCount(); i++) { widths[i] = getColumn(i).getColumnWidth(); } return widths; } /** * <p>Creates a ReportConfig from the XML Node supplied.</p> * <p>This is used to generate dynamic ReportConfig objects * that can be simply refined by editing XML files.</p> * * @param configNode A JDOM Node representing the root of * the ReportConfig XML definition. * @return ReportConfig object. */ public static ReportConfig createFromNode(Node configNode) { String key = XMLUtil.getTextForNodeNamed(NODE_KEY, configNode); ReportConfig config = new ReportConfig(key); config.setProcessorClass(XMLUtil.getTextForNodeNamed(NODE_PROCESSOR_CLASS, configNode)); logger.debug("processor-class: " + config.getProcessorClass()); config.setReportForm(XMLUtil.getTextForNodeNamed(NODE_REPORT_FORM, configNode)); logger.debug("report-form: " + config.getProcessorClass()); config.setHeading(XMLUtil.getTextForNodeNamed(NODE_REPORT_HEADING, configNode)); config.setSubHeading(XMLUtil.getTextForNodeNamed(NODE_REPORT_SUBHEADING, configNode)); config.setName(XMLUtil.getTextForNodeNamed(NODE_REPORT_NAME, configNode)); config.setDescription(XMLUtil.getTextForNodeNamed(NODE_REPORT_DESC, configNode)); String orText = XMLUtil.getTextForNodeNamed(NODE_REPORT_ORIENTATION, configNode); if (orText.toLowerCase().equals("portrait")) { config.setOrientation(Report.ORIENTATION_PORTRAIT); } else if (orText.toLowerCase().equals("landscape")) { config.setOrientation(Report.ORIENTATION_LANDSCAPE); } Node columnsNode = XMLUtil.getNode("columns", configNode); NodeList columns = columnsNode.getChildNodes(); for (int i=0; i < columns.getLength(); i++) { Node columnNode = columns.item(i); if (columnNode.getNodeName().equals("column")) { ReportColumn col = ReportColumn.createFromNode(columnNode); config.addColumn(col); } } return config; } public String toString() { return getName(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -