You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2021/08/07 12:06:13 UTC
[jena] branch main updated: Extend DatatypeFormatException
This is an automated email from the ASF dual-hosted git repository.
andy pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/jena.git
The following commit(s) were added to refs/heads/main by this push:
new 1c3e033 Extend DatatypeFormatException
new 7f29572 Merge pull request #1044 from jmkeil/patch-2
1c3e033 is described below
commit 1c3e03341b248c9efa9b9a5fed4c3be7b2b3c826
Author: Jan Martin Keil <ja...@uni-jena.de>
AuthorDate: Fri Aug 6 11:55:39 2021 +0200
Extend DatatypeFormatException
add constructors with cause parameter, improve JavaDoc
---
.../jena/datatypes/DatatypeFormatException.java | 70 ++++++++++++++++++----
1 file changed, 58 insertions(+), 12 deletions(-)
diff --git a/jena-core/src/main/java/org/apache/jena/datatypes/DatatypeFormatException.java b/jena-core/src/main/java/org/apache/jena/datatypes/DatatypeFormatException.java
index ceea212..1ad3e3a 100644
--- a/jena-core/src/main/java/org/apache/jena/datatypes/DatatypeFormatException.java
+++ b/jena-core/src/main/java/org/apache/jena/datatypes/DatatypeFormatException.java
@@ -26,15 +26,41 @@ import org.apache.jena.shared.* ;
*/
public class DatatypeFormatException extends JenaException
{
+
+ /**
+ * Constructs a new {@code DatatypeFormatException} with the specified
+ * illegal lexical form, datatype and cause. The detail message (for later
+ * retrieval by the {@link #getMessage()} method) is generated using the given
+ * datatype and illegal lexical form.
+ *
+ * @param lexicalForm the illegal lexical form discovered. The illegal lexical form
+ * is saved for later retrieval by the {@link #getLexicalForm()} method.
+ * @param dtype the datatype that found the problem. The datatype is saved for
+ * later retrieval by the {@link #getDataType()} method.
+ * @param cause the cause (which is saved for later retrieval by the
+ * {@link #getCause()} method). (A {@code null} value is
+ * permitted, and indicates that the cause is nonexistent or
+ * unknown.)
+ */
+ public DatatypeFormatException(String lexicalForm, RDFDatatype dtype, Throwable cause) {
+ super(String.format("Lexical form '%s' is not a legal instance of %s.", lexicalForm, dtype), cause);
+ this.lexicalForm = lexicalForm;
+ this.dataType = dtype;
+ }
+
/**
- * Preferred constructor.
- * @param lexicalForm the illegal string discovered
- * @param dtype the datatype that found the problem
- * @param msg additional context for the error
+ * Constructs a new {@code DatatypeFormatException} with the specified
+ * illegal lexical form, datatype and detail message.
+ *
+ * @param lexicalForm the illegal lexical form discovered. The illegal lexical form
+ * is saved for later retrieval by the {@link #getLexicalForm()} method.
+ * @param dtype the datatype that found the problem. The datatype is saved for
+ * later retrieval by the {@link #getDataType()} method.
+ * @param message the detail message (which is saved for later retrieval
+ * by the {@link #getMessage()} method).
*/
- public DatatypeFormatException(String lexicalForm, RDFDatatype dtype, String msg) {
- super("Lexical form '" + lexicalForm +
- "' is not a legal instance of " + dtype + " " + msg);
+ public DatatypeFormatException(String lexicalForm, RDFDatatype dtype, String message) {
+ super(String.format("Lexical form '%s' is not a legal instance of %s %s", lexicalForm, dtype, message));
this.lexicalForm = lexicalForm;
this.dataType = dtype;
}
@@ -52,12 +78,32 @@ public class DatatypeFormatException extends JenaException
}
/**
- * Constructs an instance of <code>DatatypeFormatException</code>
- * with the specified detail message.
- * @param msg the detail message.
+ * Constructs a new {@code DatatypeFormatException} with the specified
+ * detail message and cause.
+ *
+ * @param message the detail message (which is saved for later retrieval
+ * by the {@link #getMessage()} method).
+ * @param cause the cause (which is saved for later retrieval by the
+ * {@link #getCause()} method). (A {@code null} value is
+ * permitted, and indicates that the cause is nonexistent or
+ * unknown.)
+ */
+ public DatatypeFormatException(String message, Throwable cause) {
+ super(message, cause);
+ this.lexicalForm = null;
+ this.dataType = null;
+ }
+
+ /**
+ * Constructs a new @code DatatypeFormatException} with the specified
+ * detail message. The cause is not initialized, and may subsequently be
+ * initialized by a call to {@link #initCause}.
+ *
+ * @param message the detail message. The detail message is saved for
+ * later retrieval by the {@link #getMessage()} method.
*/
- public DatatypeFormatException(String msg) {
- super(msg);
+ public DatatypeFormatException(String message) {
+ super(message);
this.lexicalForm = null;
this.dataType = null;
}