You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 24, 2018. It is now read-only.
Repository navigation
This repository was archived by the owner on Sep 24, 2018. It is now read-only.
DatatypeConverter / DatatypeConverterInterface are underspecified #42
@jfialli said:
Assumed clarification: Issue is to specify error behavior case when a
DatatypeConverter parse method is unable to parse a string in order
to convert the string value into the target datatype of the parse method.
Survey of existing package java parse methods favors
throwing runtime exception over returning null for
the exception case. Thus, there is existing Java bias
towards stating that a runtime exception is thrown.
Examples of existing Java parse methods for various datatypes:
java.lang.Integer.parse(String) throws NumberFormatException.
(Assume same for rest of java.lang.Number subclasses.)
java.text.DateFormat.parse(String) returns null when String value does not
follow date format.
java.net.URI.URI(String value) throws URISytntaxException when given
string violates RFC 2396.
javax.xml.datatype.DatatypeFactory.newDuration(String value)
javax.xml.datatype.DatatypeFactory.newXMLGregorianCalendar(String value)
are javadoc'ed to throw IllegalArgumentException when lexical
value does not conform to XML Schema specified lexical representations for these
datatypes.
Discussion points:
Should a DatatypeConverter parse methods just state that SOME runtime exception
is thrown for the error case? Or does each method need to specify a precise
runtime exception that would be thrown. (i.e. NumericFormatException when unable
to parse a string into a specific Java Number subclass.) There is a fine line
between over and under specifying when documenting the precise unchecked
exception thrown in the javadoc. Examples above tend to be precise, not
completely certain if that is appropriate for this case.
Activity
glassfishrobot commentedon Oct 20, 2004
Reported by kohsuke
glassfishrobot commentedon Oct 21, 2004
@jfialli said:
Assumed clarification: Issue is to specify error behavior case when a
DatatypeConverter parse method is unable to parse a string in order
to convert the string value into the target datatype of the parse method.
Survey of existing package java parse methods favors
throwing runtime exception over returning null for
the exception case. Thus, there is existing Java bias
towards stating that a runtime exception is thrown.
Examples of existing Java parse methods for various datatypes:
java.lang.Integer.parse(String) throws NumberFormatException.
(Assume same for rest of java.lang.Number subclasses.)
java.text.DateFormat.parse(String) returns null when String value does not
follow date format.
java.net.URI.URI(String value) throws URISytntaxException when given
string violates RFC 2396.
javax.xml.datatype.DatatypeFactory.newDuration(String value)
javax.xml.datatype.DatatypeFactory.newXMLGregorianCalendar(String value)
are javadoc'ed to throw IllegalArgumentException when lexical
value does not conform to XML Schema specified lexical representations for these
datatypes.
Discussion points:
Should a DatatypeConverter parse methods just state that SOME runtime exception
is thrown for the error case? Or does each method need to specify a precise
runtime exception that would be thrown. (i.e. NumericFormatException when unable
to parse a string into a specific Java Number subclass.) There is a fine line
between over and under specifying when documenting the precise unchecked
exception thrown in the javadoc. Examples above tend to be precise, not
completely certain if that is appropriate for this case.
glassfishrobot commentedon May 11, 2017
This issue was imported from java.net JIRA JSR222-42