Skip to content
This repository was archived by the owner on Sep 24, 2018. It is now read-only.
This repository was archived by the owner on Sep 24, 2018. It is now read-only.

DatatypeConverter / DatatypeConverterInterface are underspecified #42

Open

Description

@glassfishrobot

It doesn't say what happens in case of an error. Does it throw an exception?
Does it just return null?

Environment

Operating System: All
Platform: All

Affected Versions

[2.0 v0.4]

Activity

  1. glassfishrobot commented on Oct 20, 2004

    @glassfishrobot
    Author

    Reported by kohsuke

  2. glassfishrobot commented on Oct 21, 2004

    @glassfishrobot
    Author

    @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.

  3. glassfishrobot commented on May 11, 2017

    @glassfishrobot
    Author

    This issue was imported from java.net JIRA JSR222-42

  4. added this to the milestone 1 milestone on May 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions