Report.java

Index Score
it.businesslogic.ireport
iReport

View: Reasons, Metrics, Source Code

These are the metrics that contribute to the Enerjy Score for this file, ranked by impact. So the metrics listed at the top influence the score to a greater extent that the metrics listed at the bottom.

MetricDescription
CYCLOMATICCyclomatic complexity
COMPARISONSNumber of comparison operators
FUNCTIONSNumber of function declarations
JAVA0034JAVA0034 Missing braces in if statement
RETURNSNumber of return points from functions
LOOPSNumber of loops
DECL_COMMENTSComments in declarations
SIZESize of the file in bytes
OPERATORSNumber of operators
PROGRAM_LENGTHHalstead program length
INTERFACE_COMPLEXITYInterface complexity
BLOCKSNumber of blocks
OPERANDSNumber of operands
EXITSProcedure exits
LOGICAL_LINESNumber of statements
LINESNumber of lines in the source file
LOCLines of code
UNIQUE_OPERANDSNumber of unique operands
ELOCEffective lines of code
JAVA0117JAVA0117 Missing javadoc: method 'method'
EXEC_COMMENTSComments in executable code
PROGRAM_VOCABHalstead program vocabulary
COMMENTSComment lines
PARAMSNumber of formal parameter declarations
DOC_COMMENTNumber of javadoc comment lines
LINE_COMMENTNumber of line comments
JAVA0144JAVA0144 Line exceeds maximum M characters
JAVA0083JAVA0083 Unnecessary instanceof test
WHITESPACENumber of whitespace lines
JAVA0143JAVA0143 Synchronized method
JAVA0076JAVA0076 Use of magic number
JAVA0254JAVA0254 Use enhanced for loop construct instead of Iterator
JAVA0079JAVA0079 Use of instance to reference static member
JAVA0259JAVA0259 Return of collection/array field
JAVA0171JAVA0171 Unused local variable
JAVA0049JAVA0049 Nested block at depth N (maximum: M)
UNIQUE_OPERATORSNumber of unique operators
JAVA0082JAVA0082 Unnecessary widening cast
JAVA0256JAVA0256 Assignment of external collection/array to field
JAVA0119JAVA0119 Control variable changed within body of for loop
JAVA0110JAVA0110 Incorrect javadoc: no @return tag
JAVA0166JAVA0166 Generic exception caught
BLOCK_COMMENTNumber of block comment lines
JAVA0265JAVA0265 Use of Throwable.printStackTrace()
JAVA0068JAVA0068 Modifiers not declared in recommended order
JAVA0108JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
JAVA0007JAVA0007 Should not declare public field
NEST_DEPTHMaximum nesting depth
JAVA0094JAVA0094 Field hides a superclass field
PROGRAM_VOLUMEHalstead program volume
JAVA0136JAVA0136 N methods defined in class (maximum: M)
JAVA0266JAVA0266 Use of System.out
JAVA0116JAVA0116 Missing javadoc: field 'field'
JAVA0126JAVA0126 Method declares unchecked exception in throws
JAVA0109JAVA0109 Incorrect javadoc: no parameter 'parameter'
JAVA0173JAVA0173 Unused method parameter
JAVA0100JAVA0100 Class contains N non-final fields (maximum: M)
JAVA0145JAVA0145 Tab character used in source file
/* * Copyright (C) 2005 - 2008 JasperSoft Corporation. All rights reserved. * http://www.jaspersoft.com. * * Unless you have purchased a commercial license agreement from JasperSoft, * the following license terms apply: * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as published by * the Free Software Foundation. * * This program is distributed WITHOUT ANY WARRANTY; and without 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, see http://www.gnu.org/licenses/gpl.txt * or write to: * * Free Software Foundation, Inc., * 59 Temple Place - Suite 330, * Boston, MA USA 02111-1307 * * * * * Report.java * * Created on 10 febbraio 2003, 19.32 * */ package it.businesslogic.ireport; import it.businesslogic.ireport.gui.MainFrame; import it.businesslogic.ireport.gui.event.ReportDocumentStatusChangedEvent; import it.businesslogic.ireport.gui.event.ReportElementChangedEvent; import it.businesslogic.ireport.gui.event.ReportSubDatasetChangedEvent; import java.util.Vector; import java.util.Iterator; import java.util.Enumeration; //import it.businesslogic.ireport.util.*; import it.businesslogic.ireport.util.Misc; import it.businesslogic.ireport.gui.JReportFrame; import it.businesslogic.ireport.gui.event.StyleChangedEvent; import it.businesslogic.ireport.gui.event.SubDatasetObjectChangedListener; import it.businesslogic.ireport.gui.event.TemplateChangedEvent; import it.businesslogic.ireport.refactoring.ReportRefactor; import net.sf.jasperreports.engine.JRGroup; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import java.io.File; /** * * @author Administrator */ public class Report extends SubDataset implements SubDatasetObjectChangedListener { public static int SCRIPTLET_IREPORT_INTERNAL_HANDLING = 1; public static int SCRIPTLET_NOT_USED = 0; public static int SCRIPTLET_CLASSIC_HANDLING = 2; private int nextGroupId = 0; private IReportFont defaultFont = new IReportFont(); private boolean readOnly = false; private int height = 0; private int width = 0; private Vector elements = new Vector(); private Vector bands = new Vector(); private Vector imports = new Vector(); private Vector templates = new Vector(); public Vector getTemplates() { return templates; } public void setTemplates(Vector templates) { this.templates = templates; } private String filename = ""; private Vector subDatasets = new Vector(); private String encoding = "UTF-8"; private int columnCount = 1; private String printOrder = "Vertical"; private String orientation = "Portrait"; private String whenNoDataType = "NoPages"; private int columnWidth = 535; private int columnSpacing = 0 ; private int leftMargin = 20; private int rightMargin = 20; private int topMargin = 30; private int bottomMargin = 30; private boolean isTitleNewPage = false; private boolean isSummaryNewPage = false; private long loadTime = 0; private Vector fonts = new Vector(); private Vector styles = new Vector(); private JReportFrame reportFrame; private String reportFormat; static int untitledId = 1; private int reportChanges = 1; // By default, a report is changed... private boolean floatColumnFooter = false; private boolean ignorePagination = false; /** used to tell the report when outputting to XML that it needs to set isCode="true" in expressions */ protected boolean usingMultiLineExpressions = false; private String language = "java"; private ScriptletCode scripletCode; private int scriptletHandling = 2; private java.util.HashMap proposedValues = null; private boolean loadingFile = false; private String formatFactoryClass = ""; /** Creates a new instance of Report */ public Report() { super(); setName(it.businesslogic.ireport.util.I18n.getString("untitledReport", "untitled_report_") + untitledId); untitledId++; proposedValues = new java.util.HashMap(); // Add basic variables... getKeywordLookup().addKeyword("$R{*}"); //addParameter(new JRParameter("COLUMN_COUNT", "", )); bands.addElement( new Band(this,"background",0) ); bands.addElement( new Band(this,"title", 50)); bands.addElement( new Band(this,"pageHeader", 50) ); bands.addElement( new Band(this,"columnHeader",30) ); bands.addElement( new Band(this,"detail",100)); bands.addElement( new Band(this,"columnFooter",30) ); bands.addElement( new Band(this,"pageFooter",50)); bands.addElement( new Band(this,"lastPageFooter",50)); bands.addElement( new Band(this,"summary",50) ); bands.addElement( new Band(this,"noData",0) ); //addImport("it.businesslogic.ireport.IReportScriptlet"); addImport("java.util.*"); addImport("net.sf.jasperreports.engine.*"); addImport("net.sf.jasperreports.engine.data.*"); try { scripletCode = new ScriptletCode(ScriptletCode.class.getClassLoader().getResourceAsStream("scriptlet_template.jav")); } catch (Exception ex) { ex.printStackTrace(); } // Set the user option default... this.setLanguage( it.businesslogic.ireport.gui.MainFrame.getMainInstance().getProperties().getProperty("DefaultScriptingLanguage","java") ); this.addSubDatasetObjectChangedListener(this); // Add default style... String rDefStyle = it.businesslogic.ireport.gui.MainFrame.getMainInstance().getProperties().getProperty("DefaultStyle",""); if (rDefStyle.length() > 0) { Vector stylesLib = (Vector)it.businesslogic.ireport.gui.MainFrame.getMainInstance().getStyleLibrarySet(); for (int i=0; i<stylesLib.size(); ++i) { Style s = (Style)stylesLib.get(i); if (s.getName() != null && s.getName().equals(rDefStyle)) { Style s1 = new Style(s); s1.getAttributes().put( s1.ATTRIBUTE_isDefault, "true" ); this.addStyle( s1 ); } } } } /** Creates a new instance of Report reading it by a file...*/ public Report(String xmlFile) throws Exception { this(); untitledId--; // Remove default style... while (getStyles().size() > 0) { this.removeStyle( (Style) this.getStyles().get(0) ); } // Set the real default... ReportReader rr = new ReportReader(this); rr.readFile( xmlFile ); } static public String readPCDATA(Node textNode) { return readPCDATA(textNode,true); } static public String readPCDATA(Node textNode, boolean trim) { NodeList list_child = textNode.getChildNodes(); for (int ck=0; ck< list_child.getLength(); ck++) { Node child_child = (Node)list_child.item(ck); // --- start solution: if there is another node this should be the PCDATA-node Node ns = child_child.getNextSibling(); if (ns != null) child_child = ns; // --- end solution final short nt = child_child.getNodeType(); if ((nt == Node.CDATA_SECTION_NODE) || (nt == Node.TEXT_NODE)) { if (trim) return ((String)child_child.getNodeValue()).trim(); return (String)child_child.getNodeValue(); } } return ""; } static java.awt.Color decodeColor(String colorString) { java.awt.Color color = null; char firstChar = colorString.charAt(0); if (firstChar == '#') { color = new java.awt.Color(Integer.parseInt(colorString.substring(1), 16)); } else if ('0' <= firstChar && firstChar <= '9') { color = new java.awt.Color(Integer.parseInt(colorString)); } else { if (net.sf.jasperreports.engine.xml.JRXmlConstants.getColorMap().containsKey(colorString)) { color = (java.awt.Color)net.sf.jasperreports.engine.xml.JRXmlConstants.getColorMap().get(colorString); } else { color = java.awt.Color.black; } } return color; } public String createChildGroup(String parentElementGroup) { nextGroupId++; if (parentElementGroup.length() > 0 ) parentElementGroup += "."; return parentElementGroup + nextGroupId; } /** Getter for property bands. * @return Value of property bands. * */ public java.util.Vector getBands() { return bands; } /** Setter for property bands. * @param bands New value of property bands. * */ public void setBands(java.util.Vector bands) { this.bands = bands; incrementReportChanges(); } /** Getter for property bottomMargin. * @return Value of property bottomMargin. * */ public int getBottomMargin() { return bottomMargin; } /** Setter for property bottomMargin. * @param bottomMargin New value of property bottomMargin. * */ public void setBottomMargin(int bottomMargin) { if (this.bottomMargin == bottomMargin) return; this.bottomMargin = bottomMargin; incrementReportChanges(); } /** Getter for property columnCount. * @return Value of property columnCount. * */ public int getColumnCount() { return columnCount; } /** Setter for property columnCount. * @param columnCount New value of property columnCount. * */ public void setColumnCount(int columnCount) { if (this.columnCount == columnCount) return; this.columnCount = columnCount; incrementReportChanges(); } /** Getter for property columnSpacing. * @return Value of property columnSpacing. * */ public int getColumnSpacing() { return columnSpacing; } /** Setter for property columnSpacing. * @param columnSpacing New value of property columnSpacing. * */ public void setColumnSpacing(int columnSpacing) { if (this.columnSpacing == columnSpacing) return; this.columnSpacing = columnSpacing; incrementReportChanges(); } /** Getter for property columnWidth. * @return Value of property columnWidth. * */ public int getColumnWidth() { return columnWidth; } /** Setter for property columnWidth. * @param columnWidth New value of property columnWidth. * */ public void setColumnWidth(int columnWidth) { if (this.columnWidth == columnWidth) return; this.columnWidth = columnWidth; incrementReportChanges(); } /** Getter for property elements. * @return Value of property elements. * */ public java.util.Vector getElements() { return elements; } /** Setter for property elements. * @param elements New value of property elements. * */ public void setElements(java.util.Vector elements) { this.elements = elements; incrementReportChanges(); } /** Getter for property encoding. * @return Value of property encoding. * */ public java.lang.String getEncoding() { return encoding; } /** Setter for property encoding. * @param encoding New value of property encoding. * */ public void setEncoding(java.lang.String encoding) { if ((this.encoding == null) ? encoding == null : this.encoding.equals(encoding)) return; this.encoding = encoding; incrementReportChanges(); } /** Getter for property filename. * @return Value of property filename. * */ public java.lang.String getFilename() { return filename; } /** Setter for property filename. * @param filename New value of property filename. * */ public void setFilename(java.lang.String filename) { this.filename = filename; } /** Getter for property fonts. * @return Value of property fonts. * */ public java.util.Vector getFonts() { return fonts; } /** Setter for property fonts. * @param fonts New value of property fonts. * */ public void setFonts(java.util.Vector fonts) { this.fonts = fonts; incrementReportChanges(); } /** Getter for property height. * @return Value of property height. * */ public int getHeight() { return height; } /** Setter for property height. * @param height New value of property height. * */ public void setHeight(int height) { if (this.height == height) return; this.height = height; incrementReportChanges(); } /** Getter for property isSummaryNewPage. * @return Value of property isSummaryNewPage. * */ public boolean isIsSummaryNewPage() { return isSummaryNewPage; } /** Setter for property isSummaryNewPage. * @param isSummaryNewPage New value of property isSummaryNewPage. * */ public void setIsSummaryNewPage(boolean isSummaryNewPage) { if (this.isSummaryNewPage == isSummaryNewPage) return; this.isSummaryNewPage = isSummaryNewPage; incrementReportChanges(); } /** Getter for property isTitleNewPage. * @return Value of property isTitleNewPage. * */ public boolean isIsTitleNewPage() { return isTitleNewPage; } /** Setter for property isTitleNewPage. * @param isTitleNewPage New value of property isTitleNewPage. * */ public void setIsTitleNewPage(boolean isTitleNewPage) { if (this.isTitleNewPage == isTitleNewPage) return; this.isTitleNewPage = isTitleNewPage; incrementReportChanges(); } /** Getter for property leftMargin. * @return Value of property leftMargin. * */ public int getLeftMargin() { return leftMargin; } /** Setter for property leftMargin. * @param leftMargin New value of property leftMargin. * */ public void setLeftMargin(int leftMargin) { if (this.leftMargin == leftMargin) return; this.leftMargin = leftMargin; incrementReportChanges(); } /** Getter for property loadTime. * @return Value of property loadTime. * */ public long getLoadTime() { return loadTime; } /** Setter for property loadTime. * @param loadTime New value of property loadTime. * */ public void setLoadTime(long loadTime) { this.loadTime = loadTime; } /** Getter for property orientation. * @return Value of property orientation. * */ public java.lang.String getOrientation() { return orientation; } /** Setter for property orientation. * @param orientation New value of property orientation. * */ public void setOrientation(java.lang.String orientation) { if ((this.orientation == null) ? orientation == null : this.orientation.equals(orientation)) return; this.orientation = orientation; incrementReportChanges(); } /** Getter for property printOrder. * @return Value of property printOrder. * */ public java.lang.String getPrintOrder() { return printOrder; } /** Setter for property printOrder. * @param printOrder New value of property printOrder. * */ public void setPrintOrder(java.lang.String printOrder) { if ((this.printOrder == null) ? printOrder == null : this.printOrder.equals(printOrder)) return; this.printOrder = printOrder; incrementReportChanges(); } /** Getter for property rightMargin. * @return Value of property rightMargin. * */ public int getRightMargin() { return rightMargin; } /** Setter for property rightMargin. * @param rightMargin New value of property rightMargin. * */ public void setRightMargin(int rightMargin) { if (this.rightMargin == rightMargin) return; this.rightMargin = rightMargin; incrementReportChanges(); } /** Getter for property topMargin. * @return Value of property topMargin. * */ public int getTopMargin() { return topMargin; } /** Setter for property topMargin. * @param topMargin New value of property topMargin. * */ public void setTopMargin(int topMargin) { if (this.topMargin == topMargin) return; this.topMargin = topMargin; incrementReportChanges(); } public void addImport(String _import) { if (!imports.contains(_import)) { this.imports.add(_import); incrementReportChanges(); } } /** Getter for property whenNoDataType. * @return Value of property whenNoDataType. * */ public java.lang.String getWhenNoDataType() { return whenNoDataType; } /** Setter for property whenNoDataType. * @param whenNoDataType New value of property whenNoDataType. * */ public void setWhenNoDataType(java.lang.String whenNoDataType) { if ((this.whenNoDataType == null) ? whenNoDataType == null : this.whenNoDataType.equals(whenNoDataType)) return; this.whenNoDataType = whenNoDataType; incrementReportChanges(); } /** Getter for property width. * @return Value of property width. * */ public int getWidth() { return width; } /** Setter for property width. * @param width New value of property width. * */ public void setWidth(int width) { if (this.width == width) return; this.width = width; incrementReportChanges(); } /** * This function compute the Y location of the band. * In the designer panel, there is as space of 10 pixels (the space * between the top border of the panel, and the begin of the * virtual page) that are not added to this measure. This is * important because permit to multiply this height for a * zoom factor. * * @param b it.businesslogic.ireport.Band The band to compute. */ public int getBandYLocation(Band b) { int y = topMargin; for (Iterator i = this.bands.iterator(); i.hasNext(); ) { Band band = (Band) i.next(); if (band != b) { y += band.getHeight(); } else { break; } } return y; } /** Getter for property reportFrame. * @return Value of property reportFrame. * */ public it.businesslogic.ireport.gui.JReportFrame getReportFrame() { return reportFrame; } /** Setter for property reportFrame. * @param reportFrame New value of property reportFrame. * */ public void setReportFrame(it.businesslogic.ireport.gui.JReportFrame reportFrame) { this.reportFrame = reportFrame; } /** Getter for property reportFormat. * @return Value of property reportFormat. * */ public java.lang.String getReportFormat() { return reportFormat; } /** Setter for property reportFormat. * @param reportFormat New value of property reportFormat. * */ public void setReportFormat(java.lang.String reportFormat) { this.reportFormat = reportFormat; } /** * This method return the height needed by a graphics to * draw all the document. */ public int getDesignHeight() { int y = topMargin + bottomMargin; for (Iterator i = this.bands.iterator(); i.hasNext(); ) { y += ((Band) i.next()).getHeight(); } return y; } public int getDesignHeightNoBG() { int y=0; y += topMargin; y += bottomMargin; for (Iterator i = this.bands.iterator(); i.hasNext(); ) { Band b = (Band) i.next(); if (!b.getName().equals("background")) y += b.getHeight(); } return y; } /** Add a group to the reprot and perform an adjust on jReportFrame * @param group New group to be inserted. * */ public void addGroup(Group grp) { addGroup(grp,true); } /** Add a group to the reprot and perform an adjust on jReportFrame if * specified * @param group New group to be inserted. * @param adjust If true, perform an adjust on jReportFrame */ public void addGroup(Group grp, boolean adjust) { incrementReportChanges(); if (!getGroups().contains(grp)) { getGroups().addElement(grp); } String bandsstr = ""; /* * start looking for the detail band. * and place header and footer of new group around it if (Adjust) */ for (int i = 0; i < bands.size(); i++) { Band b = (Band)bands.elementAt(i); if (b.getName().equals("detail")) { if (adjust) { int bandYLocation = getBandYLocation(b); for (Iterator i2 = elements.iterator(); i2.hasNext(); ) { ReportElement elem = (ReportElement) i2.next(); int delta_y = grp.getGroupHeader().getHeight(); if (elem.band == grp.getGroupHeader() || elem.band == grp.getGroupFooter()) { // Do nothing } else if (elem.position.y >= bandYLocation + 10 + b.getHeight()) { delta_y += grp.getGroupFooter().getHeight(); elem.trasform(new java.awt.Point(0, delta_y), TransformationType.TRANSFORMATION_MOVE); } else if (elem.position.y >= bandYLocation + 10) { elem.trasform(new java.awt.Point(0, delta_y), TransformationType.TRANSFORMATION_MOVE); } } } // All elements with top > detail.top must be shifted of groupHeader height bands.insertElementAt(grp.getGroupHeader(),i); // All elements with top > detail.top + detail.bottom must be shifted of groupFooter height bands.insertElementAt(grp.getGroupFooter(),i+2); break; } } addVariable(new it.businesslogic.ireport.JRVariable(grp.getName()+"_COUNT","java.lang.Integer", true)); } /** * grpOne will be palce within grpTwo * This means the header band of grpOne will come after the header band of grpTwo * And the footer band of grpOne will come before the footer band of grpTwo * @author: Robert Lamping * @param direction 1 = down, -1 -up * @param grp The group that must be moved */ public synchronized void moveGroup(Group grp, int direction ) { Group grpOne = null; Group grpTwo = null; if ( getGroups().size() <=1 ) { return; // nothing to do } incrementReportChanges(); if (direction == 1) { // down // there must be at least one element below: if ( getGroups().lastElement() == grp ) { return ; // nothing to do } grpOne = grp; grpTwo = (Group) getGroups().get( getGroups().indexOf(grp) + 1); } else { // up // there must be at least one element above if ( getGroups().firstElement() == grp ) { return ; // nothing to do } grpTwo = grp; grpOne = (Group) getGroups().get( getGroups().indexOf(grp) - 1); } Band bandGrpOneHeader = getBandByName( grpOne.getGroupHeader().getName()); Band bandGrpTwoHeader = getBandByName( grpTwo.getGroupHeader().getName()); Band bandGrpOneFooter = getBandByName( grpOne.getGroupFooter().getName()); Band bandGrpTwoFooter = getBandByName( grpTwo.getGroupFooter().getName()); int delta1 = bandGrpOneHeader.getHeight(); int delta2 = bandGrpTwoHeader.getHeight(); int delta3 = bandGrpOneFooter.getHeight(); int delta4 = bandGrpTwoFooter.getHeight(); // Move the elements for (Iterator i = elements.iterator(); i.hasNext(); ) { ReportElement re = (ReportElement) i.next(); if (re.band == bandGrpOneHeader ) { re.trasform(new java.awt.Point(0, delta2 ), TransformationType.TRANSFORMATION_MOVE); } else if (re.band == bandGrpTwoHeader ) { re.trasform(new java.awt.Point(0, -delta1 ), TransformationType.TRANSFORMATION_MOVE); } else if ( re.band == bandGrpTwoFooter ) { re.trasform(new java.awt.Point(0, delta3 ), TransformationType.TRANSFORMATION_MOVE); } else if ( re.band == bandGrpOneFooter ) { re.trasform(new java.awt.Point(0, -delta4 ), TransformationType.TRANSFORMATION_MOVE); } } // Now move the groups withing the bands array. // Move Band Group Headers int pos1 = bands.indexOf( bandGrpOneHeader); Band bandBuffer = (Band) bands.get(pos1); bands.remove(pos1); bands.insertElementAt(bandBuffer, pos1+1); // Move Band Group Footers int pos3 = bands.indexOf( bandGrpTwoFooter); bandBuffer = (Band) bands.get(pos3); bands.remove(pos3); bands.insertElementAt(bandBuffer, pos3+1); // Now move the groups within the group array int groupPos = getGroups().indexOf( grpOne ); // groupTwo is always after grpOne Group groupBuffer = (Group) getGroups().get( groupPos); getGroups().remove(groupPos); getGroups().insertElementAt( groupBuffer, groupPos + 1); } public void delGroup(Group grp) { if (!getGroups().contains(grp)) return; incrementReportChanges(); String bandsstr = ""; for (int i=0; i<getVariables().size(); ++i) { JRVariable var = (JRVariable)getVariables().elementAt(i); if (var.isBuiltin() && var.getName().equalsIgnoreCase(grp.getName()+"_COUNT")) { removeVariable(var); break; } } for (int i=0; i<elements.size(); ++i) { // Remove all elements of this group... ReportElement elem = (ReportElement)elements.elementAt(i); if (elem.getBand() == grp.getGroupHeader() || elem.getBand() == grp.getGroupFooter()) { elements.removeElementAt(i); i--; continue; } // Adjust elements posisitions... // Il element int delta_y = grp.getGroupHeader().getHeight(); if (elem.position.y >= getBandYLocation(grp.getGroupFooter())+10+grp.getGroupFooter().getHeight()) { delta_y += grp.getGroupFooter().getHeight(); elem.trasform(new java.awt.Point(0, -delta_y), TransformationType.TRANSFORMATION_MOVE); } else if (elem.position.y >= getBandYLocation(grp.getGroupHeader())+10+grp.getGroupHeader().getHeight()) { elem.trasform(new java.awt.Point(0, -delta_y), TransformationType.TRANSFORMATION_MOVE); } } bands.removeElement(grp.getGroupHeader()); bands.removeElement(grp.getGroupFooter()); getGroups().removeElement(grp); } public Group getGroupByName(String name) { for (int i = 0; i < getGroups().size(); i++) { Group grp = (Group)getGroups().elementAt(i); if (grp.getName().equals(name)) { return grp; } } return null; } public Band getBandByName(String name) { for (int i=0; i< bands.size(); i++) { Band band = (Band)bands.elementAt(i); if (band.getName().equals(name)) { return band; } } return null; } public void saveXMLFile() { saveXMLFile( this.getFilename()); } public void saveXMLFile( String aFilename ) { if(isReadOnly()){ javax.swing.JOptionPane.showMessageDialog(getReportFrame().getMainFrame(), it.businesslogic.ireport.util.I18n.getString("fileReadOnly", "File is read only and cannot be saved."), it.businesslogic.ireport.util.I18n.getString("save","Save"),javax.swing.JOptionPane.INFORMATION_MESSAGE); return; } ReportWriter wr = new ReportWriter( this ); wr.saveXMLFile( aFilename ); } /** * Getter for property usingMultiLineExpressions. * @return Value of property usingMultiLineExpressions. */ public boolean isUsingMultiLineExpressions() { return false; //usingMultiLineExpressions; } /** * Setter for property usingMultiLineExpressions. * @param usingMultiLineExpressions New value of property usingMultiLineExpressions. */ public void setUsingMultiLineExpressions(boolean usingMultiLineExpressions) { this.usingMultiLineExpressions = false; //usingMultiLineExpressions; } /** Getter for property scripletCode. * @return Value of property scripletCode. * */ public it.businesslogic.ireport.ScriptletCode getScripletCode() { return scripletCode; } /** Setter for property scripletCode. * @param scripletCode New value of property scripletCode. * */ public void setScripletCode(it.businesslogic.ireport.ScriptletCode scripletCode) { this.scripletCode = scripletCode; } /** Getter for property scriptletHandling. * @return Value of property scriptletHandling. * */ public int getScriptletHandling() { return scriptletHandling; } /** Setter for property scriptletHandling. * @param scriptletHandling New value of property scriptletHandling. * */ public void setScriptletHandling(int scriptletHandling) { if (this.scriptletHandling == scriptletHandling) return; this.scriptletHandling = scriptletHandling; incrementReportChanges(); } public String getScriptletFileName() { return this.getScriptletFileName( this.getFilename() ); } public String getScriptletFileName(String file) { if (file == null) return "Scriptlet.java"; // we assume /xxx/yyY/qqq/myreport.xml as input file name if (file.length() > 3) { file = Misc.changeFileExtension(file, ""); file = file.substring(0, file.length() -1 ); File f = new File( file ); String className = f.getName() + "Scriptlet"; className = Misc.string_replace("_",".", className); className = Misc.string_replace("_"," ",className); if ( Character.isDigit(className.charAt( 0 ) )) { className = "_"+ className; } className += ".java"; return f.getPath().substring(0, f.getPath().length() - f.getName().length()) + className; } return "Scriptlet.java"; } /** * Default font specified in xml file. * @return */ public IReportFont getDefaultFont() { return defaultFont; } public boolean isReadOnly(){ return readOnly; } public void checkReadOnlyFlag(){ checkReadOnlyFlag(getFilename()); } public void checkReadOnlyFlag(String oF){ if (oF == null) return; File f = new File(oF); try { if (!f.exists()) { readOnly = false; } else { readOnly = !f.canWrite(); } } catch (Exception ex) { } readOnly = false; } /** * return the band that encloses the parameter originY * @param originY * @return * * an originY < 0 will return nothing * an originY > designheight will return the Summary band */ public Band getBandByPosition( int originY ){ Band bname = null; for (Iterator i = this.getBands().iterator(); i.hasNext(); ) { Band b = (Band) i.next(); if ( this.getBandYLocation(b) + 10 <= originY) { bname = b; } } if (bname != null && (this.getBandYLocation(bname) + 10 + bname.getHeight() < originY)) return null; return bname; } public Vector getImports() { return imports; } public void setImports(Vector imports) { this.imports = imports; incrementReportChanges(); } public boolean isFloatColumnFooter() { return floatColumnFooter; } public void setFloatColumnFooter(boolean floatColumnFooter) { if (this.floatColumnFooter == floatColumnFooter) return; this.floatColumnFooter = floatColumnFooter; incrementReportChanges(); } public String getLanguage() { return language; } public void setLanguage(String language) { if ((this.language == null) ? language == null : this.language.equals(language)) return; this.language = language; incrementReportChanges(); } public java.util.HashMap getProposedValues() { return proposedValues; } public void setProposedValues(java.util.HashMap proposedValues) { this.proposedValues = proposedValues; } /** * Recalculate the Columnwidth bases on the available space. * Introduces at June, 6 to allow PageTransformation.java to calculate the column width again. * */ public void recalcColumnWidth() { //this.columns = (int)jNumberFieldColumns.getValue(); // calculate space... // this.setColumnCount( report.getColumnCount() ); // this.setColumnSpacing( report.getColumnSpacing()); int avail = getWidth() - getLeftMargin() - getRightMargin() - (getColumnCount()-1) * getColumnSpacing(); int dim = avail; dim = (int)( (double)dim / (double)this.getColumnCount()); while ( (dim*this.getColumnCount()) > avail) { dim--; } this.setColumnWidth(dim); } public IReportFont getReportFontByName(String name) { if (name == null || name.length() == 0) return null; for (int i=0; i<getFonts().size(); ++i) { IReportFont font = (IReportFont)getFonts().elementAt(i); if (font.getReportFont().equals(name)) { return font; } } return null; } public Vector getStyles() { return styles; } public void setStyles(Vector styles) { this.styles = styles; incrementReportChanges(); } public void elementGroupResort(Band band) { it.businesslogic.ireport.util.TreeNode root = extractBandElementsTree(band, true); addElementsTree( root ); incrementReportChanges(); } public it.businesslogic.ireport.util.TreeNode extractBandElementsTree(Band band, boolean remove) { java.util.List tmpElements = new java.util.ArrayList(); it.businesslogic.ireport.util.TreeNode root = new it.businesslogic.ireport.util.TreeNode(""); for (int i=0; i< getElements().size(); ++i) { ReportElement element = (ReportElement)getElements().elementAt(i); if (element.getBand() == band) { tmpElements.add(element); if (remove) { getElements().removeElementAt(i); i--; } } } if (tmpElements.size() > 0) { // we have to reorder all.... for (int i=0; i< tmpElements.size(); ++i) { ReportElement element = (ReportElement)tmpElements.get(i); String elementGroup = element.getElementGroup(); try { if (element.getParentElement() != null) { it.businesslogic.ireport.util.TreeNode tmpRoot = findElementInTreeNode(root,element.getParentElement()); if (tmpRoot != null) addElementToGroup(tmpRoot, elementGroup, element ); } else { addElementToGroup(root, elementGroup, element ); } } catch (Exception ex) { ex.printStackTrace(); } } } return root; } public void moveElementDown(ReportElement element) { incrementReportChanges(); it.businesslogic.ireport.util.TreeNode root = extractBandElementsTree(element.getBand(), true); root.moveDown( element ); addElementsTree( root ); } public void moveElementUp(ReportElement element) { incrementReportChanges(); it.businesslogic.ireport.util.TreeNode root = extractBandElementsTree(element.getBand(), true); root.moveUp( element ); addElementsTree( root ); } private void addElementsTree(it.businesslogic.ireport.util.TreeNode root) { for (int i=0; i< root.getChilds().size(); ++i) { it.businesslogic.ireport.util.TreeNode node =(it.businesslogic.ireport.util.TreeNode)(root.getChilds().get(i)); Object obj = node.getUserObject(); if (obj instanceof ReportElement) { getElements().add( obj ); if (obj instanceof FrameReportElement) { addElementsTree( node ); } } else { addElementsTree( node ); } } } /* public void addElementToGroup(NamedList parentNode, String subGroup, ReportElement element) { // 1. We have to find the group node... if (subGroup.equals("")) { parentNode.add( element); return; } String levelGroupName = ""; if (subGroup.indexOf(".")>=0) { levelGroupName = subGroup.substring(0, subGroup.indexOf(".")); subGroup = subGroup.substring(subGroup.indexOf(".")+1); } else { levelGroupName = subGroup; subGroup = ""; } // 2. Look for the node named levelGroupName for (int i =0; i<parentNode.size(); ++i) { Object node = parentNode.get(i); if (node instanceof NamedList) { NamedList nl = (NamedList)node; if (nl.getName().equals( levelGroupName )) { addElementToGroup(nl, subGroup, element); return; } } } // Node doesn't exists.... NamedList nl = new NamedList(levelGroupName); addElementToGroup(nl, subGroup, element); parentNode.add( nl ); } */ public void addElementToGroup(it.businesslogic.ireport.util.TreeNode parentNode, String subGroup, ReportElement element) { incrementReportChanges(); // 1. We have to find the group node... if (subGroup.equals("")) { parentNode.addChild(new it.businesslogic.ireport.util.TreeNode( element )); return; } String levelGroupName = ""; if (subGroup.indexOf(".")>=0) { levelGroupName = subGroup.substring(0, subGroup.indexOf(".")); subGroup = subGroup.substring(subGroup.indexOf(".")+1); } else { levelGroupName = subGroup; subGroup = ""; } // 2. Look for the node named levelGroupName for (int i =0; i<parentNode.getChilds().size(); ++i) { it.businesslogic.ireport.util.TreeNode node = (it.businesslogic.ireport.util.TreeNode)(parentNode.getChilds().get(i)); if (node.getName().equals( levelGroupName ) ) { addElementToGroup(node, subGroup, element); return; } } // Node doesn't exists.... it.businesslogic.ireport.util.TreeNode nl = new it.businesslogic.ireport.util.TreeNode(levelGroupName); addElementToGroup(nl, subGroup, element); parentNode.addChild( nl ); } public it.businesslogic.ireport.util.TreeNode findElementInTreeNode(it.businesslogic.ireport.util.TreeNode parentNode, ReportElement re) { for (int k=0; k<parentNode.getChilds().size(); ++k) { it.businesslogic.ireport.util.TreeNode child = (it.businesslogic.ireport.util.TreeNode)(parentNode.getChilds().get(k)); if (child.getUserObject() == re) { return child; } if (re.getElementGroup().equals("") || re.getParentElement() != null) { if (child.getUserObject() instanceof FrameReportElement || child.getUserObject() instanceof String) { it.businesslogic.ireport.util.TreeNode newchild = findElementInTreeNode(child,re); if (newchild != null) return newchild; } } } return null; } public Vector getSubDatasets() { return subDatasets; } public void setSubDatasets(Vector subDatasets) { this.subDatasets = subDatasets; incrementReportChanges(); } public boolean isIgnorePagination() { return ignorePagination; } public void setIgnorePagination(boolean ignorePagination) { if (this.ignorePagination == ignorePagination) return; this.ignorePagination = ignorePagination; incrementReportChanges(); } /** * Utility field used by event firing mechanism. */ private javax.swing.event.EventListenerList listenerList = null; public void addSubDataset(SubDataset subDataset) { this.getSubDatasets().add( subDataset); incrementReportChanges(); this.fireReportSubDatasetChangedListenerReportSubDatasetChanged( new ReportSubDatasetChangedEvent(this, subDataset, ReportSubDatasetChangedEvent.ADDED, ReportSubDatasetChangedEvent.OBJECT_SUBDATASET)); subDataset.addSubDatasetObjectChangedListener( this ); } public void removeSubDataset(SubDataset subDataset) { this.getSubDatasets().remove(subDataset); this.fireReportSubDatasetChangedListenerReportSubDatasetChanged( new ReportSubDatasetChangedEvent(this,subDataset, ReportSubDatasetChangedEvent.REMOVED, ReportSubDatasetChangedEvent.OBJECT_SUBDATASET)); subDataset.removeSubDatasetObjectChangedListener( this ); incrementReportChanges(); } public void removeStyle(Style s) { this.getStyles().remove(s); removeStyleFromElements( s, getElements()); this.fireStyleChangedListenerStyleChanged( new StyleChangedEvent( this,StyleChangedEvent.DELETED , s,s)); incrementReportChanges(); } public void removeTemplate(Template t) { this.getTemplates().remove(t); this.fireStyleChangedListenerTemplateChanged( new TemplateChangedEvent( this, TemplateChangedEvent.DELETED , t,t)); incrementReportChanges(); } public void addTemplate(Template t) { this.getTemplates().add(t); this.fireStyleChangedListenerTemplateChanged( new TemplateChangedEvent( this, TemplateChangedEvent.ADDED , t,t)); incrementReportChanges(); } public void addStyle(Style s) { this.getStyles().add(s); incrementReportChanges(); this.fireStyleChangedListenerStyleChanged( new StyleChangedEvent( this,StyleChangedEvent.ADDED , s,s)); } private void removeStyleFromElements(Style s, Vector thisElements) { for (int i=0; i<thisElements.size(); ++i) { ReportElement re = (ReportElement)thisElements.elementAt(i); if (re.getStyle() == s) re.setStyle(null); if (re instanceof CrosstabReportElement) { removeStyleFromElements(s, ((CrosstabReportElement)re).getElements()); } } incrementReportChanges(); } /** * Registers ReportSubDatasetChangedListener to receive events. * @param listener The listener to register. */ public synchronized void addReportSubDatasetChangedListener(it.businesslogic.ireport.gui.event.ReportSubDatasetChangedListener listener) { if (listenerList == null ) { listenerList = new javax.swing.event.EventListenerList(); } listenerList.add (it.businesslogic.ireport.gui.event.ReportSubDatasetChangedListener.class, listener); } /** * Removes ReportSubDatasetChangedListener from the list of listeners. * @param listener The listener to remove. */ public synchronized void removeReportSubDatasetChangedListener(it.businesslogic.ireport.gui.event.ReportSubDatasetChangedListener listener) { listenerList.remove (it.businesslogic.ireport.gui.event.ReportSubDatasetChangedListener.class, listener); } /** * Notifies all registered listeners about the event. * * @param event The event to be fired */ public void fireReportSubDatasetChangedListenerReportSubDatasetChanged(it.businesslogic.ireport.gui.event.ReportSubDatasetChangedEvent event) { if (listenerList == null) return; Object[] listeners = listenerList.getListenerList (); for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i]==it.businesslogic.ireport.gui.event.ReportSubDatasetChangedListener.class) { ((it.businesslogic.ireport.gui.event.ReportSubDatasetChangedListener)listeners[i+1]).reportSubDatasetChanged (event); } } } public void subDatasetObjectChanged(it.businesslogic.ireport.gui.event.SubDatasetObjectChangedEvent evt) { java.util.Vector changedElements = new java.util.Vector(); if (evt.getType() == evt.FIELD && evt.getAction() == evt.MODIFIED && evt.getSource() instanceof SubDataset) { String oldString = "$F{" + evt.getOldValue() + "}"; String newString = "$F{" + evt.getNewValue() + "}"; if (evt.getOldValue() != null && evt.getNewValue() != null && !oldString.equals(newString)) { System.out.println("replaceInReportExpressions for DS= " + evt.getSource()); ReportRefactor.replaceInReportExpressions(oldString, newString, evt.getSource(), this); } // Change referred types in textfields... if (evt.getSource() == this && !((JRField)evt.getOldValue()).getClassType().equals( ((JRField)evt.getNewValue()).getClassType()) ) { changedElements.addAll( ReportRefactor.replaceTextfieldClass("$F{" + evt.getNewValue() + "}", ((JRField)evt.getNewValue()).getClassType(), getElements()) ); } } if (evt.getType() == evt.PARAMETER && evt.getAction() == evt.MODIFIED && evt.getSource() instanceof SubDataset) { String oldString = "$P{" + evt.getOldValue() + "}"; String newString = "$P{" + evt.getNewValue() + "}"; if (evt.getOldValue() != null && evt.getNewValue() != null && !oldString.equals(newString)) { ReportRefactor.replaceInReportExpressions(oldString, newString, evt.getSource(), this); } if (evt.getSource() == this && !((JRParameter)evt.getOldValue()).getClassType().equals( ((JRParameter)evt.getNewValue()).getClassType()) ) { changedElements.addAll( ReportRefactor.replaceTextfieldClass("$P{" + evt.getNewValue() + "}", ((JRParameter)evt.getNewValue()).getClassType(), getElements()) ); } } if (evt.getType() == evt.VARIABLE && evt.getAction() == evt.MODIFIED && evt.getSource() instanceof SubDataset) { String oldString = "$V{" + evt.getOldValue() + "}"; String newString = "$V{" + evt.getNewValue() + "}"; if (evt.getOldValue() != null && evt.getNewValue() != null && !oldString.equals(newString)) { ReportRefactor.replaceInReportExpressions(oldString, newString, evt.getSource(), this); } if (evt.getSource() == this && !((JRVariable)evt.getOldValue()).getClassType().equals( ((JRVariable)evt.getNewValue()).getClassType()) ) { changedElements.addAll( ReportRefactor.replaceTextfieldClass("$V{" + evt.getNewValue() + "}", ((JRVariable)evt.getNewValue()).getClassType(), getElements()) ); } } if (changedElements.size() > 0) { System.out.flush(); getReportFrame().fireReportListenerReportElementsChanged( new ReportElementChangedEvent(getReportFrame(),changedElements , ReportElementChangedEvent.CHANGED)); // this window still requires a manual update... MainFrame.getMainInstance().getElementPropertiesDialog().updateSelection(); } //System.out.println(evt.getSource() + " " + this); //fireSubDatasetObjectChangedListenerSubDatasetObjectChanged( evt ); if (getListenerList() != null && evt.getSource() != this) { Object[] listeners = getListenerList().getListenerList (); for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i+1] == this) continue; //if (listeners[i+1] == evt.getSource()) continue; if (listeners[i]==it.businesslogic.ireport.gui.event.SubDatasetObjectChangedListener.class) { ((it.businesslogic.ireport.gui.event.SubDatasetObjectChangedListener)listeners[i+1]).subDatasetObjectChanged (evt); } } } incrementReportChanges(); } /** * Registers StyleChangedListener to receive events. * @param listener The listener to register. */ public synchronized void addStyleChangedListener(it.businesslogic.ireport.gui.event.StyleChangedListener listener) { if (listenerList == null ) { listenerList = new javax.swing.event.EventListenerList(); } listenerList.add (it.businesslogic.ireport.gui.event.StyleChangedListener.class, listener); } /** * Removes StyleChangedListener from the list of listeners. * @param listener The listener to remove. */ public synchronized void removeStyleChangedListener(it.businesslogic.ireport.gui.event.StyleChangedListener listener) { listenerList.remove (it.businesslogic.ireport.gui.event.StyleChangedListener.class, listener); } /** * Notifies all registered listeners about the event. * * @param event The event to be fired */ public void fireStyleChangedListenerStyleChanged(it.businesslogic.ireport.gui.event.StyleChangedEvent event) { // We have to apply again the style... Enumeration enum_elements = getElements().elements(); while (enum_elements.hasMoreElements()) { ReportElement re = (ReportElement)enum_elements.nextElement(); if (re.getStyle() == event.getNewValue()) { re.setStyle( event.getNewValue()); } } if (listenerList == null) return; Object[] listeners = listenerList.getListenerList (); for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i]==it.businesslogic.ireport.gui.event.StyleChangedListener.class) { ((it.businesslogic.ireport.gui.event.StyleChangedListener)listeners[i+1]).styleChanged (event); } } } /** * Notifies all registered listeners about the event. * * @param event The event to be fired */ public void fireStyleChangedListenerTemplateChanged(it.businesslogic.ireport.gui.event.TemplateChangedEvent event) { if (listenerList == null) return; Object[] listeners = listenerList.getListenerList (); for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i]==it.businesslogic.ireport.gui.event.StyleChangedListener.class) { ((it.businesslogic.ireport.gui.event.StyleChangedListener)listeners[i+1]).templateChanged (event); } } } public Style getDefaultStyle() { for (int i=0; i<getStyles().size(); ++i) { Style s = (Style)getStyles().elementAt(i); if (s.getAttributeBoolean( s.ATTRIBUTE_isDefault, false )) { return s; } } return null; } public int getReportChanges() { return reportChanges; } /* * Keep track of report changes. A ReportDocumentStatusChanged * event is thrown in the following cases: * * currentChanges == 0 && newChanges > 0 => ReportDocumentStatusChanged to DIRTY * currentChanges > 0 && newChanges == 0 => ReportDocumentStatusChanged to NO_DIRTY * */ public void setReportChanges(int newChanges) { boolean isChanged = false; if (reportChanges == 0 && newChanges > 0) isChanged = true; else if (reportChanges > 0 && newChanges == 0) isChanged = true; this.reportChanges = newChanges; //if (fireEvent) //{ fireReportDocumentStatusChangedListenerReportDocumentStatusChanged( new ReportDocumentStatusChangedEvent(this, isChanged)); //} } public void incrementReportChanges() { setReportChanges( getReportChanges() + 1); } public void decrementReportChanges() { if (getReportChanges() > 0) { setReportChanges( getReportChanges() - 1); } } /** * Alias for getReportChanges() > 0 */ public boolean isModified() { return getReportChanges() > 0; } public boolean isLoadingFile() { return loadingFile; } public void setLoadingFile(boolean loading) { this.loadingFile = loading; } /** * Registers ReportDocumentStatusChangedListener to receive events. * @param listener The listener to register. */ public synchronized void addReportDocumentStatusChangedListener(it.businesslogic.ireport.gui.event.ReportDocumentStatusChangedListener listener) { if (listenerList == null ) { listenerList = new javax.swing.event.EventListenerList(); } listenerList.add (it.businesslogic.ireport.gui.event.ReportDocumentStatusChangedListener.class, listener); } /** * Removes ReportDocumentStatusChangedListener from the list of listeners. * @param listener The listener to remove. */ public synchronized void removeReportDocumentStatusChangedListener(it.businesslogic.ireport.gui.event.ReportDocumentStatusChangedListener listener) { listenerList.remove (it.businesslogic.ireport.gui.event.ReportDocumentStatusChangedListener.class, listener); } /** * Notifies all registered listeners about the event. * * @param event The event to be fired */ private void fireReportDocumentStatusChangedListenerReportDocumentStatusChanged(it.businesslogic.ireport.gui.event.ReportDocumentStatusChangedEvent event) { if (listenerList == null) return; Object[] listeners = listenerList.getListenerList (); for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i]==it.businesslogic.ireport.gui.event.ReportDocumentStatusChangedListener.class) { ((it.businesslogic.ireport.gui.event.ReportDocumentStatusChangedListener)listeners[i+1]).reportDocumentStatusChanged (event); } } } /** * Return the available vertical space to add new bands or resize the current ones * */ public int getAvailableVerticalSpace() { int ph = getHeight(); ph -= getTopMargin(); ph -= getBottomMargin(); for (int i=0; i< getBands().size(); ++i) { Band b = (Band)getBands().elementAt(i); if (b.getName().equals("title") && isTitleNewPage) continue; if (b.getName().equals("background")) continue; //if (b.getName().equals("lastPageFooter")) continue; if (b.getName().equals("summary") && isSummaryNewPage) continue; ph -= b.getHeight(); } return ph; } public void setDefaultFont(IReportFont defaultFont) { this.defaultFont = defaultFont; } public static String writeEncodedColor(java.awt.Color c) { String nums = "0123456789ABCDEF"; String s = "#"; s += nums.charAt( c.getRed()/16 ); s += nums.charAt( c.getRed()%16 ); s += nums.charAt( c.getGreen()/16 ); s += nums.charAt( c.getGreen()%16 ); s += nums.charAt( c.getBlue()/16 ); s += nums.charAt( c.getBlue()%16 ); return s; } public static String getCDATAString( String string, int tabCount ) { //if ( ! Utils.needToBeInsideCDATA( string ) ) // return string; String CRLF = System.getProperty("line.separator"); String tab = ""; for ( int i = 0; i < tabCount; i++ ) { tab += "\t"; } return "<![CDATA[" + string + "]]>"; // + CRLF + tab ; } public String getFormatFactoryClass() { return formatFactoryClass; } public void setFormatFactoryClass(String formatFactoryClass) { this.formatFactoryClass = formatFactoryClass; } }

