mirror of
https://github.com/apache/poi.git
synced 2025-02-07 02:28:13 +00:00
throw exception if hyperlink is invalid type when validating hyperlink
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1753016 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
55bc4619d5
commit
c0ee980ac7
@ -235,20 +235,26 @@ public class XSSFHyperlink implements Hyperlink {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("fall-through")
|
||||
private void validate(String address) {
|
||||
switch (_type){
|
||||
switch (_type) {
|
||||
// email, path to file and url must be valid URIs
|
||||
case Hyperlink.LINK_EMAIL:
|
||||
case Hyperlink.LINK_FILE:
|
||||
case Hyperlink.LINK_URL:
|
||||
try {
|
||||
new URI(address);
|
||||
} catch (URISyntaxException x) {
|
||||
IllegalArgumentException y = new IllegalArgumentException("Address of hyperlink must be a valid URI");
|
||||
y.initCause(x);
|
||||
throw y;
|
||||
} catch (URISyntaxException e) {
|
||||
throw new IllegalArgumentException("Address of hyperlink must be a valid URI", e);
|
||||
}
|
||||
break;
|
||||
case Hyperlink.LINK_DOCUMENT:
|
||||
// currently not evaluating anything.
|
||||
break;
|
||||
default:
|
||||
// this check wouldn't need to be done if _type was checked when object was set
|
||||
// since _type is final, this check would only need to be done once
|
||||
throw new IllegalStateException("Invalid Hyperlink type: " + _type);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user