Skip to content

Commit c1f018f

Browse files
committed
Apply some IDE suggestions, JavaDoc and GitHub PR
Update assertion-message Adjust JavaDoc Add tests Reformat class DirectoryNode, adjust/move some comments Closes #730 git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1921980 13f79535-47bb-0310-9956-ffa450edef68
1 parent 83384cc commit c1f018f

File tree

10 files changed

+147
-174
lines changed

10 files changed

+147
-174
lines changed

poi-ooxml/src/main/java/org/apache/poi/poifs/crypt/dsig/SignatureConfig.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ Licensed to the Apache Software Foundation (ASF) under one or more
2626
import java.security.KeyStore;
2727
import java.security.KeyStoreException;
2828
import java.security.PrivateKey;
29-
import java.security.Provider;
3029
import java.security.cert.Certificate;
3130
import java.security.cert.CertificateException;
3231
import java.security.cert.CertificateFactory;
@@ -52,14 +51,11 @@ Licensed to the Apache Software Foundation (ASF) under one or more
5251
import javax.xml.crypto.dsig.CanonicalizationMethod;
5352
import javax.xml.crypto.dsig.DigestMethod;
5453
import javax.xml.crypto.dsig.Transform;
55-
import javax.xml.crypto.dsig.XMLSignatureFactory;
56-
import javax.xml.crypto.dsig.keyinfo.KeyInfoFactory;
5754

