IntelliJ warnings, Javadoc, Formatting

Changes for the RecordFormatException deprecation

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1780453 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2017-01-26 19:58:46 +00:00
parent b7b4a73204
commit 560a33620a
15 changed files with 47 additions and 47 deletions

View File

@ -56,7 +56,7 @@ public class VariantSupport extends Variant {
private static final POILogger logger = POILogFactory.getLogger(VariantSupport.class); private static final POILogger logger = POILogFactory.getLogger(VariantSupport.class);
private static boolean logUnsupportedTypes = false; private static boolean logUnsupportedTypes;
/** /**
* Keeps a list of the variant types an "unsupported" message has already * Keeps a list of the variant types an "unsupported" message has already
@ -196,7 +196,7 @@ public class VariantSupport extends Variant {
return uniString.toJavaString(); return uniString.toJavaString();
// if(l1 < 0) { // if(l1 < 0) {
/** /*
* YK: reading the ClipboardData packet (VT_CF) is not quite * YK: reading the ClipboardData packet (VT_CF) is not quite
* correct. The size of the data is determined by the first four * correct. The size of the data is determined by the first four
* bytes of the packet while the current implementation calculates * bytes of the packet while the current implementation calculates

View File

@ -222,7 +222,7 @@ public final class PageSettingsBlock extends RecordAggregate {
private void checkNotPresent(Record rec) { private void checkNotPresent(Record rec) {
if (rec != null) { if (rec != null) {
throw new RecordFormatException("Duplicate PageSettingsBlock record (sid=0x" throw new org.apache.poi.util.RecordFormatException("Duplicate PageSettingsBlock record (sid=0x"
+ Integer.toHexString(rec.getSid()) + ")"); + Integer.toHexString(rec.getSid()) + ")");
} }
} }
@ -614,7 +614,7 @@ public final class PageSettingsBlock extends RecordAggregate {
throw new IllegalStateException("This page settings block already has a header/footer record"); throw new IllegalStateException("This page settings block already has a header/footer record");
} }
if (rec.getSid() != HeaderFooterRecord.sid) { if (rec.getSid() != HeaderFooterRecord.sid) {
throw new RecordFormatException("Unexpected header-footer record sid: 0x" + Integer.toHexString(rec.getSid())); throw new org.apache.poi.util.RecordFormatException("Unexpected header-footer record sid: 0x" + Integer.toHexString(rec.getSid()));
} }
_headerFooter = rec; _headerFooter = rec;
} }
@ -647,7 +647,7 @@ public final class PageSettingsBlock extends RecordAggregate {
* *
* @param rs the RecordStream to read from * @param rs the RecordStream to read from
* *
* @throws RecordFormatException if any PSB record encountered has the same type (sid) as * @throws org.apache.poi.util.RecordFormatException if any PSB record encountered has the same type (sid) as
* a record that is already part of this PageSettingsBlock * a record that is already part of this PageSettingsBlock
*/ */
public void addLateRecords(RecordStream rs) { public void addLateRecords(RecordStream rs) {

View File

@ -66,8 +66,7 @@ public final class HSSFCellStyle implements CellStyle {
* unless you're comparing which one is which) * unless you're comparing which one is which)
*/ */
@Override @Override
public short getIndex() public short getIndex() {
{
return _index; return _index;
} }
@ -489,8 +488,7 @@ public final class HSSFCellStyle implements CellStyle {
@Deprecated @Deprecated
@Removal(version="3.17") @Removal(version="3.17")
@Override @Override
public void setBorderLeft(short border) public void setBorderLeft(short border) {
{
_format.setIndentNotParentBorder(true); _format.setIndentNotParentBorder(true);
_format.setBorderLeft(border); _format.setBorderLeft(border);
} }

View File

@ -211,7 +211,7 @@ public class HSSFColor implements Color {
* *
* @return a Map containing all colors keyed by String gnumeric-like triplets * @return a Map containing all colors keyed by String gnumeric-like triplets
*/ */
public final static Map<String,HSSFColor> getTripletHash() public static Map<String,HSSFColor> getTripletHash()
{ {
return createColorsByHexStringMap(); return createColorsByHexStringMap();
} }

View File

@ -28,7 +28,7 @@ import java.util.ArrayList;
public class HexRead { public class HexRead {
/** /**
* This method reads hex data from a filename and returns a byte array. * This method reads hex data from a filename and returns a byte array.
* The file may contain line comments that are preceeded with a # symbol. * The file may contain line comments that are preceded with a # symbol.
* *
* @param filename The filename to read * @param filename The filename to read
* @return The bytes read from the file. * @return The bytes read from the file.

View File

@ -21,10 +21,7 @@ import java.awt.Color;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.RenderingHints; import java.awt.RenderingHints;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.File; import java.io.*;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
@ -94,7 +91,7 @@ public class VsdxToPng {
graphics.dispose(); graphics.dispose();
FileOutputStream out = new FileOutputStream(outFile); OutputStream out = new FileOutputStream(outFile);
try { try {
ImageIO.write(img, "png", out); ImageIO.write(img, "png", out);
} finally { } finally {

View File

@ -107,7 +107,7 @@ public class SXSSFWorkbook implements Workbook {
/** /**
* whether temp files should be compressed. * whether temp files should be compressed.
*/ */
private boolean _compressTmpFiles = false; private boolean _compressTmpFiles;
/** /**
* shared string table - a cache of strings in this workbook * shared string table - a cache of strings in this workbook
@ -817,6 +817,7 @@ public class SXSSFWorkbook implements Workbook {
@Removal(version="3.17") @Removal(version="3.17")
public Font findFont(short boldWeight, short color, short fontHeight, String name, boolean italic, boolean strikeout, short typeOffset, byte underline) public Font findFont(short boldWeight, short color, short fontHeight, String name, boolean italic, boolean strikeout, short typeOffset, byte underline)
{ {
//noinspection deprecation
return _wb.findFont(boldWeight, color, fontHeight, name, italic, strikeout, typeOffset, underline); return _wb.findFont(boldWeight, color, fontHeight, name, italic, strikeout, typeOffset, underline);
} }
@ -1027,8 +1028,8 @@ public class SXSSFWorkbook implements Workbook {
@Override @Override
@Deprecated @Deprecated
@Removal(version="3.18") @Removal(version="3.18")
public Name getNameAt(int nameIndex) public Name getNameAt(int nameIndex) {
{ //noinspection deprecation
return _wb.getNameAt(nameIndex); return _wb.getNameAt(nameIndex);
} }
@ -1058,8 +1059,8 @@ public class SXSSFWorkbook implements Workbook {
@Override @Override
@Deprecated @Deprecated
@Removal(version="3.18") @Removal(version="3.18")
public int getNameIndex(String name) public int getNameIndex(String name) {
{ //noinspection deprecation
return _wb.getNameIndex(name); return _wb.getNameIndex(name);
} }
@ -1073,8 +1074,8 @@ public class SXSSFWorkbook implements Workbook {
@Override @Override
@Deprecated @Deprecated
@Removal(version="3.18") @Removal(version="3.18")
public void removeName(int index) public void removeName(int index) {
{ //noinspection deprecation
_wb.removeName(index); _wb.removeName(index);
} }
@ -1088,8 +1089,8 @@ public class SXSSFWorkbook implements Workbook {
@Override @Override
@Deprecated @Deprecated
@Removal(version="3.18") @Removal(version="3.18")
public void removeName(String name) public void removeName(String name) {
{ //noinspection deprecation
_wb.removeName(name); _wb.removeName(name);
} }
@ -1298,8 +1299,12 @@ public class SXSSFWorkbook implements Workbook {
* formulas such as "[MyOtherWorkbook]Sheet3!$A$5" to be added to the * formulas such as "[MyOtherWorkbook]Sheet3!$A$5" to be added to the
* file, for workbooks not already referenced. * file, for workbooks not already referenced.
* *
* Note: this is not implemented and thus currently throws an Exception stating this.
*
* @param name The name the workbook will be referenced as in formulas * @param name The name the workbook will be referenced as in formulas
* @param workbook The open workbook to fetch the link required information from * @param workbook The open workbook to fetch the link required information from
*
* @throws RuntimeException stating that this method is not implemented yet.
*/ */
@Override @Override
@NotImplemented @NotImplemented

View File

@ -2076,8 +2076,12 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook {
* formulas such as "[MyOtherWorkbook.xlsx]Sheet3!$A$5" to be added to the * formulas such as "[MyOtherWorkbook.xlsx]Sheet3!$A$5" to be added to the
* file, for workbooks not already linked / referenced. * file, for workbooks not already linked / referenced.
* *
* Note: this is not implemented and thus currently throws an Exception stating this.
*
* @param name The name the workbook will be referenced as in formulas * @param name The name the workbook will be referenced as in formulas
* @param workbook The open workbook to fetch the link required information from * @param workbook The open workbook to fetch the link required information from
*
* @throws RuntimeException stating that this method is not implemented yet.
*/ */
@Override @Override
@NotImplemented @NotImplemented

View File

@ -1003,7 +1003,6 @@ public abstract class AbstractWordConverter
processEndnoteAutonumbered( doc, noteIndex, block, processEndnoteAutonumbered( doc, noteIndex, block,
noteTextRange ); noteTextRange );
return;
} }
} }
} }

View File

@ -158,7 +158,7 @@ public class WordToHtmlConverter extends AbstractWordConverter
private final HtmlDocumentFacade htmlDocumentFacade; private final HtmlDocumentFacade htmlDocumentFacade;
private Element notes = null; private Element notes;
/** /**
* Creates new instance of {@link WordToHtmlConverter}. Can be used for * Creates new instance of {@link WordToHtmlConverter}. Can be used for

View File

@ -392,8 +392,7 @@ public final class HWPFLister
for ( char c : text.toCharArray() ) for ( char c : text.toCharArray() )
{ {
if ( c < 30 ) if ( c < 30 )
stringBuilder stringBuilder.append("\\0x").append(Integer.toHexString(c));
.append( "\\0x" + Integer.toHexString( c ) );
else else
stringBuilder.append( c ); stringBuilder.append( c );
} }

View File

@ -96,7 +96,7 @@ public final class WordExtractor extends POIOLE2TextExtractor
} }
// Process the first argument as a file // Process the first argument as a file
FileInputStream fin = new FileInputStream( args[0] ); InputStream fin = new FileInputStream( args[0] );
WordExtractor extractor = new WordExtractor( fin ); WordExtractor extractor = new WordExtractor( fin );
try { try {
System.out.println( extractor.getText() ); System.out.println( extractor.getText() );

View File

@ -42,15 +42,16 @@ import org.apache.poi.util.StringUtil;
/** /**
* Represents embedded picture extracted from Word Document * Represents embedded picture extracted from Word Document
*/ */
public final class Picture public final class Picture {
{ private static final POILogger log = POILogFactory
.getLogger( Picture.class );
public static final byte[] COMPRESSED1 = { (byte) 0xFE, 0x78, (byte) 0xDA }; public static final byte[] COMPRESSED1 = { (byte) 0xFE, 0x78, (byte) 0xDA };
public static final byte[] COMPRESSED2 = { (byte) 0xFE, 0x78, (byte) 0x9C }; public static final byte[] COMPRESSED2 = { (byte) 0xFE, 0x78, (byte) 0x9C };
public static final byte[] IHDR = new byte[] { 'I', 'H', 'D', 'R' }; public static final byte[] IHDR = new byte[] { 'I', 'H', 'D', 'R' };
private static final POILogger log = POILogFactory
.getLogger( Picture.class );
@Deprecated @Deprecated
private static final byte[] PNG = new byte[] { (byte) 0x89, 0x50, 0x4E, private static final byte[] PNG = new byte[] { (byte) 0x89, 0x50, 0x4E,
0x47, 0x0D, 0x0A, 0x1A, 0x0A }; 0x47, 0x0D, 0x0A, 0x1A, 0x0A };
@ -401,10 +402,11 @@ public final class Picture
} }
/** /**
* Returns picture's content as it stored in Word file, i.e. possibly in * Returns picture's content as stored in the Word file, i.e. possibly in
* compressed form. * compressed form.
* *
* @return picture's content as it stored in Word file * @return picture's content as it stored in Word file or an empty byte array
* if it cannot be read.
*/ */
public byte[] getRawContent() public byte[] getRawContent()
{ {

View File

@ -82,8 +82,7 @@ public class TestWordToHtmlConverter
new DOMSource( wordToHtmlConverter.getDocument() ), new DOMSource( wordToHtmlConverter.getDocument() ),
new StreamResult( stringWriter )); new StreamResult( stringWriter ));
String result = stringWriter.toString(); return stringWriter.toString();
return result;
} }
@Test @Test

