Skip to content

Commit

Permalink
Merge pull request apache#686 from superfell/datatype_format_exception
Browse files Browse the repository at this point in the history
JENA-1835: Capture and expose lexicalForm and dataType in DatatypeFormatException
  • Loading branch information
afs authored Feb 5, 2020
2 parents 1f3cb72 + 9c62c37 commit 6641533
Showing 1 changed file with 28 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@
*/
public class DatatypeFormatException extends JenaException
{

// TODO Could consider storing the lexical form and datatype in locals
// with accessors.

/**
* Preferred constructor.
* @param lexicalForm the illegal string discovered
Expand All @@ -39,22 +35,48 @@ public class DatatypeFormatException extends JenaException
public DatatypeFormatException(String lexicalForm, RDFDatatype dtype, String msg) {
super("Lexical form '" + lexicalForm +
"' is not a legal instance of " + dtype + " " + msg);
this.lexicalForm = lexicalForm;
this.dataType = dtype;
}


private final String lexicalForm;
private final RDFDatatype dataType;

/**
* Creates a new instance of <code>DatatypeFormatException</code>
* without detail message.
*/
public DatatypeFormatException() {
this.lexicalForm = null;
this.dataType = null;
}

/**
* Constructs an instance of <code>DatatypeFormatException</code>
* with the specified detail message.
* @param msg the detail message.
*/
public DatatypeFormatException(String msg) {
super(msg);
this.lexicalForm = null;
this.dataType = null;
}

/**
* The invalid lexical form that caused this exception.
*
* @return the lexical form that caused the exception. Maybe null depending on how the exception was constructed.
*/
public String getLexicalForm() {
return this.lexicalForm;
}

/**
* The datatype that has an invalid lexical form.
*
* @return the datatype that this exception is related to. Maybe null depending on how the exception was constructed.
*/
public RDFDatatype getDataType() {
return this.dataType;
}
}

0 comments on commit 6641533

Please sign in to comment.