From: William Victor Mote Date: Mon, 30 Jun 2003 22:01:03 +0000 (+0000) Subject: Refactor constants to conform to style guidelines. Add javadoc comments. X-Git-Tag: Root_Temp_KnuthStylePageBreaking~1370 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=336b49376838870b071d68890b0af3db48abd502;p=xmlgraphics-fop.git Refactor constants to conform to style guidelines. Add javadoc comments. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196552 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/rtf/rtflib/exceptions/RtfException.java b/src/java/org/apache/fop/rtf/rtflib/exceptions/RtfException.java index adb4dac7d..1d4e19191 100755 --- a/src/java/org/apache/fop/rtf/rtflib/exceptions/RtfException.java +++ b/src/java/org/apache/fop/rtf/rtflib/exceptions/RtfException.java @@ -61,8 +61,10 @@ package org.apache.fop.rtf.rtflib.exceptions; /** Base class for rtflib exceptions. * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch */ - public class RtfException extends java.io.IOException { + /** + * @param reason Description of reason for Exception. + */ public RtfException(String reason) { super(reason); } diff --git a/src/java/org/apache/fop/rtf/rtflib/exceptions/RtfStructureException.java b/src/java/org/apache/fop/rtf/rtflib/exceptions/RtfStructureException.java index 09c59d711..7349057c7 100755 --- a/src/java/org/apache/fop/rtf/rtflib/exceptions/RtfStructureException.java +++ b/src/java/org/apache/fop/rtf/rtflib/exceptions/RtfStructureException.java @@ -61,9 +61,11 @@ package org.apache.fop.rtf.rtflib.exceptions; /** Thrown when a method call would lead to an invalid RTF document structure. * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch */ - public class RtfStructureException extends RtfException { + /** + * @param reason Description of reason for exception. + */ public RtfStructureException(String reason) { super(reason); } diff --git a/src/java/org/apache/fop/rtf/rtflib/interfaces/ITableColumnsInfo.java b/src/java/org/apache/fop/rtf/rtflib/interfaces/ITableColumnsInfo.java index e91ec8a98..415ad1266 100644 --- a/src/java/org/apache/fop/rtf/rtflib/interfaces/ITableColumnsInfo.java +++ b/src/java/org/apache/fop/rtf/rtflib/interfaces/ITableColumnsInfo.java @@ -76,9 +76,9 @@ public interface ITableColumnsInfo { */ float getColumnWidth(); - /** @return current column iteration index */ - int getColumnIndex(); + /** @return current column iteration index */ + int getColumnIndex(); - /** @return number of columns */ - int getNumberOfColumns(); + /** @return number of columns */ + int getNumberOfColumns(); } \ No newline at end of file diff --git a/src/java/org/apache/fop/rtf/rtflib/testdocs/BasicLink.java b/src/java/org/apache/fop/rtf/rtflib/testdocs/BasicLink.java index 407ebc24c..8a7553d29 100755 --- a/src/java/org/apache/fop/rtf/rtflib/testdocs/BasicLink.java +++ b/src/java/org/apache/fop/rtf/rtflib/testdocs/BasicLink.java @@ -82,7 +82,11 @@ public class BasicLink extends TestDocument { public BasicLink() { } - /** generate the body of the test document */ + /** generate the body of the test document + * @param rda RtfDocumentArea + * @param sect RtfSection + * @throws IOException for I/O Errors + */ protected void generateDocument(RtfDocumentArea rda, RtfSection sect) throws IOException { RtfParagraph p = sect.newParagraph (); p.newLineBreak(); diff --git a/src/java/org/apache/fop/rtf/rtflib/testdocs/CreateTestDocuments.java b/src/java/org/apache/fop/rtf/rtflib/testdocs/CreateTestDocuments.java index 7795cf8b7..f179b6af4 100755 --- a/src/java/org/apache/fop/rtf/rtflib/testdocs/CreateTestDocuments.java +++ b/src/java/org/apache/fop/rtf/rtflib/testdocs/CreateTestDocuments.java @@ -68,10 +68,14 @@ import java.io.IOException; */ public class CreateTestDocuments { + + /** + * package name for the testdocs + */ public static final String TESTDOCS_PACKAGE = "org.apache.fop.rtf.rtflib.testdocs"; /** List of all TestDocument subclasses from this package */ - private static final String [] classNames = { + private static final String [] CLASS_NAMES = { "SimpleDocument", "TextAttributes", "SimpleTable", @@ -91,8 +95,8 @@ public class CreateTestDocuments { throw new IOException("output directory (" + outDir + ") must exist and be writable"); } - for (int i = 0; i < classNames.length; i++) { - createOneTestDocument(classNames[i], outDir); + for (int i = 0; i < CLASS_NAMES.length; i++) { + createOneTestDocument(CLASS_NAMES[i], outDir); } } @@ -111,7 +115,10 @@ public class CreateTestDocuments { td.generateOutput(); } - /** execute this to create test documents from all classes listed in classNames array */ + /** execute this to create test documents from all classes listed in classNames array + * @param args String array of arguments + * @throws Exception for errors + */ public static void main(String args[]) throws Exception { if (args.length < 1) { diff --git a/src/java/org/apache/fop/rtf/rtflib/testdocs/MergedTableCells.java b/src/java/org/apache/fop/rtf/rtflib/testdocs/MergedTableCells.java index 1e99c7740..273d91e3b 100755 --- a/src/java/org/apache/fop/rtf/rtflib/testdocs/MergedTableCells.java +++ b/src/java/org/apache/fop/rtf/rtflib/testdocs/MergedTableCells.java @@ -71,13 +71,14 @@ import org.apache.fop.rtf.rtflib.rtfdoc.RtfTableCell; */ class MergedTableCells extends TestDocument { + static final int MM_TO_TWIPS = (int)(1440f / 25.4f); + /** generate the body of the test document */ protected void generateDocument(RtfDocumentArea rda, RtfSection sect) throws IOException { sect.newParagraph().newText("This document contains a table with some merged cells."); final RtfTable tbl = sect.newTable(new DummyTableColumnsInfo()); - final int MM_TO_TWIPS = (int)(1440f / 25.4f); // first row, test horizontal merging { diff --git a/src/java/org/apache/fop/rtf/rtflib/testdocs/ParagraphAlignment.java b/src/java/org/apache/fop/rtf/rtflib/testdocs/ParagraphAlignment.java index 3c48bc0e2..eff92a1b9 100755 --- a/src/java/org/apache/fop/rtf/rtflib/testdocs/ParagraphAlignment.java +++ b/src/java/org/apache/fop/rtf/rtflib/testdocs/ParagraphAlignment.java @@ -69,8 +69,18 @@ import org.apache.fop.rtf.rtflib.rtfdoc.RtfAttributes; */ public class ParagraphAlignment extends TestDocument { + /** + * Constructor + */ public ParagraphAlignment() { } + + /** + * Generate the document. + * @param rda RtfDocumentArea + * @param sect RtfSection + * @throws java.io.IOException for I/O errors + */ protected void generateDocument(RtfDocumentArea rda, RtfSection sect) throws java.io.IOException { RtfAttributes attr = new RtfAttributes (); diff --git a/src/java/org/apache/fop/rtf/rtflib/testdocs/SimpleTable.java b/src/java/org/apache/fop/rtf/rtflib/testdocs/SimpleTable.java index b9aa459f6..e634a5ef6 100755 --- a/src/java/org/apache/fop/rtf/rtflib/testdocs/SimpleTable.java +++ b/src/java/org/apache/fop/rtf/rtflib/testdocs/SimpleTable.java @@ -71,16 +71,16 @@ import org.apache.fop.rtf.rtflib.rtfdoc.RtfTableCell; */ class SimpleTable extends TestDocument { /** generate the body of the test document */ + static final int MAX_ROW = 2; + static final int MAX_COL = 3; + static final int INCH_TO_TWIPS = 1440; + static final int C1W = 4; + protected void generateDocument(RtfDocumentArea rda, RtfSection sect) throws IOException { final RtfTable tbl = sect.newTable(new DummyTableColumnsInfo()); - final int MAX_ROW = 2; - final int MAX_COL = 3; - - final int INCH_TO_TWIPS = 1440; - final int c1w = 4; - tbl.newTableRow().newTableCell(c1w * INCH_TO_TWIPS).newParagraph().newText - ("Here's a table row with just one cell, width " + c1w + "''"); + tbl.newTableRow().newTableCell(C1W * INCH_TO_TWIPS).newParagraph().newText + ("Here's a table row with just one cell, width " + C1W + "''"); for (int row = 0; row < MAX_ROW; row++) { final RtfTableRow r = tbl.newTableRow(); diff --git a/src/java/org/apache/fop/rtf/rtflib/testdocs/TestDocument.java b/src/java/org/apache/fop/rtf/rtflib/testdocs/TestDocument.java index e2a7f4866..abba5654b 100755 --- a/src/java/org/apache/fop/rtf/rtflib/testdocs/TestDocument.java +++ b/src/java/org/apache/fop/rtf/rtflib/testdocs/TestDocument.java @@ -74,11 +74,11 @@ import org.apache.fop.rtf.rtflib.rtfdoc.RtfParagraph; */ abstract class TestDocument { - private File m_output; + private File output; final void setOutputDir(File outDir) throws IOException { - m_output = new File(outDir, getRtfFilename()); + output = new File(outDir, getRtfFilename()); } final String getRtfFilename() { @@ -90,8 +90,8 @@ abstract class TestDocument { final void generateOutput() throws IOException { - debugMsg("Generating document " + m_output + "..."); - final RtfFile f = new RtfFile(new FileWriter(m_output)); + debugMsg("Generating document " + output + "..."); + final RtfFile f = new RtfFile(new FileWriter(output)); final RtfDocumentArea rda = f.startDocumentArea(); final RtfSection sect = rda.newSection(); addIntroComments(sect); diff --git a/src/java/org/apache/fop/rtf/rtflib/tools/ImageConstants.java b/src/java/org/apache/fop/rtf/rtflib/tools/ImageConstants.java index d563fb60e..7f98af4da 100755 --- a/src/java/org/apache/fop/rtf/rtflib/tools/ImageConstants.java +++ b/src/java/org/apache/fop/rtf/rtflib/tools/ImageConstants.java @@ -71,41 +71,43 @@ public class ImageConstants { ////////////////////////////////////////////////// /** Defines the case, if image is not supported */ - public static int I_NOT_SUPPORTED = -1; - - public static int I_EMF = 0; - public static int I_PNG = 1; - public static int I_JPG = 2; + public static final int I_NOT_SUPPORTED = -1; + /** Integer equivalent for EMF */ + public static final int I_EMF = 0; + /** Integer equivalent for PNG */ + public static final int I_PNG = 1; + /** Integer equivalent for JPG */ + public static final int I_JPG = 2; /** Defines the RTF properties */ - public static String [] RTF_TAGS = new String [] + public static final String [] RTF_TAGS = new String [] { "emfblip", "pngblip", "jpegblip" }; - public static int I_TO_CONVERT_BASIS = 50; - public static int I_GIF = 50; - public static int I_JPG_C = 51; + public static final int I_TO_CONVERT_BASIS = 50; + public static final int I_GIF = 50; + public static final int I_JPG_C = 51; /** Defines the types for converting rtf supported image types */ - public static int [] CONVERT_TO = new int [] + public static final int [] CONVERT_TO = new int [] { I_JPG, I_JPG }; /** EMF file extension */ - public static String EMF_EXT = "emf"; + public static final String EMF_EXT = "emf"; /** PNG file extension */ - public static String PNG_EXT = "png"; + public static final String PNG_EXT = "png"; /** JPG file extension */ - public static String JPG_EXT = "jpg"; + public static final String JPG_EXT = "jpg"; /** JPEG file extension */ - public static String JPEG_EXT = "jpeg"; + public static final String JPEG_EXT = "jpeg"; /** GIF file extension */ - public static String GIF_EXT = "gif"; + public static final String GIF_EXT = "gif"; /** Defines the file extensions and the RTF property belongs to */ - public static Hashtable SUPPORTED_IMAGE_TYPES = new Hashtable (); + public static final Hashtable SUPPORTED_IMAGE_TYPES = new Hashtable (); static { SUPPORTED_IMAGE_TYPES.put (EMF_EXT, new Integer (I_EMF)); SUPPORTED_IMAGE_TYPES.put (PNG_EXT, new Integer (I_PNG)); diff --git a/src/java/org/apache/fop/rtf/rtflib/tools/ImageUtil.java b/src/java/org/apache/fop/rtf/rtflib/tools/ImageUtil.java index d21166ec0..8da089fbd 100755 --- a/src/java/org/apache/fop/rtf/rtflib/tools/ImageUtil.java +++ b/src/java/org/apache/fop/rtf/rtflib/tools/ImageUtil.java @@ -84,9 +84,8 @@ public class ImageUtil { * * @param value String with digits * - * @return - * -1 There is no digit\n - * number The digits as integer + * @return -1 There is no digit + * number The digits as integer */ public static int getInt (String value) { String retString = new String (); @@ -111,9 +110,8 @@ public class ImageUtil { * * @param value String with digits * - * @return - * true The string contains a % value - * false Other string + * @return true The string contains a % value + * false Other string */ public static boolean isPercent (String value) { if (value.endsWith ("%")) { @@ -132,9 +130,8 @@ public class ImageUtil { * @param searchAt Position to start compare * @param searchForward Direction to compare byte arrays * - * @return - * true If equal\n - * false If different + * @return true If equal + * false If different */ public static boolean compareHexValues (byte[] pattern, byte[] data, int searchAt, boolean searchForward) { @@ -178,10 +175,11 @@ public class ImageUtil { * Determines a integer value from a hexadecimal byte array. * * @param data Image - * @param start Start index to read from - * @param end End index until to read + * @param startAt Start index to read from + * @param length Number of data elements to read + * @param searchForward True if searching forward, False if not (??) * - * @return A number + * @return integer */ public static int getIntFromByteArray (byte[] data, int startAt, int length, boolean searchForward) {