View File

@ -203,7 +203,6 @@ public final class TestPageSettingsBlock extends TestCase {
* was added while fixing bug 47199. All existing POI test samples comply with this requirement. * was added while fixing bug 47199. All existing POI test samples comply with this requirement.
*/ */
public void testDuplicatePSBRecord_bug47199() { public void testDuplicatePSBRecord_bug47199() {
// Hypothetical setup of PSB records which should cause POI to crash // Hypothetical setup of PSB records which should cause POI to crash
Record[] recs = { Record[] recs = {
new HeaderRecord("&LSales Figures"), new HeaderRecord("&LSales Figures"),
@ -214,10 +213,8 @@ public final class TestPageSettingsBlock extends TestCase {
try { try {
new PageSettingsBlock(rs); new PageSettingsBlock(rs);
throw new AssertionFailedError("Identified bug 47199b - duplicate PSB records should not be allowed"); throw new AssertionFailedError("Identified bug 47199b - duplicate PSB records should not be allowed");
} catch (RecordFormatException e) { } catch (org.apache.poi.util.RecordFormatException e) {
if (e.getMessage().equals("Duplicate PageSettingsBlock record (sid=0x14)")) { if (!e.getMessage().equals("Duplicate PageSettingsBlock record (sid=0x14)")) {
// expected during successful test
} else {
throw new AssertionFailedError("Expected RecordFormatException due to duplicate PSB record"); throw new AssertionFailedError("Expected RecordFormatException due to duplicate PSB record");
} }
} }
@ -288,7 +285,7 @@ public final class TestPageSettingsBlock extends TestCase {
PageSettingsBlock psb; PageSettingsBlock psb;
try { try {
psb = new PageSettingsBlock(rs); psb = new PageSettingsBlock(rs);
} catch (RecordFormatException e) { } catch (org.apache.poi.util.RecordFormatException e) {
if ("Duplicate PageSettingsBlock record (sid=0x4d)".equals(e.getMessage())) { if ("Duplicate PageSettingsBlock record (sid=0x4d)".equals(e.getMessage())) {
throw new AssertionFailedError("Identified bug 47415"); throw new AssertionFailedError("Identified bug 47415");
} }