JROpenDocumentExporter.java

Index Score
net.sf.jasperreports.engine.export.oasis
JasperReports

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
RETURNSNumber of return points from functions
EXITSProcedure exits
INTERFACE_COMPLEXITYInterface complexity
JAVA0108JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
LOCLines of code
LINESNumber of lines in the source file
OPERANDSNumber of operands
JAVA0115JAVA0115 Incorrect javadoc: no @throws or @exception tag for 'exception'
LOGICAL_LINESNumber of statements
PROGRAM_LENGTHHalstead program length
EXEC_COMMENTSComments in executable code
OPERATORSNumber of operators
ELOCEffective lines of code
UNIQUE_OPERANDSNumber of unique operands
SIZESize of the file in bytes
PROGRAM_VOCABHalstead program vocabulary
CYCLOMATICCyclomatic complexity
COMPARISONSNumber of comparison operators
BLOCKSNumber of blocks
JAVA0145JAVA0145 Tab character used in source file
JAVA0144JAVA0144 Line exceeds maximum M characters
WHITESPACENumber of whitespace lines
PARAMSNumber of formal parameter declarations
JAVA0117JAVA0117 Missing javadoc: method 'method'
COMMENTSComment lines
DECL_COMMENTSComments in declarations
LINE_COMMENTNumber of line comments
LOOPSNumber of loops
JAVA0177JAVA0177 Variable declaration missing initializer
JAVA0173JAVA0173 Unused method parameter
DOC_COMMENTNumber of javadoc comment lines
JAVA0110JAVA0110 Incorrect javadoc: no @return tag
UNIQUE_OPERATORSNumber of unique operators
FUNCTIONSNumber of function declarations
JAVA0031JAVA0031 Case statement not properly closed
JAVA0049JAVA0049 Nested block at depth N (maximum: M)
JAVA0130JAVA0130 Non-static method does not use instance fields
JAVA0082JAVA0082 Unnecessary widening cast
NEST_DEPTHMaximum nesting depth
PROGRAM_VOLUMEHalstead program volume
JAVA0136JAVA0136 N methods defined in class (maximum: M)
JAVA0160JAVA0160 Method does not throw specified exception
JAVA0126JAVA0126 Method declares unchecked exception in throws
JAVA0034JAVA0034 Missing braces in if statement
JAVA0100JAVA0100 Class contains N non-final fields (maximum: M)
JAVA0254JAVA0254 Use enhanced for loop construct instead of Iterator
JAVA0075JAVA0075 Method parameter hides field
/* * ============================================================================ * GNU Lesser General Public License * ============================================================================ * * JasperReports - Free Java report-generating library. * Copyright (C) 2001-2006 JasperSoft Corporation http://www.jaspersoft.com * * 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. * * JasperSoft Corporation * 303 Second Street, Suite 450 North * San Francisco, CA 94107 * http://www.jaspersoft.com */ /* * Special thanks to Google 'Summer of Code 2005' program for supporting this development * * Contributors: * Majid Ali Khan - majidkk@users.sourceforge.net * Frank Schˆnheit - Frank.Schoenheit@Sun.COM */ package net.sf.jasperreports.engine.export.oasis; import java.awt.Color; import java.awt.Dimension; import java.awt.geom.Dimension2D; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.io.Writer; import java.text.AttributedCharacterIterator; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; import net.sf.jasperreports.engine.JRAbstractExporter; import net.sf.jasperreports.engine.JRAlignment; import net.sf.jasperreports.engine.JRElement; import net.sf.jasperreports.engine.JRException; import net.sf.jasperreports.engine.JRExporterParameter; import net.sf.jasperreports.engine.JRHyperlink; import net.sf.jasperreports.engine.JRImage; import net.sf.jasperreports.engine.JRImageRenderer; import net.sf.jasperreports.engine.JRLine; import net.sf.jasperreports.engine.JRPrintElement; import net.sf.jasperreports.engine.JRPrintElementIndex; import net.sf.jasperreports.engine.JRPrintEllipse; import net.sf.jasperreports.engine.JRPrintFrame; import net.sf.jasperreports.engine.JRPrintHyperlink; import net.sf.jasperreports.engine.JRPrintImage; import net.sf.jasperreports.engine.JRPrintLine; import net.sf.jasperreports.engine.JRPrintPage; import net.sf.jasperreports.engine.JRPrintRectangle; import net.sf.jasperreports.engine.JRPrintText; import net.sf.jasperreports.engine.JRRenderable; import net.sf.jasperreports.engine.JRRuntimeException; import net.sf.jasperreports.engine.JRWrappingSvgRenderer; import net.sf.jasperreports.engine.JasperPrint; import net.sf.jasperreports.engine.export.CutsInfo; import net.sf.jasperreports.engine.export.ExporterFilter; import net.sf.jasperreports.engine.export.ExporterNature; import net.sf.jasperreports.engine.export.JRExportProgressMonitor; import net.sf.jasperreports.engine.export.JRExporterGridCell; import net.sf.jasperreports.engine.export.JRGridLayout; import net.sf.jasperreports.engine.export.JRHyperlinkProducer; import net.sf.jasperreports.engine.export.JRHyperlinkProducerFactory; import net.sf.jasperreports.engine.export.JROriginExporterFilter; import net.sf.jasperreports.engine.export.oasis.zip.FileBufferedOasisZip; import net.sf.jasperreports.engine.export.oasis.zip.FileBufferedOasisZipEntry; import net.sf.jasperreports.engine.export.oasis.zip.OasisZip; import net.sf.jasperreports.engine.export.oasis.zip.OasisZipEntry; import net.sf.jasperreports.engine.util.JRProperties; import net.sf.jasperreports.engine.util.JRStringUtil; import net.sf.jasperreports.engine.util.JRStyledText; /** * Exports a JasperReports document to ODF format. It has character output type and exports the document to a * grid-based layout. * @author Teodor Danciu (teodord@users.sourceforge.net) * @version $Id: JROpenDocumentExporter.java 2219 2008-06-11 12:21:02Z shertage $ */ public abstract class JROpenDocumentExporter extends JRAbstractExporter { protected static final String ODT_EXPORTER_PROPERTIES_PREFIX = JRProperties.PROPERTY_PREFIX + "export.odt."; protected static final String ODS_EXPORTER_PROPERTIES_PREFIX = JRProperties.PROPERTY_PREFIX + "export.ods."; /** * */ protected static final String JR_PAGE_ANCHOR_PREFIX = "JR_PAGE_ANCHOR_"; /** * */ protected static final String HORIZONTAL_ALIGN_LEFT = "start"; protected static final String HORIZONTAL_ALIGN_RIGHT = "end"; protected static final String HORIZONTAL_ALIGN_CENTER = "center"; protected static final String HORIZONTAL_ALIGN_JUSTIFY = "justified"; /** * */ protected static final String VERTICAL_ALIGN_TOP = "top"; protected static final String VERTICAL_ALIGN_MIDDLE = "middle"; protected static final String VERTICAL_ALIGN_BOTTOM = "bottom"; public static final String IMAGE_NAME_PREFIX = "img_"; protected static final int IMAGE_NAME_PREFIX_LEGTH = IMAGE_NAME_PREFIX.length(); /** * */ protected Writer tempBodyWriter = null; protected Writer tempStyleWriter = null; protected JRExportProgressMonitor progressMonitor = null; protected Map rendererToImagePathMap = null; protected Map imageMaps; protected List imagesToProcess = null; protected int reportIndex = 0; protected int pageIndex = 0; protected int tableIndex = 0; protected boolean startPage; /** * */ protected String encoding = null; /** * */ protected boolean isWrapBreakWord = false; protected Map fontMap = null; protected LinkedList backcolorStack; protected Color backcolor; private StyleCache styleCache = null; protected JRHyperlinkProducerFactory hyperlinkProducerFactory; protected ExporterNature nature = null; protected String exporterPropertiesPrefix; public JROpenDocumentExporter() { backcolorStack = new LinkedList(); backcolor = null; } /** * */ public void exportReport() throws JRException { progressMonitor = (JRExportProgressMonitor)parameters.get(JRExporterParameter.PROGRESS_MONITOR); /* */ setOffset(); try { /* */ setExportContext(); /* */ setInput(); if (!parameters.containsKey(JRExporterParameter.FILTER)) { filter = createFilter(exporterPropertiesPrefix); } /* */ if (!isModeBatch) { setPageRange(); } encoding = getStringParameterOrDefault( JRExporterParameter.CHARACTER_ENCODING, JRExporterParameter.PROPERTY_CHARACTER_ENCODING ); rendererToImagePathMap = new HashMap(); imageMaps = new HashMap(); imagesToProcess = new ArrayList(); fontMap = (Map) parameters.get(JRExporterParameter.FONT_MAP); setHyperlinkProducerFactory(); nature = getExporterNature(filter); OutputStream os = (OutputStream)parameters.get(JRExporterParameter.OUTPUT_STREAM); if (os != null) { try { exportReportToOasisZip(os); } catch (IOException e) { throw new JRException("Error trying to export to output stream : " + jasperPrint.getName(), e); } } else { File destFile = (File)parameters.get(JRExporterParameter.OUTPUT_FILE); if (destFile == null) { String fileName = (String)parameters.get(JRExporterParameter.OUTPUT_FILE_NAME); if (fileName != null) { destFile = new File(fileName); } else { throw new JRException("No output specified for the exporter."); } } try { os = new FileOutputStream(destFile); exportReportToOasisZip(os); } catch (IOException e) { throw new JRException("Error trying to export to file : " + destFile, e); } finally { if (os != null) { try { os.close(); } catch(IOException e) { } } } } } finally { resetExportContext(); } } protected void setHyperlinkProducerFactory() { hyperlinkProducerFactory = (JRHyperlinkProducerFactory) parameters.get(JRExporterParameter.HYPERLINK_PRODUCER_FACTORY); } /** * */ public static JRPrintImage getImage(List jasperPrintList, String imageName) { return getImage(jasperPrintList, getPrintElementIndex(imageName)); } public static JRPrintImage getImage(List jasperPrintList, JRPrintElementIndex imageIndex) { JasperPrint report = (JasperPrint)jasperPrintList.get(imageIndex.getReportIndex()); JRPrintPage page = (JRPrintPage)report.getPages().get(imageIndex.getPageIndex()); Integer[] elementIndexes = imageIndex.getAddressArray(); Object element = page.getElements().get(elementIndexes[0].intValue()); for (int i = 1; i < elementIndexes.length; ++i) { JRPrintFrame frame = (JRPrintFrame) element; element = frame.getElements().get(elementIndexes[i].intValue()); } return (JRPrintImage) element; } /** * */ protected void exportReportToOasisZip(OutputStream os) throws JRException, IOException { OasisZip oasisZip = new FileBufferedOasisZip(((JROpenDocumentExporterNature)nature).getOpenDocumentNature()); OasisZipEntry tempBodyEntry = new FileBufferedOasisZipEntry(null); OasisZipEntry tempStyleEntry = new FileBufferedOasisZipEntry(null); tempBodyWriter = tempBodyEntry.getWriter(); tempStyleWriter = tempStyleEntry.getWriter(); styleCache = new StyleCache(tempStyleWriter, fontMap); Writer stylesWriter = oasisZip.getStylesEntry().getWriter(); StyleBuilder styleBuilder = new StyleBuilder(jasperPrintList, stylesWriter); styleBuilder.build(); stylesWriter.close(); for(reportIndex = 0; reportIndex < jasperPrintList.size(); reportIndex++) { jasperPrint = (JasperPrint)jasperPrintList.get(reportIndex); List pages = jasperPrint.getPages(); if (pages != null && pages.size() > 0) { if (isModeBatch) { startPageIndex = 0; endPageIndex = pages.size() - 1; } JRPrintPage page = null; for(pageIndex = startPageIndex; pageIndex <= endPageIndex; pageIndex++) { if (Thread.currentThread().isInterrupted()) { throw new JRException("Current thread interrupted."); } page = (JRPrintPage)pages.get(pageIndex); exportPage(page); } } } tempBodyWriter.flush(); tempStyleWriter.flush(); tempBodyWriter.close(); tempStyleWriter.close(); /* */ ContentBuilder contentBuilder = new ContentBuilder( oasisZip.getContentEntry(), tempStyleEntry, tempBodyEntry, styleCache.getFontFaces(), ((JROpenDocumentExporterNature)nature).getOpenDocumentNature() ); contentBuilder.build(); tempStyleEntry.dispose(); tempBodyEntry.dispose(); if ((imagesToProcess != null && imagesToProcess.size() > 0)) { for(Iterator it = imagesToProcess.iterator(); it.hasNext();) { JRPrintElementIndex imageIndex = (JRPrintElementIndex)it.next(); JRPrintImage image = getImage(jasperPrintList, imageIndex); JRRenderable renderer = image.getRenderer(); if (renderer.getType() == JRRenderable.TYPE_SVG) { renderer = new JRWrappingSvgRenderer( renderer, new Dimension(image.getWidth(), image.getHeight()), JRElement.MODE_OPAQUE == image.getMode() ? image.getBackcolor() : null ); } oasisZip.addEntry(//FIXMEODT optimize with a different implementation of entry new FileBufferedOasisZipEntry( "Pictures/" + getImageName(imageIndex), renderer.getImageData() ) ); } } oasisZip.zipEntries(os); oasisZip.dispose(); } /** * */ protected void exportPage(JRPrintPage page) throws JRException, IOException { startPage = true; JRGridLayout layout = new JRGridLayout( nature, page.getElements(), jasperPrint.getPageWidth(), jasperPrint.getPageHeight(), globalOffsetX, globalOffsetY, null //address ); exportGrid(layout, null); if (progressMonitor != null) { progressMonitor.afterPageExport(); } } /** * */ protected void exportGrid(JRGridLayout gridLayout, JRPrintElementIndex frameIndex) throws IOException, JRException { CutsInfo xCuts = gridLayout.getXCuts(); JRExporterGridCell[][] grid = gridLayout.getGrid(); TableBuilder tableBuilder = frameIndex == null ? new TableBuilder(reportIndex, pageIndex, tempBodyWriter, tempStyleWriter) : new TableBuilder(frameIndex.toString(), tempBodyWriter, tempStyleWriter); tableBuilder.buildTableStyle(); tableBuilder.buildTableHeader(); for(int col = 1; col < xCuts.size(); col++) { tableBuilder.buildColumnStyle( col - 1, xCuts.getCut(col) - xCuts.getCut(col - 1) ); tableBuilder.buildColumnHeader(col - 1); tableBuilder.buildColumnFooter(); } JRPrintElement element = null; for(int row = 0; row < grid.length; row++) { //JRExporterGridCell[] gridRow = grid[row]; int emptyCellColSpan = 0; int emptyCellWidth = 0; int rowHeight = gridLayout.getRowHeight(row); tableBuilder.buildRowStyle(row, rowHeight); tableBuilder.buildRowHeader(row); for(int col = 0; col < grid[0].length; col++) { JRExporterGridCell gridCell = grid[row][col]; if (gridCell == JRExporterGridCell.OCCUPIED_CELL) { if (emptyCellColSpan > 0) { writeEmptyCell(gridCell, emptyCellColSpan, emptyCellWidth, rowHeight); emptyCellColSpan = 0; emptyCellWidth = 0; } writeOccupiedCells(1); } else if(gridCell.getWrapper() != null) { if (emptyCellColSpan > 0) { writeEmptyCell(gridCell, emptyCellColSpan, emptyCellWidth, rowHeight); emptyCellColSpan = 0; emptyCellWidth = 0; } element = gridCell.getWrapper().getElement(); if (element instanceof JRPrintLine) { exportLine(tableBuilder, (JRPrintLine)element, gridCell); } else if (element instanceof JRPrintRectangle) { exportRectangle(tableBuilder, (JRPrintRectangle)element, gridCell); } else if (element instanceof JRPrintEllipse) { exportEllipse(tableBuilder, (JRPrintEllipse)element, gridCell); } else if (element instanceof JRPrintImage) { exportImage(tableBuilder, (JRPrintImage)element, gridCell); } else if (element instanceof JRPrintText) { exportText(tableBuilder, (JRPrintText)element, gridCell); } else if (element instanceof JRPrintFrame) { exportFrame(tableBuilder, (JRPrintFrame)element, gridCell); } //x += gridCell.colSpan - 1; } else { emptyCellColSpan++; emptyCellWidth += gridCell.getWidth(); } } if (emptyCellColSpan > 0) { writeEmptyCell(null, emptyCellColSpan, emptyCellWidth, rowHeight); } tableBuilder.buildRowFooter(); } tableBuilder.buildTableFooter(); } private void writeEmptyCell(JRExporterGridCell gridCell, int emptyCellColSpan, int emptyCellWidth, int rowHeight) throws IOException { tempBodyWriter.write("<table:table-cell"); //tempBodyWriter.write(" office:value-type=\"string\""); tempBodyWriter.write(" table:style-name=\"empty-cell\""); if (emptyCellColSpan > 1) { tempBodyWriter.write(" table:number-columns-spanned=\"" + emptyCellColSpan + "\""); } tempBodyWriter.write("/>\n"); writeOccupiedCells(emptyCellColSpan - 1); } private void writeOccupiedCells(int count) throws IOException { for(int i = 0; i < count; i++) { tempBodyWriter.write("<table:covered-table-cell/>\n"); } } /** * */ protected void exportLine(TableBuilder tableBuilder, JRPrintLine line, JRExporterGridCell gridCell) throws IOException { tableBuilder.buildCellHeader(null, gridCell.getColSpan(), gridCell.getRowSpan()); double x1, y1, x2, y2; if (line.getDirection() == JRLine.DIRECTION_TOP_DOWN) { x1 = Utility.translatePixelsToInches(0); y1 = Utility.translatePixelsToInches(0); x2 = Utility.translatePixelsToInches(line.getWidth() - 1); y2 = Utility.translatePixelsToInches(line.getHeight() - 1); } else { x1 = Utility.translatePixelsToInches(0); y1 = Utility.translatePixelsToInches(line.getHeight() - 1); x2 = Utility.translatePixelsToInches(line.getWidth() - 1); y2 = Utility.translatePixelsToInches(0); } tempBodyWriter.write("<text:p>"); insertPageAnchor(); tempBodyWriter.write( "<draw:line text:anchor-type=\"paragraph\" " + "draw:style-name=\"" + styleCache.getGraphicStyle(line) + "\" " + "svg:x1=\"" + x1 + "in\" " + "svg:y1=\"" + y1 + "in\" " + "svg:x2=\"" + x2 + "in\" " + "svg:y2=\"" + y2 + "in\">" //+ "</draw:line>" + "<text:p/></draw:line>" + "</text:p>" ); tableBuilder.buildCellFooter(); } /** * */ protected void exportRectangle(TableBuilder tableBuilder, JRPrintRectangle rectangle, JRExporterGridCell gridCell) throws IOException { tableBuilder.buildCellHeader(styleCache.getCellStyle(rectangle), gridCell.getColSpan(), gridCell.getRowSpan()); tableBuilder.buildCellFooter(); } /** * */ protected void exportEllipse(TableBuilder tableBuilder, JRPrintEllipse ellipse, JRExporterGridCell gridCell) throws IOException { tableBuilder.buildCellHeader(null, gridCell.getColSpan(), gridCell.getRowSpan()); tempBodyWriter.write("<text:p>"); insertPageAnchor(); tempBodyWriter.write( "<draw:ellipse text:anchor-type=\"paragraph\" " + "draw:style-name=\"" + styleCache.getGraphicStyle(ellipse) + "\" " + "svg:width=\"" + Utility.translatePixelsToInches(ellipse.getWidth()) + "in\" " + "svg:height=\"" + Utility.translatePixelsToInches(ellipse.getHeight()) + "in\" " + "svg:x=\"0in\" " + "svg:y=\"0in\">" + "<text:p/></draw:ellipse></text:p>" ); tableBuilder.buildCellFooter(); } /** * */ protected void exportText(TableBuilder tableBuilder, JRPrintText text, JRExporterGridCell gridCell) throws IOException { tableBuilder.buildCellHeader(styleCache.getCellStyle(text), gridCell.getColSpan(), gridCell.getRowSpan()); JRStyledText styledText = getStyledText(text); int textLength = 0; if (styledText != null) { textLength = styledText.length(); } // if (isWrapBreakWord) // { // styleBuffer.append("width: " + gridCell.width + "; "); // styleBuffer.append("word-wrap: break-word; "); // } // if (text.getLineSpacing() != JRTextElement.LINE_SPACING_SINGLE) // { // styleBuffer.append("line-height: " + text.getLineSpacingFactor() + "; "); // } // if (styleBuffer.length() > 0) // { // writer.write(" style=\""); // writer.write(styleBuffer.toString()); // writer.write("\""); // } // // writer.write(">"); tempBodyWriter.write("<text:p text:style-name=\""); tempBodyWriter.write(styleCache.getParagraphStyle(text)); tempBodyWriter.write("\">"); insertPageAnchor(); if (text.getAnchorName() != null) { tempBodyWriter.write("<text:bookmark text:name=\""); tempBodyWriter.write(text.getAnchorName()); tempBodyWriter.write("\"/>"); } boolean startedHyperlink = startHyperlink(text, true); if (textLength > 0) { exportStyledText(styledText); } if (startedHyperlink) { endHyperlink(true); } tempBodyWriter.write("</text:p>\n"); tableBuilder.buildCellFooter(); } /** * */ protected void exportStyledText(JRStyledText styledText) throws IOException { String text = styledText.getText(); int runLimit = 0; AttributedCharacterIterator iterator = styledText.getAttributedString().getIterator(); while(runLimit < styledText.length() && (runLimit = iterator.getRunLimit()) <= styledText.length()) { exportStyledTextRun(iterator.getAttributes(), text.substring(iterator.getIndex(), runLimit)); iterator.setIndex(runLimit); } } /** * */ protected void exportStyledTextRun(Map attributes, String text) throws IOException { String textSpanStyleName = styleCache.getTextSpanStyle(attributes, text); tempBodyWriter.write("<text:span"); tempBodyWriter.write(" text:style-name=\"" + textSpanStyleName + "\""); tempBodyWriter.write(">"); if (text != null) { tempBodyWriter.write(Utility.replaceNewLineWithLineBreak(JRStringUtil.xmlEncode(text)));//FIXMEODT try something nicer for replace } tempBodyWriter.write("</text:span>"); } /** * */ protected void exportImage(TableBuilder tableBuilder, JRPrintImage image, JRExporterGridCell gridCell) throws JRException, IOException { int topPadding = Math.max(image.getLineBox().getTopPadding().intValue(), Math.round(image.getLineBox().getTopPen().getLineWidth().floatValue())); int leftPadding = Math.max(image.getLineBox().getLeftPadding().intValue(), Math.round(image.getLineBox().getLeftPen().getLineWidth().floatValue())); int bottomPadding = Math.max(image.getLineBox().getBottomPadding().intValue(), Math.round(image.getLineBox().getBottomPen().getLineWidth().floatValue())); int rightPadding = Math.max(image.getLineBox().getRightPadding().intValue(), Math.round(image.getLineBox().getRightPen().getLineWidth().floatValue())); int availableImageWidth = image.getWidth() - leftPadding - rightPadding; availableImageWidth = availableImageWidth < 0 ? 0 : availableImageWidth; int availableImageHeight = image.getHeight() - topPadding - bottomPadding; availableImageHeight = availableImageHeight < 0 ? 0 : availableImageHeight; int width = availableImageWidth; int height = availableImageHeight; int xoffset = 0; int yoffset = 0; tableBuilder.buildCellHeader(styleCache.getCellStyle(image), gridCell.getColSpan(), gridCell.getRowSpan()); JRRenderable renderer = image.getRenderer(); if ( renderer != null && availableImageWidth > 0 && availableImageHeight > 0 ) { if (renderer.getType() == JRRenderable.TYPE_IMAGE && !image.isLazy()) { // Non-lazy image renderers are all asked for their image data at some point. // Better to test and replace the renderer now, in case of lazy load error. renderer = JRImageRenderer.getOnErrorRendererForImageData(renderer, image.getOnErrorType()); } } else { renderer = null; } if (renderer != null) { float xalignFactor = getXAlignFactor(image); float yalignFactor = getYAlignFactor(image); switch (image.getScaleImage()) { case JRImage.SCALE_IMAGE_FILL_FRAME : { width = availableImageWidth; height = availableImageHeight; xoffset = 0; yoffset = 0; break; } case JRImage.SCALE_IMAGE_CLIP : case JRImage.SCALE_IMAGE_RETAIN_SHAPE : default : { double normalWidth = availableImageWidth; double normalHeight = availableImageHeight; if (!image.isLazy()) { // Image load might fail. JRRenderable tmpRenderer = JRImageRenderer.getOnErrorRendererForDimension(renderer, image.getOnErrorType()); Dimension2D dimension = tmpRenderer == null ? null : tmpRenderer.getDimension(); // If renderer was replaced, ignore image dimension. if (tmpRenderer == renderer && dimension != null) { normalWidth = dimension.getWidth(); normalHeight = dimension.getHeight(); } } if (availableImageHeight > 0) { double ratio = (double)normalWidth / (double)normalHeight; if( ratio > availableImageWidth / (double)availableImageHeight ) { width = availableImageWidth; height = (int)(width/ratio); } else { height = availableImageHeight; width = (int)(ratio * height); } } xoffset = (int)(xalignFactor * (availableImageWidth - width)); yoffset = (int)(yalignFactor * (availableImageHeight - height)); } } tempBodyWriter.write("<text:p>"); insertPageAnchor(); if (image.getAnchorName() != null) { tempBodyWriter.write("<text:bookmark text:name=\""); tempBodyWriter.write(image.getAnchorName()); tempBodyWriter.write("\"/>"); } boolean startedHyperlink = startHyperlink(image,false); tempBodyWriter.write("<draw:frame text:anchor-type=\"paragraph\" " + "draw:style-name=\"" + styleCache.getGraphicStyle(image) + "\" " + "svg:x=\"" + Utility.translatePixelsToInches(leftPadding + xoffset) + "in\" " + "svg:y=\"" + Utility.translatePixelsToInches(topPadding + yoffset) + "in\" " + "svg:width=\"" + Utility.translatePixelsToInches(width) + "in\" " + "svg:height=\"" + Utility.translatePixelsToInches(height) + "in\">" ); tempBodyWriter.write("<draw:image "); tempBodyWriter.write(" xlink:href=\"" + getImagePath(renderer, image.isLazy(), gridCell) + "\""); tempBodyWriter.write(" xlink:type=\"simple\""); tempBodyWriter.write(" xlink:show=\"embed\""); tempBodyWriter.write(" xlink:actuate=\"onLoad\""); tempBodyWriter.write("/>\n"); tempBodyWriter.write("</draw:frame>"); if(startedHyperlink) { endHyperlink(false); } tempBodyWriter.write("</text:p>"); } tableBuilder.buildCellFooter(); } /** * */ protected String getImagePath(JRRenderable renderer, boolean isLazy, JRExporterGridCell gridCell) throws IOException { String imagePath = null; if (renderer != null) { if (renderer.getType() == JRRenderable.TYPE_IMAGE && rendererToImagePathMap.containsKey(renderer.getId())) { imagePath = (String)rendererToImagePathMap.get(renderer.getId()); } else { if (isLazy) { imagePath = ((JRImageRenderer)renderer).getImageLocation(); } else { JRPrintElementIndex imageIndex = getElementIndex(gridCell); imagesToProcess.add(imageIndex); String imageName = getImageName(imageIndex); imagePath = "Pictures/" + imageName; } rendererToImagePathMap.put(renderer.getId(), imagePath); } } return imagePath; } protected JRPrintElementIndex getElementIndex(JRExporterGridCell gridCell) { JRPrintElementIndex imageIndex = new JRPrintElementIndex( reportIndex, pageIndex, gridCell.getWrapper().getAddress() ); return imageIndex; } /** * * protected void writeImageMap(String imageMapName, JRPrintHyperlink mainHyperlink, List imageMapAreas) throws IOException { writer.write("<map name=\"" + imageMapName + "\">\n"); for (Iterator it = imageMapAreas.iterator(); it.hasNext();) { JRPrintImageAreaHyperlink areaHyperlink = (JRPrintImageAreaHyperlink) it.next(); JRPrintImageArea area = areaHyperlink.getArea(); writer.write(" <area shape=\"" + JRPrintImageArea.getHtmlShape(area.getShape()) + "\""); writeImageAreaCoordinates(area); writeImageAreaHyperlink(areaHyperlink.getHyperlink()); writer.write("/>\n"); } if (mainHyperlink.getHyperlinkType() != JRHyperlink.HYPERLINK_TYPE_NONE) { writer.write(" <area shape=\"default\""); writeImageAreaHyperlink(mainHyperlink); writer.write("/>\n"); } writer.write("</map>\n"); } protected void writeImageAreaCoordinates(JRPrintImageArea area) throws IOException { int[] coords = area.getCoordinates(); if (coords != null && coords.length > 0) { StringBuffer coordsEnum = new StringBuffer(coords.length * 4); coordsEnum.append(coords[0]); for (int i = 1; i < coords.length; i++) { coordsEnum.append(','); coordsEnum.append(coords[i]); } writer.write(" coords=\"" + coordsEnum + "\""); } } protected void writeImageAreaHyperlink(JRPrintHyperlink hyperlink) throws IOException { String href = getHyperlinkURL(hyperlink); if (href == null) { writer.write(" nohref=\"nohref\""); } else { writer.write(" href=\"" + href + "\""); String target = getHyperlinkTarget(hyperlink); if (target != null) { writer.write(" target=\""); writer.write(target); writer.write("\""); } } if (hyperlink.getHyperlinkTooltip() != null) { writer.write(" title=\""); writer.write(JRStringUtil.xmlEncode(hyperlink.getHyperlinkTooltip())); writer.write("\""); } } /** * */ public static String getImageName(JRPrintElementIndex printElementIndex) { return IMAGE_NAME_PREFIX + printElementIndex.toString(); } /** * */ public static JRPrintElementIndex getPrintElementIndex(String imageName) { if (!imageName.startsWith(IMAGE_NAME_PREFIX)) { throw new JRRuntimeException("Invalid image name: " + imageName); } return JRPrintElementIndex.parsePrintElementIndex(imageName.substring(IMAGE_NAME_PREFIX_LEGTH)); } /** * */ protected void exportFrame(TableBuilder tableBuilder, JRPrintFrame frame, JRExporterGridCell gridCell) throws IOException, JRException { tableBuilder.buildCellHeader(styleCache.getCellStyle(frame), gridCell.getColSpan(), gridCell.getRowSpan()); boolean appendBackcolor = frame.getMode() == JRElement.MODE_OPAQUE && (backcolor == null || frame.getBackcolor().getRGB() != backcolor.getRGB()); if (appendBackcolor) { setBackcolor(frame.getBackcolor()); } try { JRGridLayout layout = gridCell.getLayout(); JRPrintElementIndex frameIndex = new JRPrintElementIndex( reportIndex, pageIndex, gridCell.getWrapper().getAddress() ); exportGrid(layout, frameIndex); } finally { if (appendBackcolor) { restoreBackcolor(); } } tableBuilder.buildCellFooter(); } /** * */ protected void setBackcolor(Color color) { backcolorStack.addLast(backcolor); backcolor = color; } protected void restoreBackcolor() { backcolor = (Color) backcolorStack.removeLast(); } private float getXAlignFactor(JRPrintImage image) { float xalignFactor = 0f; switch (image.getHorizontalAlignment()) { case JRAlignment.HORIZONTAL_ALIGN_RIGHT : { xalignFactor = 1f; break; } case JRAlignment.HORIZONTAL_ALIGN_CENTER : { xalignFactor = 0.5f; break; } case JRAlignment.HORIZONTAL_ALIGN_LEFT : default : { xalignFactor = 0f; break; } } return xalignFactor; } private float getYAlignFactor(JRPrintImage image) { float yalignFactor = 0f; switch (image.getVerticalAlignment()) { case JRAlignment.VERTICAL_ALIGN_BOTTOM : { yalignFactor = 1f; break; } case JRAlignment.VERTICAL_ALIGN_MIDDLE : { yalignFactor = 0.5f; break; } case JRAlignment.VERTICAL_ALIGN_TOP : default : { yalignFactor = 0f; break; } } return yalignFactor; } protected boolean startHyperlink(JRPrintHyperlink link, boolean isText) throws IOException { String href = getHyperlinkURL(link); if (href != null) { if(isText) { tempBodyWriter.write("<text:a xlink:href=\""); } else { tempBodyWriter.write("<draw:a xlink:type=\"simple\" xlink:href=\""); } tempBodyWriter.write(href); tempBodyWriter.write("\""); String target = getHyperlinkTarget(link); if (target != null) { tempBodyWriter.write(" office:target-frame-name=\""); tempBodyWriter.write(target); tempBodyWriter.write("\""); if(target.equals("_blank")) { tempBodyWriter.write(" xlink:show=\"new\""); } } /* * tooltips are unavailable for the moment * if (link.getHyperlinkTooltip() != null) { tempBodyWriter.write(" xlink:title=\""); tempBodyWriter.write(JRStringUtil.xmlEncode(link.getHyperlinkTooltip())); tempBodyWriter.write("\""); } */ tempBodyWriter.write(">"); } return href != null; } protected String getHyperlinkTarget(JRPrintHyperlink link) { String target = null; switch(link.getHyperlinkTarget()) { case JRHyperlink.HYPERLINK_TARGET_SELF : { target = "_self"; break; } case JRHyperlink.HYPERLINK_TARGET_BLANK : default : { target = "_blank"; break; } } return target; } protected String getHyperlinkURL(JRPrintHyperlink link) { String href = null; JRHyperlinkProducer customHandler = getCustomHandler(link); if (customHandler == null) { switch(link.getHyperlinkType()) { case JRHyperlink.HYPERLINK_TYPE_REFERENCE : { if (link.getHyperlinkReference() != null) { href = link.getHyperlinkReference(); } break; } case JRHyperlink.HYPERLINK_TYPE_LOCAL_ANCHOR : { if (link.getHyperlinkAnchor() != null) { href = "#" + link.getHyperlinkAnchor(); } break; } case JRHyperlink.HYPERLINK_TYPE_LOCAL_PAGE : { if (link.getHyperlinkPage() != null) { href = "#" + JR_PAGE_ANCHOR_PREFIX + reportIndex + "_" + link.getHyperlinkPage().toString(); } break; } case JRHyperlink.HYPERLINK_TYPE_REMOTE_ANCHOR : { if ( link.getHyperlinkReference() != null && link.getHyperlinkAnchor() != null ) { href = link.getHyperlinkReference() + "#" + link.getHyperlinkAnchor(); } break; } case JRHyperlink.HYPERLINK_TYPE_REMOTE_PAGE : { if ( link.getHyperlinkReference() != null && link.getHyperlinkPage() != null ) { href = link.getHyperlinkReference() + "#" + JR_PAGE_ANCHOR_PREFIX + "0_" + link.getHyperlinkPage().toString(); } break; } case JRHyperlink.HYPERLINK_TYPE_NONE : default : { break; } } } else { href = customHandler.getHyperlink(link); } return href; } protected JRHyperlinkProducer getCustomHandler(JRPrintHyperlink link) { return hyperlinkProducerFactory == null ? null : hyperlinkProducerFactory.getHandler(link.getLinkType()); } protected void endHyperlink(boolean isText) throws IOException { if(isText) tempBodyWriter.write("</text:a>"); else tempBodyWriter.write("</draw:a>"); } protected void insertPageAnchor() throws IOException { if(startPage) { tempBodyWriter.write("<text:bookmark text:name=\""); tempBodyWriter.write(JR_PAGE_ANCHOR_PREFIX + reportIndex + "_" + (pageIndex + 1)); tempBodyWriter.write("\"/>\n"); startPage = false; } } protected abstract ExporterNature getExporterNature(ExporterFilter filter); }

The table below shows all metrics for JROpenDocumentExporter.java.

MetricValueDescription
BLOCKS134.00Number of blocks
BLOCK_COMMENT49.00Number of block comment lines
COMMENTS225.00Comment lines
COMMENT_DENSITY 0.37Comment density
COMPARISONS101.00Number of comparison operators
CYCLOMATIC141.00Cyclomatic complexity
DECL_COMMENTS26.00Comments in declarations
DOC_COMMENT151.00Number of javadoc comment lines
ELOC611.00Effective lines of code
EXEC_COMMENTS30.00Comments in executable code
EXITS166.00Procedure exits
FUNCTIONS33.00Number of function declarations
HALSTEAD_DIFFICULTY104.36Halstead difficulty
HALSTEAD_EFFORT 0.00Halstead effort
INTERFACE_COMPLEXITY215.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 0.00JAVA0005 Imports not in specified order
JAVA0006 0.00JAVA0006 Empty finally block
JAVA0007 0.00JAVA0007 Should not declare public field
JAVA0008 0.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 1.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 1.00JAVA0031 Case statement not properly closed
JAVA0032 0.00JAVA0032 Switch statement missing default
JAVA0033 0.00JAVA0033 default: not last case in switch statement
JAVA0034 2.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 2.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 0.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 0.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 1.00JAVA0075 Method parameter hides field
JAVA0076 2.00JAVA0076 Use of magic number
JAVA0077 0.00JAVA0077 Private field not used in declaring class
JAVA0078 0.00JAVA0078 Floating point values compared with ==
JAVA0079 0.00JAVA0079 Use of instance to reference static member
JAVA0080 1.00JAVA0080 Import declaration not used
JAVA0081 0.00JAVA0081 Boolean literal in comparison
JAVA0082 2.00JAVA0082 Unnecessary widening cast
JAVA0083 0.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 0.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
JAVA010833.00JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
JAVA0109 0.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 0.00JAVA0114 Incorrect javadoc: no @version tag
JAVA011518.00JAVA0115 Incorrect javadoc: no @throws or @exception tag for 'exception'
JAVA0116 1.00JAVA0116 Missing javadoc: field 'field'
JAVA011712.00JAVA0117 Missing javadoc: method 'method'
JAVA0118 0.00JAVA0118 Missing javadoc: type 'type'
JAVA0119 0.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 2.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 0.00JAVA0143 Synchronized method
JAVA014410.00JAVA0144 Line exceeds maximum M characters
JAVA01452926.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 1.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 0.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 0.00JAVA0171 Unused local variable
JAVA0173 3.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 4.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 1.00JAVA0254 Use enhanced for loop construct instead of Iterator
JAVA0255 0.00JAVA0255 Result of method invocation not used
JAVA0256 0.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 0.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 0.00JAVA0265 Use of Throwable.printStackTrace()
JAVA0266 0.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
LINES1314.00Number of lines in the source file
LINE_COMMENT25.00Number of line comments
LOC895.00Lines of code
LOGICAL_LINES398.00Number of statements
LOOPS 9.00Number of loops
NEST_DEPTH 6.00Maximum nesting depth
OPERANDS1861.00Number of operands
OPERATORS3308.00Number of operators
PARAMS50.00Number of formal parameter declarations
PROGRAM_LENGTH5169.00Halstead program length
PROGRAM_VOCAB595.00Halstead program vocabulary
PROGRAM_VOLUME 0.00Halstead program volume
RETURNS165.00Number of return points from functions
SIZE34160.00Size of the file in bytes
UNIQUE_OPERANDS535.00Number of unique operands
UNIQUE_OPERATORS60.00Number of unique operators
WHITESPACE194.00Number of whitespace lines