Why does XMLEventReader extend raw Iterator? Due to that XMLEventReader.next() returns Object and we have to use an explicit cast. Shouldn’t it be this way:
public interface XMLEventReader extends Iterator<XmlEvent>
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The Stax api was defined in jsr 173, the specification got to final release status in march of 2004. JDK 5, which introduced generics, was only released in september 2004. The development of jsr 173 started much earlier and so it targeted an earlier java version.
It should be possible to introduce generics in a further release of the api, but I guess no one on the expert group has stepped up to the task.
Note that
XMLEventReaderalso has anextEventmethod that does not require casting.