[bug-65741] rework previous change

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1895881 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2021-12-13 13:12:32 +00:00
parent bbef66dee3
commit 837590024f
6 changed files with 45 additions and 54 deletions

View File

@ -236,7 +236,7 @@ public final class PackagePropertiesPart extends PackagePart implements PackageP
}
/**
* Get created date formated into a String.
* Get created date formatted into a String.
*
* @return A string representation of the created date.
*/
@ -308,7 +308,7 @@ public final class PackagePropertiesPart extends PackagePart implements PackageP
}
/**
* Get last printed date formated into a String.
* Get last printed date formatted into a String.
*
* @return A string representation of the last printed date.
*/
@ -326,7 +326,7 @@ public final class PackagePropertiesPart extends PackagePart implements PackageP
}
/**
* Get modified date formated into a String.
* Get modified date formatted into a String.
*
* @return A string representation of the modified date.
*/
@ -379,7 +379,7 @@ public final class PackagePropertiesPart extends PackagePart implements PackageP
*/
@Override
public void setCategoryProperty(String category) {
this.category = setStringValue(category);
this.category = parseStringValue(category);
}
/**
@ -395,7 +395,7 @@ public final class PackagePropertiesPart extends PackagePart implements PackageP
*/
@Override
public void setContentStatusProperty(String contentStatus) {
this.contentStatus = setStringValue(contentStatus);
this.contentStatus = parseStringValue(contentStatus);
}
/**
@ -411,7 +411,7 @@ public final class PackagePropertiesPart extends PackagePart implements PackageP
*/
@Override
public void setContentTypeProperty(String contentType) {
this.contentType = setStringValue(contentType);
this.contentType = parseStringValue(contentType);
}
/**
@ -428,12 +428,10 @@ public final class PackagePropertiesPart extends PackagePart implements PackageP
*/
@Override
public void setCreatedProperty(String created) {
if (created != null) {
try {
this.created = setDateValue(created);
} catch (InvalidFormatException e) {
throw new IllegalArgumentException("Date for created could not be parsed: " + created, e);
}
try {
this.created = parseDateValue(created);
} catch (InvalidFormatException e) {
throw new IllegalArgumentException("Date for created could not be parsed: " + created, e);
}
}
@ -443,8 +441,7 @@ public final class PackagePropertiesPart extends PackagePart implements PackageP
*/
@Override
public void setCreatedProperty(Optional<Date> created) {
if (created.isPresent())
this.created = created;
this.created = created;
}
/**
@ -453,7 +450,7 @@ public final class PackagePropertiesPart extends PackagePart implements PackageP
*/
@Override
public void setCreatorProperty(String creator) {
this.creator = setStringValue(creator);
this.creator = parseStringValue(creator);
}
/**
@ -469,7 +466,7 @@ public final class PackagePropertiesPart extends PackagePart implements PackageP
*/
@Override
public void setDescriptionProperty(String description) {
this.description = setStringValue(description);
this.description = parseStringValue(description);
}
/**
@ -485,7 +482,7 @@ public final class PackagePropertiesPart extends PackagePart implements PackageP
*/
@Override
public void setIdentifierProperty(String identifier) {
this.identifier = setStringValue(identifier);
this.identifier = parseStringValue(identifier);
}
/**
@ -501,7 +498,7 @@ public final class PackagePropertiesPart extends PackagePart implements PackageP
*/
@Override
public void setKeywordsProperty(String keywords) {
this.keywords = setStringValue(keywords);
this.keywords = parseStringValue(keywords);
}
/**
@ -517,7 +514,7 @@ public final class PackagePropertiesPart extends PackagePart implements PackageP
*/
@Override
public void setLanguageProperty(String language) {
this.language = setStringValue(language);
this.language = parseStringValue(language);
}
/**
@ -533,7 +530,7 @@ public final class PackagePropertiesPart extends PackagePart implements PackageP
*/
@Override
public void setLastModifiedByProperty(String lastModifiedBy) {
this.lastModifiedBy = setStringValue(lastModifiedBy);
this.lastModifiedBy = parseStringValue(lastModifiedBy);
}
/**
@ -552,13 +549,11 @@ public final class PackagePropertiesPart extends PackagePart implements PackageP
*/
@Override
public void setLastPrintedProperty(String lastPrinted) {
if (lastPrinted != null) {
try {
this.lastPrinted = setDateValue(lastPrinted);
} catch (InvalidFormatException e) {
throw new IllegalArgumentException("lastPrinted : "
+ e.getLocalizedMessage(), e);
}
try {
this.lastPrinted = parseDateValue(lastPrinted);
} catch (InvalidFormatException e) {
throw new IllegalArgumentException("lastPrinted : "
+ e.getLocalizedMessage(), e);
}
}
@ -568,8 +563,7 @@ public final class PackagePropertiesPart extends PackagePart implements PackageP
*/
@Override
public void setLastPrintedProperty(Optional<Date> lastPrinted) {
if (lastPrinted.isPresent())
this.lastPrinted = lastPrinted;
this.lastPrinted = lastPrinted;
}
/**
@ -579,13 +573,11 @@ public final class PackagePropertiesPart extends PackagePart implements PackageP
*/
@Override
public void setModifiedProperty(String modified) {
if (modified != null) {
try {
this.modified = setDateValue(modified);
} catch (InvalidFormatException e) {
throw new IllegalArgumentException("modified : "
+ e.getLocalizedMessage(), e);
}
try {
this.modified = parseDateValue(modified);
} catch (InvalidFormatException e) {
throw new IllegalArgumentException("modified : "
+ e.getLocalizedMessage(), e);
}
}
@ -595,8 +587,7 @@ public final class PackagePropertiesPart extends PackagePart implements PackageP
*/
@Override
public void setModifiedProperty(Optional<Date> modified) {
if (modified.isPresent())
this.modified = modified;
this.modified = modified;
}
/**
@ -612,7 +603,7 @@ public final class PackagePropertiesPart extends PackagePart implements PackageP
*/
@Override
public void setRevisionProperty(String revision) {
this.revision = setStringValue(revision);
this.revision = parseStringValue(revision);
}
/**
* Set subject.
@ -620,7 +611,7 @@ public final class PackagePropertiesPart extends PackagePart implements PackageP
*/
@Override
public void setSubjectProperty(String subject) {
this.subject = setStringValue(subject);
this.subject = parseStringValue(subject);
}
/**
@ -636,7 +627,7 @@ public final class PackagePropertiesPart extends PackagePart implements PackageP
*/
@Override
public void setTitleProperty(String title) {
this.title = setStringValue(title);
this.title = parseStringValue(title);
}
/**
@ -652,7 +643,7 @@ public final class PackagePropertiesPart extends PackagePart implements PackageP
*/
@Override
public void setVersionProperty(String version) {
this.version = setStringValue(version);
this.version = parseStringValue(version);
}
/**
@ -665,7 +656,7 @@ public final class PackagePropertiesPart extends PackagePart implements PackageP
/**
* Convert a string value into a {@code Optional<String>}
*/
private Optional<String> setStringValue(String s) {
private Optional<String> parseStringValue(String s) {
if (s == null || s.isEmpty()) {
return Optional.empty();
}
@ -678,7 +669,7 @@ public final class PackagePropertiesPart extends PackagePart implements PackageP
* @throws InvalidFormatException
* Throws if the date format is not valid.
*/
private Optional<Date> setDateValue(String dateStr) throws InvalidFormatException {
private Optional<Date> parseDateValue(String dateStr) throws InvalidFormatException {
if (dateStr == null || dateStr.isEmpty()) {
return Optional.empty();
}
@ -720,7 +711,7 @@ public final class PackagePropertiesPart extends PackagePart implements PackageP
*
* @param d
* The Date to convert.
* @return The formated date or null.
* @return The formatted date or null.
* @see java.text.SimpleDateFormat
*/
private static String getDateValue(Optional<Date> d) {

View File

@ -269,7 +269,7 @@ public class MAPIMessage extends POIReadOnlyDocument {
/**
* Gets the display value of the "FROM" line of the outlook message
* This is not the actual address that was sent from but the formated display of the user name.
* This is not the actual address that was sent from but the formatted display of the user name.
* @throws ChunkNotFoundException If the from-chunk does not exist and
* returnNullOnMissingChunk is set
*/

View File

@ -75,7 +75,7 @@ final class TestHSSFRichTextString {
/**
* Test case proposed in Bug 40520: formated twice => will format whole String
* Test case proposed in Bug 40520: formatted twice => will format whole String
*/
@Test
void test40520_1() {
@ -109,7 +109,7 @@ final class TestHSSFRichTextString {
}
/**
* Test case proposed in Bug 40520: formated twice => will format whole String
* Test case proposed in Bug 40520: formatted twice => will format whole String
*/
@Test
void test40520_3() {

View File

@ -421,7 +421,7 @@ public abstract class BaseTestDataValidation {
CellStyle cellStyle_time = wb.createCellStyle();
cellStyle_time.setDataFormat(fmtTime);
wf.createDVTypeRow("Date ( cells are already formated as date - m/d/yyyy)");
wf.createDVTypeRow("Date ( cells are already formatted as date - m/d/yyyy)");
wf.createHeaderRow();
ValidationAdder va = wf.createValidationAdder(cellStyle_date, ValidationType.DATE);
@ -435,7 +435,7 @@ public abstract class BaseTestDataValidation {
va.addValidation(OperatorType.LESS_OR_EQUAL, "2004/03/04", null, ErrorStyle.STOP, "Less than or equal to 3/4/2004", "-", false, true, false);
// "Time" validation type
wf.createDVTypeRow("Time ( cells are already formated as time - h:mm)");
wf.createDVTypeRow("Time ( cells are already formatted as time - h:mm)");
wf.createHeaderRow();
va = wf.createValidationAdder(cellStyle_time, ValidationType.TIME);

View File

@ -21,9 +21,9 @@
41 74 20
41 74 20
00 00 # Formatting run 1, first formated char at 0
00 00 # Formatting run 1, first formatted char at 0
00 00 # Formatting run 1, Index to font record
02 00 # Formatting run 2, first formated char at 2
02 00 # Formatting run 2, first formatted char at 2
00 00 # Formatting run 2, Index to font record
FF FF FF # extended data

View File

@ -17,7 +17,7 @@
41 74 20
41 74 20
00 00 # Formatting run 1, first formated char at 0
00 00 # Formatting run 1, first formatted char at 0
00 00 # Formatting run 1, Index to font record
02 00 # Formatting run 2, first formated char at 2
02 00 # Formatting run 2, first formatted char at 2
00 00 # Formatting run 2, Index to font record