5855
import org.apache.logging.log4j.LogManager;
5956
import org.apache.logging.log4j.Logger;
6057
import org.apache.poi.EncryptedDocumentException;
6158
import org.apache.poi.hpsf.ClassID;
62-
import org.apache.poi.openxml4j.opc.OPCPackage;
6359
import org.apache.poi.poifs.crypt.HashAlgorithm;
6460
import org.apache.poi.poifs.crypt.dsig.facets.KeyInfoSignatureFacet;
6561
import org.apache.poi.poifs.crypt.dsig.facets.OOXMLSignatureFacet;
@@ -73,7 +69,6 @@ Licensed to the Apache Software Foundation (ASF) under one or more
7369
import org.apache.poi.poifs.crypt.dsig.services.TimeStampService;
7470
import org.apache.poi.poifs.crypt.dsig.services.TimeStampServiceValidator;
7571
import org.apache.poi.poifs.crypt.dsig.services.TimeStampSimpleHttpClient;
76-
import org.apache.poi.util.Internal;
7772
import org.apache.poi.util.LocaleUtil;
7873
import org.apache.poi.util.Removal;
7974
import org.apache.xml.security.signature.XMLSignature;
@@ -382,7 +377,7 @@ public String formatExecutionTime() {
382377
* @since POI 4.0.0
383378
*/
384379
public void setExecutionTime(String executionTime) {
385-
if (executionTime != null && !"".equals(executionTime)){
380+
if (executionTime != null && !executionTime.isEmpty()){
386381
final DateFormat fmt = new SimpleDateFormat(SIGNATURE_TIME_FORMAT, Locale.ROOT);
387382
fmt.setTimeZone(LocaleUtil.TIMEZONE_UTC);
388383
try {
@@ -992,12 +987,12 @@ public void setSignatureMethodFromUri(final String signatureMethodUri) {
992987
* <li>the JDK xmlsec provider</li>
993988
* </ol>
994989
*
995-
* @return a list of possible XMLSEC provider class names
990+
* @return an array of possible XMLSEC provider class names
996991
*/
997992
public static String[] getProviderNames() {
998993
// need to check every time, as the system property might have been changed in the meantime
999994
String sysProp = System.getProperty("jsr105Provider");
1000-
return (sysProp == null || "".equals(sysProp))
995+
return (sysProp == null || sysProp.isEmpty())
1001996
? new String[]{XMLSEC_SANTUARIO, XMLSEC_JDK}
1002997
: new String[]{sysProp, XMLSEC_SANTUARIO, XMLSEC_JDK};
1003998
}
@@ -1031,7 +1026,7 @@ public boolean isUpdateConfigOnValidate() {
10311026

10321027
/**
10331028
* The signature config can be updated if a document is succesful validated.
1034-
* This flag is used for activating this modifications.
1029+
* This flag is used for activating these modifications.
10351030
* Defaults to {@code false}
10361031
*
10371032
* @param updateConfigOnValidate if true, update config on validate

poi-ooxml/src/test/java/org/apache/poi/xslf/usermodel/TestXSLFTextParagraph.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Licensed to the Apache Software Foundation (ASF) under one or more
1919
import static org.apache.poi.sl.usermodel.BaseTestSlideShow.getColor;
2020
import static org.junit.jupiter.api.Assertions.assertEquals;
2121
import static org.junit.jupiter.api.Assertions.assertFalse;
22+
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
2223
import static org.junit.jupiter.api.Assertions.assertNotNull;
2324
import static org.junit.jupiter.api.Assertions.assertNull;
2425
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -467,21 +468,21 @@ public void drawString(AttributedCharacterIterator iterator, float x, float y) {
467468
attributes = iterator.getAttributes();
468469
}
469470

470-
if ("This is a".equals(sb.toString())) {
471+
if ("This is a".contentEquals(sb)) {
471472
// Should be no background.
472473
assertNotNull(attributes);
473474
Object background = attributes.get(TextAttribute.BACKGROUND);
474475
assertNull(background);
475476
}
476-
if ("highlight".equals(sb.toString())) {
477+
if ("highlight".contentEquals(sb)) {
477478
// Should be yellow background.
478479
assertNotNull(attributes);
479480
Object background = attributes.get(TextAttribute.BACKGROUND);
480481
assertNotNull(background);
481-
assertTrue(background instanceof Color);
482+
assertInstanceOf(Color.class, background);
482483
assertEquals(Color.yellow, background);
483484
}
484-
if (" test".equals(sb.toString())) {
485+
if (" test".contentEquals(sb)) {
485486
// Should be no background.
486487
assertNotNull(attributes);
487488
Object background = attributes.get(TextAttribute.BACKGROUND);
@@ -494,5 +495,4 @@ public void drawString(AttributedCharacterIterator iterator, float x, float y) {
494495
ppt.getSlides().get(0).draw(dgfx);
495496
}
496497
}
497-
498498
}

poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFBugs.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3331,7 +3331,7 @@ void test58896WithFile() throws IOException {
33313331
LOG.atInfo().log(between(start, now()));
33323332

33333333
assertTrue(between(start, now()).getSeconds() < 25,
3334-
"Had start: " + start + ", now: " + now() +
3334+
"Expected to have less than 25s duration for test, but had start: " + start + ", now: " + now() +
33353335
", diff: " + Duration.between(start, now()).getSeconds());
33363336
}
33373337
}

poi-scratchpad/src/main/java/org/apache/poi/hsmf/datatypes/PropertiesChunk.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,8 +447,9 @@ private void writeFixedLengthValueHeader(OutputStream out, MAPIProperty property
447447
/**
448448
* Writes out pre-calculated raw values which assume any variable length property `data`
449449
* field to already have size, reserved and manually written header
450-
* @param out
451-
* @throws IOException
450+
*
451+
* @param out The OutputStream to write the data to
452+
* @throws IOException If an I/O error occurs while writing data
452453
*/
453454
private void writeVariableLengthPreCalculatedValue(OutputStream out, PropertyValue value) throws IOException {
454455
// variable length header

poi-scratchpad/src/main/java/org/apache/poi/hwpf/HWPFDocument.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ public HWPFDocument(DirectoryNode directory) throws IOException {
291291
_text = _tpt.getText();
292292

293293
/*
294-
* in this mode we preserving PAPX/CHPX structure from file, so text may
294+
* in this mode we are preserving PAPX/CHPX structure from file, so text may
295295
* miss from output, and text order may be corrupted
296296
*/
297297
boolean preserveBinTables = false;

poi/src/main/java/org/apache/poi/hssf/record/RecordFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public static short[] getAllKnownRecordSIDs() {
173173
*
174174
* @param in the InputStream from which the records will be obtained
175175
*
176-
* @return an array of Records created from the InputStream
176+
* @return a list of Records created from the InputStream
177177
*
178178
* @throws org.apache.poi.util.RecordFormatException on error processing the InputStream
179179
*/

0 commit comments

Comments
 (0)