Evgeniy Dorofeev
Evgeniy Dorofeev

Reputation: 136062

Why does javax.xml.stream.XMLEventReader extend raw Iterator instead of Iterator<XmlEvent>?

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>

Upvotes: 3

Views: 231

Answers (1)

J&#246;rn Horstmann
J&#246;rn Horstmann

Reputation: 34024

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 XMLEventReader also has a nextEvent method that does not require casting.

Upvotes: 4

Related Questions