The table below shows all metrics for Report.java.

MetricValueDescription
BLOCKS246.00Number of blocks
BLOCK_COMMENT86.00Number of block comment lines
COMMENTS442.00Comment lines
COMMENT_DENSITY 0.58Comment density
COMPARISONS212.00Number of comparison operators
CYCLOMATIC311.00Cyclomatic complexity
DECL_COMMENTS79.00Comments in declarations
DOC_COMMENT309.00Number of javadoc comment lines
ELOC768.00Effective lines of code
EXEC_COMMENTS37.00Comments in executable code
EXITS173.00Procedure exits
FUNCTIONS132.00Number of function declarations
HALSTEAD_DIFFICULTY132.61Halstead difficulty
HALSTEAD_EFFORT 0.00Halstead effort
INTERFACE_COMPLEXITY272.00Interface complexity
JAVA0001 0.00JAVA0001 Package name does not contain only lower case letters
JAVA0002 0.00JAVA0002 Package name does not begin with a top level domain name or country code
JAVA0003 0.00JAVA0003 Minimize use of on-demand (.*) imports
JAVA0004 0.00JAVA0004 Unnecessary import from java.lang
JAVA0005 1.00JAVA0005 Imports not in specified order
JAVA0006 0.00JAVA0006 Empty finally block
JAVA0007 3.00JAVA0007 Should not declare public field
JAVA0008 1.00JAVA0008 Empty catch block
JAVA0009 0.00JAVA0009 Protected member in final class
JAVA0010 0.00JAVA0010 Non-instantiable class does not contain a non-private static member
JAVA0011 0.00JAVA0011 Abstract class does not contain an abstract method
JAVA0012 0.00JAVA0012 Non-constructor method with same name as declaring class
JAVA0013 0.00JAVA0013 Non-blank final field is not static
JAVA0014 0.00JAVA0014 Class with only static members has non-private constructor
JAVA0015 0.00JAVA0015 Package class contains public nested type
JAVA0016 0.00JAVA0016 Abstract class contains public constructor
JAVA0017 0.00JAVA0017 Class name does not have required form
JAVA0018 0.00JAVA0018 Method name does not have required form
JAVA0019 0.00JAVA0019 Interface name does not have required form
JAVA0020 0.00JAVA0020 Field name does not have required form
JAVA0021 0.00JAVA0021 Interface method name does not have required form
JAVA0022 0.00JAVA0022 Static final field name does not have required form
JAVA0023 0.00JAVA0023 Empty finalize method
JAVA0024 0.00JAVA0024 Empty class
JAVA0025 0.00JAVA0025 Method override is empty
JAVA0026 0.00JAVA0026 Finalize method with parameters
JAVA0029 0.00JAVA0029 Private method not used
JAVA0030 0.00JAVA0030 Private field not used
JAVA0031 0.00JAVA0031 Case statement not properly closed
JAVA0032 0.00JAVA0032 Switch statement missing default
JAVA0033 0.00JAVA0033 default: not last case in switch statement
JAVA003441.00JAVA0034 Missing braces in if statement
JAVA0035 0.00JAVA0035 Missing braces in for statement
JAVA0036 0.00JAVA0036 Missing braces in while statement
JAVA0038 0.00JAVA0038 Non-case label in switch statement
JAVA0039 0.00JAVA0039 Break statement with label
JAVA0040 0.00JAVA0040 Switch statement contains N cases (maximum: M)
JAVA0041 0.00JAVA0041 Nested synchronized block
JAVA0042 0.00JAVA0042 Empty synchronized statement
JAVA0043 0.00JAVA0043 Inner class does not use outer class
JAVA0044 0.00JAVA0044 Serializable class with no instance variables
JAVA0045 0.00JAVA0045 Serializable class with only transient fields
JAVA0046 0.00JAVA0046 Name of class not derived from Exception ends with 'Exception'
JAVA0047 0.00JAVA0047 Serializable class derives from invalid base class
JAVA0048 0.00JAVA0048 Name of class derived from Exception does not end with 'Exception'
JAVA0049 3.00JAVA0049 Nested block at depth N (maximum: M)
JAVA0050 0.00JAVA0050 Class derives from java.lang.Error
JAVA0051 0.00JAVA0051 Class derives from java.lang.RuntimeException
JAVA0052 0.00JAVA0052 Class derives from java.lang.Throwable
JAVA0053 0.00JAVA0053 Unused label
JAVA0054 0.00JAVA0054 Inheritance depth N exceeds maximum M
JAVA0055 0.00JAVA0055 Class should be interface
JAVA0056 0.00JAVA0056 Unnecessary abstract modifier for interface or annotation
JAVA0057 0.00JAVA0057 Unnecessary default constructor
JAVA0058 1.00JAVA0058 Constructor calls super()
JAVA0059 0.00JAVA0059 Method override only calls super()
JAVA0061 0.00JAVA0061 Inaccessible member in anonymous class
JAVA0062 0.00JAVA0062 Public class missing public member or protected constructor
JAVA0063 0.00JAVA0063 Identifier name should not contain '$'
JAVA0064 0.00JAVA0064 N variations of identifier name (maximum: M)
JAVA0065 0.00JAVA0065 Unnecessary final modifier for method in final class
JAVA0066 0.00JAVA0066 Unnecessary modifier for interface nested type
JAVA0067 0.00JAVA0067 Array descriptor on identifier name
JAVA0068 2.00JAVA0068 Modifiers not declared in recommended order
JAVA0071 0.00JAVA0071 Strings compared with ==
JAVA0073 0.00JAVA0073 Integer division in floating-point context
JAVA0074 0.00JAVA0074 Use of Object.notify()
JAVA0075 0.00JAVA0075 Method parameter hides field
JAVA007624.00JAVA0076 Use of magic number
JAVA0077 0.00JAVA0077 Private field not used in declaring class
JAVA0078 0.00JAVA0078 Floating point values compared with ==
JAVA0079 8.00JAVA0079 Use of instance to reference static member
JAVA0080 1.00JAVA0080 Import declaration not used
JAVA0081 0.00JAVA0081 Boolean literal in comparison
JAVA0082 4.00JAVA0082 Unnecessary widening cast
JAVA0083 3.00JAVA0083 Unnecessary instanceof test
JAVA0084 0.00JAVA0084 Should use compound assignment operator
JAVA0085 0.00JAVA0085 Use of sun.* class
JAVA0087 0.00JAVA0087 Use of Thread.sleep()
JAVA0089 0.00JAVA0089 Use of restricted package
JAVA0092 0.00JAVA0092 Use of restricted type
JAVA0093 0.00JAVA0093 Redundant assignment
JAVA0094 1.00JAVA0094 Field hides a superclass field
JAVA0095 0.00JAVA0095 Uninitialized private field
JAVA0096 0.00JAVA0096 Field in nested class hides outer field
JAVA0098 0.00JAVA0098 Minimize use of implicit field initializers
JAVA0100 1.00JAVA0100 Class contains N non-final fields (maximum: M)
JAVA0101 0.00JAVA0101 Unnecessary modifier for field in interface
JAVA0102 0.00JAVA0102 Last statement in finalize() not super.finalize()
JAVA0103 0.00JAVA0103 Explicit call to finalize()
JAVA0104 0.00JAVA0104 finalize() only calls super.finalize()
JAVA0105 0.00JAVA0105 Duplicate import declaration
JAVA0106 0.00JAVA0106 Unnecessary import from current package
JAVA0108 3.00JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
JAVA0109 2.00JAVA0109 Incorrect javadoc: no parameter 'parameter'
JAVA0110 4.00JAVA0110 Incorrect javadoc: no @return tag
JAVA0111 0.00JAVA0111 Incorrect javadoc: @return tag for void method
JAVA0112 0.00JAVA0112 Incorrect javadoc: no exception 'exception' in throws
JAVA0113 0.00JAVA0113 Incorrect javadoc: no @author tag
JAVA0114 1.00JAVA0114 Incorrect javadoc: no @version tag
JAVA0115 1.00JAVA0115 Incorrect javadoc: no @throws or @exception tag for 'exception'
JAVA0116 3.00JAVA0116 Missing javadoc: field 'field'
JAVA011756.00JAVA0117 Missing javadoc: method 'method'
JAVA0118 0.00JAVA0118 Missing javadoc: type 'type'
JAVA0119 2.00JAVA0119 Control variable changed within body of for loop
JAVA0123 0.00JAVA0123 Use all three components of for loop
JAVA0125 0.00JAVA0125 Continue statement with label
JAVA0126 0.00JAVA0126 Method declares unchecked exception in throws
JAVA0128 0.00JAVA0128 Public constructor in non-public class
JAVA0130 0.00JAVA0130 Non-static method does not use instance fields
JAVA0131 0.00JAVA0131 Compatible method does not override base
JAVA0132 0.00JAVA0132 Method overload with compatible signature
JAVA0133 0.00JAVA0133 Non-synchronized method overrides synchronized method
JAVA0135 0.00JAVA0135 Only one of Object.equals and Object.hashCode defined: missing 'method'
JAVA0136 1.00JAVA0136 N methods defined in class (maximum: M)
JAVA0137 0.00JAVA0137 Non-abstract class missing constructor
JAVA0138 0.00JAVA0138 N parameters defined for method (maximum: M)
JAVA0139 0.00JAVA0139 Definition of main other than public static void main(java.lang.String[])
JAVA0141 0.00JAVA0141 Unnecessary modifier for method in interface
JAVA0143 7.00JAVA0143 Synchronized method
JAVA014418.00JAVA0144 Line exceeds maximum M characters
JAVA0145 1.00JAVA0145 Tab character used in source file
JAVA0150 0.00JAVA0150 java.lang.Error (or subclass) thrown
JAVA0153 0.00JAVA0153 Inefficient conversion of integer to string
JAVA0159 0.00JAVA0159 Inefficient conversion of string to integer
JAVA0160 0.00JAVA0160 Method does not throw specified exception
JAVA0161 0.00JAVA0161 Conditional wait() not in loop
JAVA0163 0.00JAVA0163 Empty statement
JAVA0165 0.00JAVA0165 Conflicting return statement in finally block
JAVA0166 3.00JAVA0166 Generic exception caught
JAVA0167 0.00JAVA0167 ThreadDeath not rethrown
JAVA0169 0.00JAVA0169 Unnecessary catch block: exception 'exception'
JAVA0170 0.00JAVA0170 Caught exception not derived from java.lang.Exception
JAVA0171 3.00JAVA0171 Unused local variable
JAVA0173 1.00JAVA0173 Unused method parameter
JAVA0174 0.00JAVA0174 Assigned local variable never used
JAVA0175 0.00JAVA0175 Successive assignment to variable
JAVA0176 0.00JAVA0176 Local variable name does not have required form
JAVA0177 0.00JAVA0177 Variable declaration missing initializer
JAVA0179 0.00JAVA0179 Local variable hides visible field
JAVA0233 0.00JAVA0233 Definition of serialVersionUID other than 'private static final long serialVersionUID'
JAVA0234 0.00JAVA0234 Class is Serializable but does not define serialVersionUID
JAVA0235 0.00JAVA0235 Class defines serialVersionUID but does not implement Serializable
JAVA0236 0.00JAVA0236 Attempt to clone an object which does not implement Cloneable
JAVA0237 0.00JAVA0237 Class implements Cloneable but does not have public clone method
JAVA0238 0.00JAVA0238 Clone method does not call super.clone()
JAVA0239 0.00JAVA0239 Class declares 'readObject' or 'writeObject' but does not implement Serializable
JAVA0240 0.00JAVA0240 Serializable class which declares readObject or writeObject but not both
JAVA0241 0.00JAVA0241 'readObject' or 'writeObject' should be declared private in Serializable class
JAVA0242 0.00JAVA0242 Transient field in non-Serializable class
JAVA0243 0.00JAVA0243 'readResolve' or 'writeReplace' should be declared private or protected
JAVA0244 0.00JAVA0244 Field or method name in subclass differs only by case from inherited field or method
JAVA0245 0.00JAVA0245 JUnit TestCase with non-trivial constructor
JAVA0246 0.00JAVA0246 JUnit assertXXX statement missing message parameter
JAVA0247 0.00JAVA0247 JUnit 'setUp()' and 'tearDown()' should call super method
JAVA0248 0.00JAVA0248 JUnit method 'setUp' or 'tearDown' with incorrect signature
JAVA0249 0.00JAVA0249 JUnit TestCase 'suite()' should be declared static
JAVA0250 0.00JAVA0250 JUnit TestCase declares testXXX method with incorrect signature
JAVA0251 0.00JAVA0251 Use '%n' for line breaks in printf/format for platform independence
JAVA0252 0.00JAVA0252 'enum' is a Java 1.5 reserved word
JAVA0253 0.00JAVA0253 Not all enum constants consumed in switch statement
JAVA0254 6.00JAVA0254 Use enhanced for loop construct instead of Iterator
JAVA0255 0.00JAVA0255 Result of method invocation not used
JAVA0256 7.00JAVA0256 Assignment of external collection/array to field
JAVA0257 0.00JAVA0257 Use of 'Constant Interface' anti-pattern
JAVA0258 0.00JAVA0258 Implement Iterable for foreach compatibility
JAVA0259 7.00JAVA0259 Return of collection/array field
JAVA0260 0.00JAVA0260 Use 'enum' instead of Enumerated Type pattern
JAVA0261 0.00JAVA0261 Use specialized Enum collection types
JAVA0262 0.00JAVA0262 Use of char in integer context
JAVA0263 0.00JAVA0263 Long literal ends with 'l' instead of 'L'
JAVA0264 0.00JAVA0264 Integer math in long context - check for overflow
JAVA0265 2.00JAVA0265 Use of Throwable.printStackTrace()
JAVA0266 2.00JAVA0266 Use of System.out
JAVA0267 0.00JAVA0267 Use of System.err
JAVA0269 0.00JAVA0269 Contents of StringBuffer never used
JAVA0270 0.00JAVA0270 Use Java 5.0 enhanced for loop construct to iterate over all elements in an array
JAVA0271 0.00JAVA0271 Minimize use of on-demand (.*) static imports
JAVA0272 0.00JAVA0272 Thread.run() called
JAVA0273 0.00JAVA0273 Non-final derivative of Thread calls start() in constructor
JAVA0274 0.00JAVA0274 Serializable class has a synchronized readObject()
JAVA0275 0.00JAVA0275 Serializable class has a synchronized writeObject() and no other synchronized methods
JAVA0276 0.00JAVA0276 Unnecessary use of String constructor
JAVA0277 0.00JAVA0277 Iterator.next() implementation does not throw NoSuchElementException
JAVA0278 0.00JAVA0278 Unnecessary use of Boolean constructor
JAVA0279 0.00JAVA0279 Serialization method readObject or readObjectNoData calls an overridable method
JAVA0280 0.00JAVA0280 IllegalMonitorStateException caught
JAVA0281 0.00JAVA0281 Iterator.next() not called in loop
JAVA0282 0.00JAVA0282 Call to Iterator.next() in loop which does not test Iterator.hasNext()
JAVA0283 0.00JAVA0283 Control variable not updated in loop body
JAVA0284 0.00JAVA0284 Explicit garbage collection
JAVA0285 0.00JAVA0285 Dereference of potentially null variable
JAVA0286 0.00JAVA0286 Dereference of null variable
JAVA0287 0.00JAVA0287 Unnecessary null check
JAVA0288 0.00JAVA0288 Inconsistent null check
LINES1808.00Number of lines in the source file
LINE_COMMENT47.00Number of line comments
LOC1071.00Lines of code
LOGICAL_LINES565.00Number of statements
LOOPS31.00Number of loops
NEST_DEPTH 6.00Maximum nesting depth
OPERANDS2791.00Number of operands
OPERATORS5566.00Number of operators
PARAMS91.00Number of formal parameter declarations
PROGRAM_LENGTH8357.00Halstead program length
PROGRAM_VOCAB749.00Halstead program vocabulary
PROGRAM_VOLUME 0.00Halstead program volume
RETURNS181.00Number of return points from functions
SIZE59096.00Size of the file in bytes
UNIQUE_OPERANDS684.00Number of unique operands
UNIQUE_OPERATORS65.00Number of unique operators
WHITESPACE295.00Number of whitespace lines