mirror of https://github.com/apache/poi.git
[bug-65741] change some methods to throw checked exception InvalidFormatException
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1895882 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
837590024f
commit
469a485f38
|
@ -276,7 +276,7 @@ public class POIXMLProperties {
|
||||||
public void setCreated(Optional<Date> date) {
|
public void setCreated(Optional<Date> date) {
|
||||||
part.setCreatedProperty(date);
|
part.setCreatedProperty(date);
|
||||||
}
|
}
|
||||||
public void setCreated(String date) {
|
public void setCreated(String date) throws InvalidFormatException {
|
||||||
part.setCreatedProperty(date);
|
part.setCreatedProperty(date);
|
||||||
}
|
}
|
||||||
public String getCreator() {
|
public String getCreator() {
|
||||||
|
@ -309,7 +309,7 @@ public class POIXMLProperties {
|
||||||
public void setLastPrinted(Optional<Date> date) {
|
public void setLastPrinted(Optional<Date> date) {
|
||||||
part.setLastPrintedProperty(date);
|
part.setLastPrintedProperty(date);
|
||||||
}
|
}
|
||||||
public void setLastPrinted(String date) {
|
public void setLastPrinted(String date) throws InvalidFormatException {
|
||||||
part.setLastPrintedProperty(date);
|
part.setLastPrintedProperty(date);
|
||||||
}
|
}
|
||||||
/** @since POI 3.15 beta 3 */
|
/** @since POI 3.15 beta 3 */
|
||||||
|
@ -326,7 +326,7 @@ public class POIXMLProperties {
|
||||||
public void setModified(Optional<Date> date) {
|
public void setModified(Optional<Date> date) {
|
||||||
part.setModifiedProperty(date);
|
part.setModifiedProperty(date);
|
||||||
}
|
}
|
||||||
public void setModified(String date) {
|
public void setModified(String date) throws InvalidFormatException {
|
||||||
part.setModifiedProperty(date);
|
part.setModifiedProperty(date);
|
||||||
}
|
}
|
||||||
public String getSubject() {
|
public String getSubject() {
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
|
|
||||||
package org.apache.poi.openxml4j.opc;
|
package org.apache.poi.openxml4j.opc;
|
||||||
|
|
||||||
|
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@ -102,8 +104,10 @@ public interface PackageProperties {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the date of creation of the resource.
|
* Set the date of creation of the resource.
|
||||||
|
* @throws InvalidFormatException only since POI 5.2.0, used to throw unchecked exception
|
||||||
|
* IllegalArgumentException if format was invalid
|
||||||
*/
|
*/
|
||||||
void setCreatedProperty(String created);
|
void setCreatedProperty(String created) throws InvalidFormatException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the date of creation of the resource.
|
* Set the date of creation of the resource.
|
||||||
|
@ -227,8 +231,10 @@ public interface PackageProperties {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the date and time of the last printing.
|
* Set the date and time of the last printing.
|
||||||
|
* @throws InvalidFormatException only since POI 5.2.0, used to throw unchecked exception
|
||||||
|
* IllegalArgumentException if format was invalid
|
||||||
*/
|
*/
|
||||||
void setLastPrintedProperty(String lastPrinted);
|
void setLastPrintedProperty(String lastPrinted) throws InvalidFormatException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the date and time of the last printing.
|
* Set the date and time of the last printing.
|
||||||
|
@ -243,8 +249,10 @@ public interface PackageProperties {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the date on which the resource was changed.
|
* Set the date on which the resource was changed.
|
||||||
|
* @throws InvalidFormatException only since POI 5.2.0, used to throw unchecked exception
|
||||||
|
* IllegalArgumentException if format was invalid
|
||||||
*/
|
*/
|
||||||
void setModifiedProperty(String modified);
|
void setModifiedProperty(String modified) throws InvalidFormatException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the date on which the resource was changed.
|
* Set the date on which the resource was changed.
|
||||||
|
|
|
@ -427,12 +427,8 @@ public final class PackagePropertiesPart extends PackagePart implements PackageP
|
||||||
* @see org.apache.poi.openxml4j.opc.PackageProperties#setCreatedProperty(java.util.Optional)
|
* @see org.apache.poi.openxml4j.opc.PackageProperties#setCreatedProperty(java.util.Optional)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setCreatedProperty(String created) {
|
public void setCreatedProperty(String created) throws InvalidFormatException {
|
||||||
try {
|
|
||||||
this.created = parseDateValue(created);
|
this.created = parseDateValue(created);
|
||||||
} catch (InvalidFormatException e) {
|
|
||||||
throw new IllegalArgumentException("Date for created could not be parsed: " + created, e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -548,13 +544,8 @@ public final class PackagePropertiesPart extends PackagePart implements PackageP
|
||||||
* @see org.apache.poi.openxml4j.opc.PackageProperties#setLastPrintedProperty(java.util.Optional)
|
* @see org.apache.poi.openxml4j.opc.PackageProperties#setLastPrintedProperty(java.util.Optional)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setLastPrintedProperty(String lastPrinted) {
|
public void setLastPrintedProperty(String lastPrinted) throws InvalidFormatException {
|
||||||
try {
|
|
||||||
this.lastPrinted = parseDateValue(lastPrinted);
|
this.lastPrinted = parseDateValue(lastPrinted);
|
||||||
} catch (InvalidFormatException e) {
|
|
||||||
throw new IllegalArgumentException("lastPrinted : "
|
|
||||||
+ e.getLocalizedMessage(), e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -572,13 +563,8 @@ public final class PackagePropertiesPart extends PackagePart implements PackageP
|
||||||
* @see org.apache.poi.openxml4j.opc.PackageProperties#setModifiedProperty(java.util.Optional)
|
* @see org.apache.poi.openxml4j.opc.PackageProperties#setModifiedProperty(java.util.Optional)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setModifiedProperty(String modified) {
|
public void setModifiedProperty(String modified) throws InvalidFormatException {
|
||||||
try {
|
|
||||||
this.modified = parseDateValue(modified);
|
this.modified = parseDateValue(modified);
|
||||||
} catch (InvalidFormatException e) {
|
|
||||||
throw new IllegalArgumentException("modified : "
|
|
||||||
+ e.getLocalizedMessage(), e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue