0

I am working with the new multimedia tags in HTML5 (video, audio, source, and track). These tags have new attributes that did not exist prior to HTML5 and are not included on the HTML.Attribute class of javax.swing.text.html, such as media, srclang, and kind. Since HTML.Attribute is defined as "public static final class" it is not possible to "extend" this class to add the new values.

I found a class com.inet.html.css.HTML.Attribute that appears to do exactly what I want to do (and adds the "media" attribute), but I cannot figure out how they managed to extend the super class java.lang.Enum.

Any ideas?

Deduplicator
  • 44,692
  • 7
  • 66
  • 118
dacDave
  • 232
  • 1
  • 12
  • Well, you can always copy-paste the source and modify it. – user1803551 Apr 21 '14 at 21:31
  • I am not sure where I would find the source for either javax.swing.text.html.HTML.Attribute or com.inet.html.css.HTML.Attribute. Beyond that, I would like to implement this in a way that it automatically incorporate future changes in javax.swing. In other words, I see my override of methods like valueOf and toString first calling the super class to get the current canonical definition and fail over to my local definition. – dacDave Apr 21 '14 at 23:31
  • You can get the source of the standard Java libraries by downloading the JDK (it contains a JRE, the source and other developing tools). The source along with is also available [here](http://grepcode.com/project/repository.grepcode.com/java/root/jdk/openjdk/). As for a solution, you can't extend the class in any way, but you can write your own class with the same members of the final class (you can use reflection), and call them as if calling `super` - this is a wrapping class. – user1803551 Apr 21 '14 at 23:38
  • Since you mentioned "media" tag, it is oddly mentioned in the source as `static final` While the rest of the attributes are `public static final`. Don't know why and it looks like a mistake. – user1803551 Apr 21 '14 at 23:56
  • Also, by looking at Intel's JWebEngine it seems that they edit it manually. They can extend `java.lang.Enum` because its `public abstract class`. – user1803551 Apr 22 '14 at 00:10

0 Answers0